Win32 API 日本語リファレンス
ホームGlobalization › udat_open

udat_open

関数
スタイルやパターンを指定し日付フォーマッタを開く。
DLLicuin.dll呼出規約cdecl

シグネチャ

// icuin.dll
#include <windows.h>

void** udat_open(
    UDateFormatStyle timeStyle,
    UDateFormatStyle dateStyle,
    LPCSTR locale,
    const WORD* tzID,
    INT tzIDLength,
    const WORD* pattern,
    INT patternLength,
    UErrorCode* status
);

パラメーター

名前方向説明
timeStyleUDateFormatStylein時刻部分の書式スタイルを示す列挙値。UDAT_NONEで時刻を省く。
dateStyleUDateFormatStylein日付部分の書式スタイルを示す列挙値。UDAT_PATTERNでパターン使用。
localeLPCSTRin日付書式に用いるロケール名。NULLで既定ロケールを使用する。
tzIDWORD*inタイムゾーンID文字列。UTF-16配列。NULLで既定タイムゾーンを使う。
tzIDLengthINTinタイムゾーンIDの長さ(UTF-16単位)。-1でNUL終端として扱う。
patternWORD*inPATTERNスタイル時に使う日付書式パターン文字列。UTF-16配列。
patternLengthINTinパターンの長さ(UTF-16単位)。-1でNUL終端として扱う。
statusUErrorCode*inoutICUのエラーコード。呼び出し前に成功値で初期化する。

戻り値の型: void**

各言語での呼び出し定義

// icuin.dll
#include <windows.h>

