ホーム › Globalization › ucal_open
ucal_open
関数タイムゾーンとロケールを指定してカレンダーを開く。
シグネチャ
// icuin.dll
#include <windows.h>
void** ucal_open(
const WORD* zoneID,
INT len,
LPCSTR locale,
UCalendarType type,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| zoneID | WORD* | in | 暦に関連付けるタイムゾーンID(UTF-16)。NULLで既定。 |
| len | INT | in | zoneIDの長さをUChar単位で指定する。-1でNUL終端。 |
| locale | LPCSTR | in | 暦の挙動に用いるロケールID。NULLで既定ロケール。 |
| type | UCalendarType | in | 生成する暦の種別を示すUCalendarType列挙値。 |
| status | UErrorCode* | inout | ICUエラーコードを入出力するポインタ。呼出前に成功値で初期化する。 |
戻り値の型: void**
各言語での呼び出し定義
// icuin.dll
#include <windows.h>
void** ucal_open(
const WORD* zoneID,
INT len,
LPCSTR locale,
UCalendarType type,
UErrorCode* status
);[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ucal_open(
ref ushort zoneID, // WORD*
int len, // INT
[MarshalAs(UnmanagedType.LPStr)] string locale, // LPCSTR
int type, // UCalendarType
ref int status // UErrorCode* in/out
);<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucal_open(
ByRef zoneID As UShort, ' WORD*
len As Integer, ' INT
<MarshalAs(UnmanagedType.LPStr)> locale As String, ' LPCSTR
type As Integer, ' UCalendarType
ByRef status As Integer ' UErrorCode* in/out
) As IntPtr
End Function' zoneID : WORD*
' len : INT
' locale : LPCSTR
' type : UCalendarType
' status : UErrorCode* in/out
Declare PtrSafe Function ucal_open Lib "icuin" ( _
ByRef zoneID As Integer, _
ByVal len As Long, _
ByVal locale As String, _
ByVal type As Long, _
ByRef status As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ucal_open = ctypes.cdll.icuin.ucal_open
ucal_open.restype = ctypes.c_void_p
ucal_open.argtypes = [
ctypes.POINTER(ctypes.c_ushort), # zoneID : WORD*
ctypes.c_int, # len : INT
wintypes.LPCSTR, # locale : LPCSTR
ctypes.c_int, # type : UCalendarType
ctypes.c_void_p, # status : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuin.dll')
ucal_open = Fiddle::Function.new(
lib['ucal_open'],
[
Fiddle::TYPE_VOIDP, # zoneID : WORD*
Fiddle::TYPE_INT, # len : INT
Fiddle::TYPE_VOIDP, # locale : LPCSTR
Fiddle::TYPE_INT, # type : UCalendarType
Fiddle::TYPE_VOIDP, # status : UErrorCode* in/out
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icuin")]
extern "C" {
fn ucal_open(
zoneID: *const u16, // WORD*
len: i32, // INT
locale: *const u8, // LPCSTR
type: i32, // UCalendarType
status: *mut i32 // UErrorCode* in/out
) -> *mut *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuin.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ucal_open(ref ushort zoneID, int len, [MarshalAs(UnmanagedType.LPStr)] string locale, int type, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_ucal_open' -Namespace Win32 -PassThru
# $api::ucal_open(zoneID, len, locale, type, status)#uselib "icuin.dll"
#func global ucal_open "ucal_open" sptr, sptr, sptr, sptr, sptr
; ucal_open varptr(zoneID), len, locale, type, varptr(status) ; 戻り値は stat
; zoneID : WORD* -> "sptr"
; len : INT -> "sptr"
; locale : LPCSTR -> "sptr"
; type : UCalendarType -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuin.dll" #cfunc global ucal_open "ucal_open" var, int, str, int, var ; res = ucal_open(zoneID, len, locale, type, status) ; zoneID : WORD* -> "var" ; len : INT -> "int" ; locale : LPCSTR -> "str" ; type : UCalendarType -> "int" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuin.dll" #cfunc global ucal_open "ucal_open" sptr, int, str, int, sptr ; res = ucal_open(varptr(zoneID), len, locale, type, varptr(status)) ; zoneID : WORD* -> "sptr" ; len : INT -> "int" ; locale : LPCSTR -> "str" ; type : UCalendarType -> "int" ; status : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void** ucal_open(WORD* zoneID, INT len, LPCSTR locale, UCalendarType type, UErrorCode* status) #uselib "icuin.dll" #cfunc global ucal_open "ucal_open" var, int, str, int, var ; res = ucal_open(zoneID, len, locale, type, status) ; zoneID : WORD* -> "var" ; len : INT -> "int" ; locale : LPCSTR -> "str" ; type : UCalendarType -> "int" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void** ucal_open(WORD* zoneID, INT len, LPCSTR locale, UCalendarType type, UErrorCode* status) #uselib "icuin.dll" #cfunc global ucal_open "ucal_open" intptr, int, str, int, intptr ; res = ucal_open(varptr(zoneID), len, locale, type, varptr(status)) ; zoneID : WORD* -> "intptr" ; len : INT -> "int" ; locale : LPCSTR -> "str" ; type : UCalendarType -> "int" ; status : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuin = windows.NewLazySystemDLL("icuin.dll")
procucal_open = icuin.NewProc("ucal_open")
)
// zoneID (WORD*), len (INT), locale (LPCSTR), type (UCalendarType), status (UErrorCode* in/out)
r1, _, err := procucal_open.Call(
uintptr(zoneID),
uintptr(len),
uintptr(unsafe.Pointer(windows.BytePtrFromString(locale))),
uintptr(type),
uintptr(status),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // void**function ucal_open(
zoneID: Pointer; // WORD*
len: Integer; // INT
locale: PAnsiChar; // LPCSTR
type: Integer; // UCalendarType
status: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icuin.dll' name 'ucal_open';result := DllCall("icuin\ucal_open"
, "Ptr", zoneID ; WORD*
, "Int", len ; INT
, "AStr", locale ; LPCSTR
, "Int", type ; UCalendarType
, "Ptr", status ; UErrorCode* in/out
, "Cdecl Ptr") ; return: void**●ucal_open(zoneID, len, locale, type, status) = DLL("icuin.dll", "void* ucal_open(void*, int, char*, int, void*)")
# 呼び出し: ucal_open(zoneID, len, locale, type, status)
# zoneID : WORD* -> "void*"
# len : INT -> "int"
# locale : LPCSTR -> "char*"
# type : UCalendarType -> "int"
# status : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "icuin" fn ucal_open(
zoneID: [*c]u16, // WORD*
len: i32, // INT
locale: [*c]const u8, // LPCSTR
type: i32, // UCalendarType
status: [*c]i32 // UErrorCode* in/out
) callconv(.c) ?*anyopaque;proc ucal_open(
zoneID: ptr uint16, # WORD*
len: int32, # INT
locale: cstring, # LPCSTR
`type`: int32, # UCalendarType
status: ptr int32 # UErrorCode* in/out
): pointer {.importc: "ucal_open", cdecl, dynlib: "icuin.dll".}pragma(lib, "icuin");
extern(C)
void** ucal_open(
ushort* zoneID, // WORD*
int len, // INT
const(char)* locale, // LPCSTR
int type, // UCalendarType
int* status // UErrorCode* in/out
);ccall((:ucal_open, "icuin.dll"), Ptr{Cvoid},
(Ptr{UInt16}, Int32, Cstring, Int32, Ptr{Int32}),
zoneID, len, locale, type, status)
# zoneID : WORD* -> Ptr{UInt16}
# len : INT -> Int32
# locale : LPCSTR -> Cstring
# type : UCalendarType -> Int32
# status : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
void** ucal_open(
uint16_t* zoneID,
int32_t len,
const char* locale,
int32_t type,
int32_t* status);
]]
local icuin = ffi.load("icuin")
-- icuin.ucal_open(zoneID, len, locale, type, status)
-- zoneID : WORD*
-- len : INT
-- locale : LPCSTR
-- type : UCalendarType
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuin.dll');
const ucal_open = lib.func('__cdecl', 'ucal_open', 'void *', ['uint16_t *', 'int32_t', 'str', 'int32_t', 'int32_t *']);
// ucal_open(zoneID, len, locale, type, status)
// zoneID : WORD* -> 'uint16_t *'
// len : INT -> 'int32_t'
// locale : LPCSTR -> 'str'
// type : UCalendarType -> 'int32_t'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuin.dll", {
ucal_open: { parameters: ["pointer", "i32", "buffer", "i32", "pointer"], result: "pointer" },
});
// lib.symbols.ucal_open(zoneID, len, locale, type, status)
// zoneID : WORD* -> "pointer"
// len : INT -> "i32"
// locale : LPCSTR -> "buffer"
// type : UCalendarType -> "i32"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void** ucal_open(
uint16_t* zoneID,
int32_t len,
const char* locale,
int32_t type,
int32_t* status);
C, "icuin.dll");
// $ffi->ucal_open(zoneID, len, locale, type, status);
// zoneID : WORD*
// len : INT
// locale : LPCSTR
// type : UCalendarType
// status : UErrorCode* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Icuin extends Library {
Icuin INSTANCE = Native.load("icuin", Icuin.class);
Pointer ucal_open(
ShortByReference zoneID, // WORD*
int len, // INT
String locale, // LPCSTR
int type, // UCalendarType
IntByReference status // UErrorCode* in/out
);
}@[Link("icuin")]
lib Libicuin
fun ucal_open = ucal_open(
zoneID : UInt16*, # WORD*
len : Int32, # INT
locale : UInt8*, # LPCSTR
type_ : Int32, # UCalendarType
status : Int32* # UErrorCode* in/out
) : Void**
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ucal_openNative = Pointer<Void> Function(Pointer<Uint16>, Int32, Pointer<Utf8>, Int32, Pointer<Int32>);
typedef ucal_openDart = Pointer<Void> Function(Pointer<Uint16>, int, Pointer<Utf8>, int, Pointer<Int32>);
final ucal_open = DynamicLibrary.open('icuin.dll')
.lookupFunction<ucal_openNative, ucal_openDart>('ucal_open');
// zoneID : WORD* -> Pointer<Uint16>
// len : INT -> Int32
// locale : LPCSTR -> Pointer<Utf8>
// type : UCalendarType -> Int32
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ucal_open(
zoneID: Pointer; // WORD*
len: Integer; // INT
locale: PAnsiChar; // LPCSTR
type: Integer; // UCalendarType
status: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icuin.dll' name 'ucal_open';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ucal_open"
c_ucal_open :: Ptr Word16 -> Int32 -> CString -> Int32 -> Ptr Int32 -> IO (Ptr ())
-- zoneID : WORD* -> Ptr Word16
-- len : INT -> Int32
-- locale : LPCSTR -> CString
-- type : UCalendarType -> Int32
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ucal_open =
foreign "ucal_open"
((ptr uint16_t) @-> int32_t @-> string @-> int32_t @-> (ptr int32_t) @-> returning (ptr void))
(* zoneID : WORD* -> (ptr uint16_t) *)
(* len : INT -> int32_t *)
(* locale : LPCSTR -> string *)
(* type : UCalendarType -> int32_t *)
(* status : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuin (t "icuin.dll"))
(cffi:use-foreign-library icuin)
(cffi:defcfun ("ucal_open" ucal-open :convention :cdecl) :pointer
(zone-id :pointer) ; WORD*
(len :int32) ; INT
(locale :string) ; LPCSTR
(type :int32) ; UCalendarType
(status :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ucal_open = Win32::API::More->new('icuin',
'LPVOID ucal_open(LPVOID zoneID, int len, LPCSTR locale, int type, LPVOID status)');
# my $ret = $ucal_open->Call($zoneID, $len, $locale, $type, $status);
# zoneID : WORD* -> LPVOID
# len : INT -> int
# locale : LPCSTR -> LPCSTR
# type : UCalendarType -> int
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。