ホーム › 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 |
| len | INT | in |
| locale | LPCSTR | in |
| type | UCalendarType | in |
| status | UErrorCode* | inout |
戻り値の型: 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, 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, int ; res = ucal_open(zoneID, len, locale, type, status) ; zoneID : WORD* -> "var" ; len : INT -> "int" ; locale : LPCSTR -> "str" ; type : UCalendarType -> "int" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuin.dll" #cfunc global ucal_open "ucal_open" sptr, int, str, int, int ; res = ucal_open(varptr(zoneID), len, locale, type, status) ; zoneID : WORD* -> "sptr" ; len : INT -> "int" ; locale : LPCSTR -> "str" ; type : UCalendarType -> "int" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(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, int ; res = ucal_open(zoneID, len, locale, type, status) ; zoneID : WORD* -> "var" ; len : INT -> "int" ; locale : LPCSTR -> "str" ; type : UCalendarType -> "int" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は 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, int ; res = ucal_open(varptr(zoneID), len, locale, type, status) ; zoneID : WORD* -> "intptr" ; len : INT -> "int" ; locale : LPCSTR -> "str" ; type : UCalendarType -> "int" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(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`,…) を使用。