void** udat_open(
    UDateFormatStyle timeStyle,
    UDateFormatStyle dateStyle,
    LPCSTR locale,
    const WORD* tzID,
    INT tzIDLength,
    const WORD* pattern,
    INT patternLength,
    UErrorCode* status
);
[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr udat_open(
    int timeStyle,   // UDateFormatStyle
    int dateStyle,   // UDateFormatStyle
    [MarshalAs(UnmanagedType.LPStr)] string locale,   // LPCSTR
    ref ushort tzID,   // WORD*
    int tzIDLength,   // INT
    ref ushort pattern,   // WORD*
    int patternLength,   // INT
    ref int status   // UErrorCode* in/out
);
<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function udat_open(
    timeStyle As Integer,   ' UDateFormatStyle
    dateStyle As Integer,   ' UDateFormatStyle
    <MarshalAs(UnmanagedType.LPStr)> locale As String,   ' LPCSTR
    ByRef tzID As UShort,   ' WORD*
    tzIDLength As Integer,   ' INT
    ByRef pattern As UShort,   ' WORD*
    patternLength As Integer,   ' INT
    ByRef status As Integer   ' UErrorCode* in/out
) As IntPtr
End Function
' timeStyle : UDateFormatStyle
' dateStyle : UDateFormatStyle
' locale : LPCSTR
' tzID : WORD*
' tzIDLength : INT
' pattern : WORD*
' patternLength : INT
' status : UErrorCode* in/out
Declare PtrSafe Function udat_open Lib "icuin" ( _
    ByVal timeStyle As Long, _
    ByVal dateStyle As Long, _
    ByVal locale As String, _
    ByRef tzID As Integer, _
    ByVal tzIDLength As Long, _
    ByRef pattern As Integer, _
    ByVal patternLength 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

udat_open = ctypes.cdll.icuin.udat_open
udat_open.restype = ctypes.c_void_p
udat_open.argtypes = [
    ctypes.c_int,  # timeStyle : UDateFormatStyle
    ctypes.c_int,  # dateStyle : UDateFormatStyle
    wintypes.LPCSTR,  # locale : LPCSTR
    ctypes.POINTER(ctypes.c_ushort),  # tzID : WORD*
    ctypes.c_int,  # tzIDLength : INT
    ctypes.POINTER(ctypes.c_ushort),  # pattern : WORD*
    ctypes.c_int,  # patternLength : INT
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuin.dll')
udat_open = Fiddle::Function.new(
  lib['udat_open'],
  [
    Fiddle::TYPE_INT,  # timeStyle : UDateFormatStyle
    Fiddle::TYPE_INT,  # dateStyle : UDateFormatStyle
    Fiddle::TYPE_VOIDP,  # locale : LPCSTR
    Fiddle::TYPE_VOIDP,  # tzID : WORD*
    Fiddle::TYPE_INT,  # tzIDLength : INT
    Fiddle::TYPE_VOIDP,  # pattern : WORD*
    Fiddle::TYPE_INT,  # patternLength : INT
    Fiddle::TYPE_VOIDP,  # status : UErrorCode* in/out
  ],
  Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)
#[link(name = "icuin")]
extern "C" {
    fn udat_open(
        timeStyle: i32,  // UDateFormatStyle
        dateStyle: i32,  // UDateFormatStyle
        locale: *const u8,  // LPCSTR
        tzID: *const u16,  // WORD*
        tzIDLength: i32,  // INT
        pattern: *const u16,  // WORD*
        patternLength: i32,  // INT
        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 udat_open(int timeStyle, int dateStyle, [MarshalAs(UnmanagedType.LPStr)] string locale, ref ushort tzID, int tzIDLength, ref ushort pattern, int patternLength, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_udat_open' -Namespace Win32 -PassThru
# $api::udat_open(timeStyle, dateStyle, locale, tzID, tzIDLength, pattern, patternLength, status)
#uselib "icuin.dll"
#func global udat_open "udat_open" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; udat_open timeStyle, dateStyle, locale, varptr(tzID), tzIDLength, varptr(pattern), patternLength, varptr(status)   ; 戻り値は stat
; timeStyle : UDateFormatStyle -> "sptr"
; dateStyle : UDateFormatStyle -> "sptr"
; locale : LPCSTR -> "sptr"
; tzID : WORD* -> "sptr"
; tzIDLength : INT -> "sptr"
; pattern : WORD* -> "sptr"
; patternLength : INT -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuin.dll"
#cfunc global udat_open "udat_open" int, int, str, var, int, var, int, var
; res = udat_open(timeStyle, dateStyle, locale, tzID, tzIDLength, pattern, patternLength, status)
; timeStyle : UDateFormatStyle -> "int"
; dateStyle : UDateFormatStyle -> "int"
; locale : LPCSTR -> "str"
; tzID : WORD* -> "var"
; tzIDLength : INT -> "int"
; pattern : WORD* -> "var"
; patternLength : INT -> "int"
; status : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void** udat_open(UDateFormatStyle timeStyle, UDateFormatStyle dateStyle, LPCSTR locale, WORD* tzID, INT tzIDLength, WORD* pattern, INT patternLength, UErrorCode* status)
#uselib "icuin.dll"
#cfunc global udat_open "udat_open" int, int, str, var, int, var, int, var
; res = udat_open(timeStyle, dateStyle, locale, tzID, tzIDLength, pattern, patternLength, status)
; timeStyle : UDateFormatStyle -> "int"
; dateStyle : UDateFormatStyle -> "int"
; locale : LPCSTR -> "str"
; tzID : WORD* -> "var"
; tzIDLength : INT -> "int"
; pattern : WORD* -> "var"
; patternLength : INT -> "int"
; status : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuin = windows.NewLazySystemDLL("icuin.dll")
	procudat_open = icuin.NewProc("udat_open")
)

// timeStyle (UDateFormatStyle), dateStyle (UDateFormatStyle), locale (LPCSTR), tzID (WORD*), tzIDLength (INT), pattern (WORD*), patternLength (INT), status (UErrorCode* in/out)
r1, _, err := procudat_open.Call(
	uintptr(timeStyle),
	uintptr(dateStyle),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(locale))),
	uintptr(tzID),
	uintptr(tzIDLength),
	uintptr(pattern),
	uintptr(patternLength),
	uintptr(status),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void**
function udat_open(
  timeStyle: Integer;   // UDateFormatStyle
  dateStyle: Integer;   // UDateFormatStyle
  locale: PAnsiChar;   // LPCSTR
  tzID: Pointer;   // WORD*
  tzIDLength: Integer;   // INT
  pattern: Pointer;   // WORD*
  patternLength: Integer;   // INT
  status: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icuin.dll' name 'udat_open';
result := DllCall("icuin\udat_open"
    , "Int", timeStyle   ; UDateFormatStyle
    , "Int", dateStyle   ; UDateFormatStyle
    , "AStr", locale   ; LPCSTR
    , "Ptr", tzID   ; WORD*
    , "Int", tzIDLength   ; INT
    , "Ptr", pattern   ; WORD*
    , "Int", patternLength   ; INT
    , "Ptr", status   ; UErrorCode* in/out
    , "Cdecl Ptr")   ; return: void**
●udat_open(timeStyle, dateStyle, locale, tzID, tzIDLength, pattern, patternLength, status) = DLL("icuin.dll", "void* udat_open(int, int, char*, void*, int, void*, int, void*)")
# 呼び出し: udat_open(timeStyle, dateStyle, locale, tzID, tzIDLength, pattern, patternLength, status)
# timeStyle : UDateFormatStyle -> "int"
# dateStyle : UDateFormatStyle -> "int"
# locale : LPCSTR -> "char*"
# tzID : WORD* -> "void*"
# tzIDLength : INT -> "int"
# pattern : WORD* -> "void*"
# patternLength : INT -> "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 udat_open(
    timeStyle: i32, // UDateFormatStyle
    dateStyle: i32, // UDateFormatStyle
    locale: [*c]const u8, // LPCSTR
    tzID: [*c]u16, // WORD*
    tzIDLength: i32, // INT
    pattern: [*c]u16, // WORD*
    patternLength: i32, // INT
    status: [*c]i32 // UErrorCode* in/out
) callconv(.c) ?*anyopaque;
proc udat_open(
    timeStyle: int32,  # UDateFormatStyle
    dateStyle: int32,  # UDateFormatStyle
    locale: cstring,  # LPCSTR
    tzID: ptr uint16,  # WORD*
    tzIDLength: int32,  # INT
    pattern: ptr uint16,  # WORD*
    patternLength: int32,  # INT
    status: ptr int32  # UErrorCode* in/out
): pointer {.importc: "udat_open", cdecl, dynlib: "icuin.dll".}
pragma(lib, "icuin");
extern(C)
void** udat_open(
    int timeStyle,   // UDateFormatStyle
    int dateStyle,   // UDateFormatStyle
    const(char)* locale,   // LPCSTR
    ushort* tzID,   // WORD*
    int tzIDLength,   // INT
    ushort* pattern,   // WORD*
    int patternLength,   // INT
    int* status   // UErrorCode* in/out
);
ccall((:udat_open, "icuin.dll"), Ptr{Cvoid},
      (Int32, Int32, Cstring, Ptr{UInt16}, Int32, Ptr{UInt16}, Int32, Ptr{Int32}),
      timeStyle, dateStyle, locale, tzID, tzIDLength, pattern, patternLength, status)
# timeStyle : UDateFormatStyle -> Int32
# dateStyle : UDateFormatStyle -> Int32
# locale : LPCSTR -> Cstring
# tzID : WORD* -> Ptr{UInt16}
# tzIDLength : INT -> Int32
# pattern : WORD* -> Ptr{UInt16}
# patternLength : INT -> Int32
# status : UErrorCode* in/out -> Ptr{Int32}
local ffi = require("ffi")
ffi.cdef[[
void** udat_open(
    int32_t timeStyle,
    int32_t dateStyle,
    const char* locale,
    uint16_t* tzID,
    int32_t tzIDLength,
    uint16_t* pattern,
    int32_t patternLength,
    int32_t* status);
]]
local icuin = ffi.load("icuin")
-- icuin.udat_open(timeStyle, dateStyle, locale, tzID, tzIDLength, pattern, patternLength, status)
-- timeStyle : UDateFormatStyle
-- dateStyle : UDateFormatStyle
-- locale : LPCSTR
-- tzID : WORD*
-- tzIDLength : INT
-- pattern : WORD*
-- patternLength : INT
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuin.dll');
const udat_open = lib.func('__cdecl', 'udat_open', 'void *', ['int32_t', 'int32_t', 'str', 'uint16_t *', 'int32_t', 'uint16_t *', 'int32_t', 'int32_t *']);
// udat_open(timeStyle, dateStyle, locale, tzID, tzIDLength, pattern, patternLength, status)
// timeStyle : UDateFormatStyle -> 'int32_t'
// dateStyle : UDateFormatStyle -> 'int32_t'
// locale : LPCSTR -> 'str'
// tzID : WORD* -> 'uint16_t *'
// tzIDLength : INT -> 'int32_t'
// pattern : WORD* -> 'uint16_t *'
// patternLength : INT -> 'int32_t'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuin.dll", {
  udat_open: { parameters: ["i32", "i32", "buffer", "pointer", "i32", "pointer", "i32", "pointer"], result: "pointer" },
});
// lib.symbols.udat_open(timeStyle, dateStyle, locale, tzID, tzIDLength, pattern, patternLength, status)
// timeStyle : UDateFormatStyle -> "i32"
// dateStyle : UDateFormatStyle -> "i32"
// locale : LPCSTR -> "buffer"
// tzID : WORD* -> "pointer"
// tzIDLength : INT -> "i32"
// pattern : WORD* -> "pointer"
// patternLength : INT -> "i32"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void** udat_open(
    int32_t timeStyle,
    int32_t dateStyle,
    const char* locale,
    uint16_t* tzID,
    int32_t tzIDLength,
    uint16_t* pattern,
    int32_t patternLength,
    int32_t* status);
C, "icuin.dll");
// $ffi->udat_open(timeStyle, dateStyle, locale, tzID, tzIDLength, pattern, patternLength, status);
// timeStyle : UDateFormatStyle
// dateStyle : UDateFormatStyle
// locale : LPCSTR
// tzID : WORD*
// tzIDLength : INT
// pattern : WORD*
// patternLength : INT
// 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 udat_open(
        int timeStyle,   // UDateFormatStyle
        int dateStyle,   // UDateFormatStyle
        String locale,   // LPCSTR
        ShortByReference tzID,   // WORD*
        int tzIDLength,   // INT
        ShortByReference pattern,   // WORD*
        int patternLength,   // INT
        IntByReference status   // UErrorCode* in/out
    );
}
@[Link("icuin")]
lib Libicuin
  fun udat_open = udat_open(
    timeStyle : Int32,   # UDateFormatStyle
    dateStyle : Int32,   # UDateFormatStyle
    locale : UInt8*,   # LPCSTR
    tzID : UInt16*,   # WORD*
    tzIDLength : Int32,   # INT
    pattern : UInt16*,   # WORD*
    patternLength : Int32,   # INT
    status : Int32*   # UErrorCode* in/out
  ) : Void**
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef udat_openNative = Pointer<Void> Function(Int32, Int32, Pointer<Utf8>, Pointer<Uint16>, Int32, Pointer<Uint16>, Int32, Pointer<Int32>);
typedef udat_openDart = Pointer<Void> Function(int, int, Pointer<Utf8>, Pointer<Uint16>, int, Pointer<Uint16>, int, Pointer<Int32>);
final udat_open = DynamicLibrary.open('icuin.dll')
    .lookupFunction<udat_openNative, udat_openDart>('udat_open');
// timeStyle : UDateFormatStyle -> Int32
// dateStyle : UDateFormatStyle -> Int32
// locale : LPCSTR -> Pointer<Utf8>
// tzID : WORD* -> Pointer<Uint16>
// tzIDLength : INT -> Int32
// pattern : WORD* -> Pointer<Uint16>
// patternLength : INT -> Int32
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function udat_open(
  timeStyle: Integer;   // UDateFormatStyle
  dateStyle: Integer;   // UDateFormatStyle
  locale: PAnsiChar;   // LPCSTR
  tzID: Pointer;   // WORD*
  tzIDLength: Integer;   // INT
  pattern: Pointer;   // WORD*
  patternLength: Integer;   // INT
  status: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icuin.dll' name 'udat_open';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "udat_open"
  c_udat_open :: Int32 -> Int32 -> CString -> Ptr Word16 -> Int32 -> Ptr Word16 -> Int32 -> Ptr Int32 -> IO (Ptr ())
-- timeStyle : UDateFormatStyle -> Int32
-- dateStyle : UDateFormatStyle -> Int32
-- locale : LPCSTR -> CString
-- tzID : WORD* -> Ptr Word16
-- tzIDLength : INT -> Int32
-- pattern : WORD* -> Ptr Word16
-- patternLength : INT -> Int32
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let udat_open =
  foreign "udat_open"
    (int32_t @-> int32_t @-> string @-> (ptr uint16_t) @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> (ptr int32_t) @-> returning (ptr void))
(* timeStyle : UDateFormatStyle -> int32_t *)
(* dateStyle : UDateFormatStyle -> int32_t *)
(* locale : LPCSTR -> string *)
(* tzID : WORD* -> (ptr uint16_t) *)
(* tzIDLength : INT -> int32_t *)
(* pattern : WORD* -> (ptr uint16_t) *)
(* patternLength : INT -> 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 ("udat_open" udat-open :convention :cdecl) :pointer
  (time-style :int32)   ; UDateFormatStyle
  (date-style :int32)   ; UDateFormatStyle
  (locale :string)   ; LPCSTR
  (tz-id :pointer)   ; WORD*
  (tz-idlength :int32)   ; INT
  (pattern :pointer)   ; WORD*
  (pattern-length :int32)   ; INT
  (status :pointer))   ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $udat_open = Win32::API::More->new('icuin',
    'LPVOID udat_open(int timeStyle, int dateStyle, LPCSTR locale, LPVOID tzID, int tzIDLength, LPVOID pattern, int patternLength, LPVOID status)');
# my $ret = $udat_open->Call($timeStyle, $dateStyle, $locale, $tzID, $tzIDLength, $pattern, $patternLength, $status);
# timeStyle : UDateFormatStyle -> int
# dateStyle : UDateFormatStyle -> int
# locale : LPCSTR -> LPCSTR
# tzID : WORD* -> LPVOID
# tzIDLength : INT -> int
# pattern : WORD* -> LPVOID
# patternLength : INT -> int
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型