ホーム › Globalization › udatpg_getBestPatternWithOptions
udatpg_getBestPatternWithOptions
関数オプション付きでスケルトンから最適な日時パターンを生成する。
シグネチャ
// icuin.dll
#include <windows.h>
INT udatpg_getBestPatternWithOptions(
void** dtpg,
const WORD* skeleton,
INT length,
UDateTimePatternMatchOptions options,
WORD* bestPattern,
INT capacity,
UErrorCode* pErrorCode
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dtpg | void** | inout | 対象のUDateTimePatternGeneratorハンドル。 |
| skeleton | WORD* | in | 希望するフィールド構成を表すスケルトン文字列。UTF-16配列。 |
| length | INT | in | スケルトンの長さ(UTF-16単位)。-1でNUL終端として扱う。 |
| options | UDateTimePatternMatchOptions | in | フィールド幅一致方針などを指定するオプションフラグの列挙値。 |
| bestPattern | WORD* | inout | 生成された最適パターンを受け取る出力バッファ。UTF-16配列。 |
| capacity | INT | in | 出力バッファの容量(UTF-16単位)。0で必要長の照会も可能。 |
| pErrorCode | UErrorCode* | inout | ICUのエラーコード。呼び出し前に成功値で初期化する。 |
戻り値の型: INT
各言語での呼び出し定義
// icuin.dll
#include <windows.h>
INT udatpg_getBestPatternWithOptions(
void** dtpg,
const WORD* skeleton,
INT length,
UDateTimePatternMatchOptions options,
WORD* bestPattern,
INT capacity,
UErrorCode* pErrorCode
);[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int udatpg_getBestPatternWithOptions(
IntPtr dtpg, // void** in/out
ref ushort skeleton, // WORD*
int length, // INT
int options, // UDateTimePatternMatchOptions
ref ushort bestPattern, // WORD* in/out
int capacity, // INT
ref int pErrorCode // UErrorCode* in/out
);<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function udatpg_getBestPatternWithOptions(
dtpg As IntPtr, ' void** in/out
ByRef skeleton As UShort, ' WORD*
length As Integer, ' INT
options As Integer, ' UDateTimePatternMatchOptions
ByRef bestPattern As UShort, ' WORD* in/out
capacity As Integer, ' INT
ByRef pErrorCode As Integer ' UErrorCode* in/out
) As Integer
End Function' dtpg : void** in/out
' skeleton : WORD*
' length : INT
' options : UDateTimePatternMatchOptions
' bestPattern : WORD* in/out
' capacity : INT
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function udatpg_getBestPatternWithOptions Lib "icuin" ( _
ByVal dtpg As LongPtr, _
ByRef skeleton As Integer, _
ByVal length As Long, _
ByVal options As Long, _
ByRef bestPattern As Integer, _
ByVal capacity As Long, _
ByRef pErrorCode As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
udatpg_getBestPatternWithOptions = ctypes.cdll.icuin.udatpg_getBestPatternWithOptions
udatpg_getBestPatternWithOptions.restype = ctypes.c_int
udatpg_getBestPatternWithOptions.argtypes = [
ctypes.c_void_p, # dtpg : void** in/out
ctypes.POINTER(ctypes.c_ushort), # skeleton : WORD*
ctypes.c_int, # length : INT
ctypes.c_int, # options : UDateTimePatternMatchOptions
ctypes.POINTER(ctypes.c_ushort), # bestPattern : WORD* in/out
ctypes.c_int, # capacity : INT
ctypes.c_void_p, # pErrorCode : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuin.dll')
udatpg_getBestPatternWithOptions = Fiddle::Function.new(
lib['udatpg_getBestPatternWithOptions'],
[
Fiddle::TYPE_VOIDP, # dtpg : void** in/out
Fiddle::TYPE_VOIDP, # skeleton : WORD*
Fiddle::TYPE_INT, # length : INT
Fiddle::TYPE_INT, # options : UDateTimePatternMatchOptions
Fiddle::TYPE_VOIDP, # bestPattern : WORD* in/out
Fiddle::TYPE_INT, # capacity : INT
Fiddle::TYPE_VOIDP, # pErrorCode : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuin")]
extern "C" {
fn udatpg_getBestPatternWithOptions(
dtpg: *mut *mut (), // void** in/out
skeleton: *const u16, // WORD*
length: i32, // INT
options: i32, // UDateTimePatternMatchOptions
bestPattern: *mut u16, // WORD* in/out
capacity: i32, // INT
pErrorCode: *mut i32 // UErrorCode* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuin.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int udatpg_getBestPatternWithOptions(IntPtr dtpg, ref ushort skeleton, int length, int options, ref ushort bestPattern, int capacity, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_udatpg_getBestPatternWithOptions' -Namespace Win32 -PassThru
# $api::udatpg_getBestPatternWithOptions(dtpg, skeleton, length, options, bestPattern, capacity, pErrorCode)#uselib "icuin.dll"
#func global udatpg_getBestPatternWithOptions "udatpg_getBestPatternWithOptions" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; udatpg_getBestPatternWithOptions dtpg, varptr(skeleton), length, options, varptr(bestPattern), capacity, varptr(pErrorCode) ; 戻り値は stat
; dtpg : void** in/out -> "sptr"
; skeleton : WORD* -> "sptr"
; length : INT -> "sptr"
; options : UDateTimePatternMatchOptions -> "sptr"
; bestPattern : WORD* in/out -> "sptr"
; capacity : INT -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuin.dll" #cfunc global udatpg_getBestPatternWithOptions "udatpg_getBestPatternWithOptions" sptr, var, int, int, var, int, var ; res = udatpg_getBestPatternWithOptions(dtpg, skeleton, length, options, bestPattern, capacity, pErrorCode) ; dtpg : void** in/out -> "sptr" ; skeleton : WORD* -> "var" ; length : INT -> "int" ; options : UDateTimePatternMatchOptions -> "int" ; bestPattern : WORD* in/out -> "var" ; capacity : INT -> "int" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuin.dll" #cfunc global udatpg_getBestPatternWithOptions "udatpg_getBestPatternWithOptions" sptr, sptr, int, int, sptr, int, sptr ; res = udatpg_getBestPatternWithOptions(dtpg, varptr(skeleton), length, options, varptr(bestPattern), capacity, varptr(pErrorCode)) ; dtpg : void** in/out -> "sptr" ; skeleton : WORD* -> "sptr" ; length : INT -> "int" ; options : UDateTimePatternMatchOptions -> "int" ; bestPattern : WORD* in/out -> "sptr" ; capacity : INT -> "int" ; pErrorCode : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT udatpg_getBestPatternWithOptions(void** dtpg, WORD* skeleton, INT length, UDateTimePatternMatchOptions options, WORD* bestPattern, INT capacity, UErrorCode* pErrorCode) #uselib "icuin.dll" #cfunc global udatpg_getBestPatternWithOptions "udatpg_getBestPatternWithOptions" intptr, var, int, int, var, int, var ; res = udatpg_getBestPatternWithOptions(dtpg, skeleton, length, options, bestPattern, capacity, pErrorCode) ; dtpg : void** in/out -> "intptr" ; skeleton : WORD* -> "var" ; length : INT -> "int" ; options : UDateTimePatternMatchOptions -> "int" ; bestPattern : WORD* in/out -> "var" ; capacity : INT -> "int" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT udatpg_getBestPatternWithOptions(void** dtpg, WORD* skeleton, INT length, UDateTimePatternMatchOptions options, WORD* bestPattern, INT capacity, UErrorCode* pErrorCode) #uselib "icuin.dll" #cfunc global udatpg_getBestPatternWithOptions "udatpg_getBestPatternWithOptions" intptr, intptr, int, int, intptr, int, intptr ; res = udatpg_getBestPatternWithOptions(dtpg, varptr(skeleton), length, options, varptr(bestPattern), capacity, varptr(pErrorCode)) ; dtpg : void** in/out -> "intptr" ; skeleton : WORD* -> "intptr" ; length : INT -> "int" ; options : UDateTimePatternMatchOptions -> "int" ; bestPattern : WORD* in/out -> "intptr" ; capacity : INT -> "int" ; pErrorCode : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuin = windows.NewLazySystemDLL("icuin.dll")
procudatpg_getBestPatternWithOptions = icuin.NewProc("udatpg_getBestPatternWithOptions")
)
// dtpg (void** in/out), skeleton (WORD*), length (INT), options (UDateTimePatternMatchOptions), bestPattern (WORD* in/out), capacity (INT), pErrorCode (UErrorCode* in/out)
r1, _, err := procudatpg_getBestPatternWithOptions.Call(
uintptr(dtpg),
uintptr(skeleton),
uintptr(length),
uintptr(options),
uintptr(bestPattern),
uintptr(capacity),
uintptr(pErrorCode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction udatpg_getBestPatternWithOptions(
dtpg: Pointer; // void** in/out
skeleton: Pointer; // WORD*
length: Integer; // INT
options: Integer; // UDateTimePatternMatchOptions
bestPattern: Pointer; // WORD* in/out
capacity: Integer; // INT
pErrorCode: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuin.dll' name 'udatpg_getBestPatternWithOptions';result := DllCall("icuin\udatpg_getBestPatternWithOptions"
, "Ptr", dtpg ; void** in/out
, "Ptr", skeleton ; WORD*
, "Int", length ; INT
, "Int", options ; UDateTimePatternMatchOptions
, "Ptr", bestPattern ; WORD* in/out
, "Int", capacity ; INT
, "Ptr", pErrorCode ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●udatpg_getBestPatternWithOptions(dtpg, skeleton, length, options, bestPattern, capacity, pErrorCode) = DLL("icuin.dll", "int udatpg_getBestPatternWithOptions(void*, void*, int, int, void*, int, void*)")
# 呼び出し: udatpg_getBestPatternWithOptions(dtpg, skeleton, length, options, bestPattern, capacity, pErrorCode)
# dtpg : void** in/out -> "void*"
# skeleton : WORD* -> "void*"
# length : INT -> "int"
# options : UDateTimePatternMatchOptions -> "int"
# bestPattern : WORD* in/out -> "void*"
# capacity : INT -> "int"
# pErrorCode : 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 udatpg_getBestPatternWithOptions(
dtpg: ?*anyopaque, // void** in/out
skeleton: [*c]u16, // WORD*
length: i32, // INT
options: i32, // UDateTimePatternMatchOptions
bestPattern: [*c]u16, // WORD* in/out
capacity: i32, // INT
pErrorCode: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;proc udatpg_getBestPatternWithOptions(
dtpg: pointer, # void** in/out
skeleton: ptr uint16, # WORD*
length: int32, # INT
options: int32, # UDateTimePatternMatchOptions
bestPattern: ptr uint16, # WORD* in/out
capacity: int32, # INT
pErrorCode: ptr int32 # UErrorCode* in/out
): int32 {.importc: "udatpg_getBestPatternWithOptions", cdecl, dynlib: "icuin.dll".}pragma(lib, "icuin");
extern(C)
int udatpg_getBestPatternWithOptions(
void** dtpg, // void** in/out
ushort* skeleton, // WORD*
int length, // INT
int options, // UDateTimePatternMatchOptions
ushort* bestPattern, // WORD* in/out
int capacity, // INT
int* pErrorCode // UErrorCode* in/out
);ccall((:udatpg_getBestPatternWithOptions, "icuin.dll"), Int32,
(Ptr{Cvoid}, Ptr{UInt16}, Int32, Int32, Ptr{UInt16}, Int32, Ptr{Int32}),
dtpg, skeleton, length, options, bestPattern, capacity, pErrorCode)
# dtpg : void** in/out -> Ptr{Cvoid}
# skeleton : WORD* -> Ptr{UInt16}
# length : INT -> Int32
# options : UDateTimePatternMatchOptions -> Int32
# bestPattern : WORD* in/out -> Ptr{UInt16}
# capacity : INT -> Int32
# pErrorCode : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
int32_t udatpg_getBestPatternWithOptions(
void** dtpg,
uint16_t* skeleton,
int32_t length,
int32_t options,
uint16_t* bestPattern,
int32_t capacity,
int32_t* pErrorCode);
]]
local icuin = ffi.load("icuin")
-- icuin.udatpg_getBestPatternWithOptions(dtpg, skeleton, length, options, bestPattern, capacity, pErrorCode)
-- dtpg : void** in/out
-- skeleton : WORD*
-- length : INT
-- options : UDateTimePatternMatchOptions
-- bestPattern : WORD* in/out
-- capacity : INT
-- pErrorCode : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuin.dll');
const udatpg_getBestPatternWithOptions = lib.func('__cdecl', 'udatpg_getBestPatternWithOptions', 'int32_t', ['void *', 'uint16_t *', 'int32_t', 'int32_t', 'uint16_t *', 'int32_t', 'int32_t *']);
// udatpg_getBestPatternWithOptions(dtpg, skeleton, length, options, bestPattern, capacity, pErrorCode)
// dtpg : void** in/out -> 'void *'
// skeleton : WORD* -> 'uint16_t *'
// length : INT -> 'int32_t'
// options : UDateTimePatternMatchOptions -> 'int32_t'
// bestPattern : WORD* in/out -> 'uint16_t *'
// capacity : INT -> 'int32_t'
// pErrorCode : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuin.dll", {
udatpg_getBestPatternWithOptions: { parameters: ["pointer", "pointer", "i32", "i32", "pointer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.udatpg_getBestPatternWithOptions(dtpg, skeleton, length, options, bestPattern, capacity, pErrorCode)
// dtpg : void** in/out -> "pointer"
// skeleton : WORD* -> "pointer"
// length : INT -> "i32"
// options : UDateTimePatternMatchOptions -> "i32"
// bestPattern : WORD* in/out -> "pointer"
// capacity : INT -> "i32"
// pErrorCode : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t udatpg_getBestPatternWithOptions(
void** dtpg,
uint16_t* skeleton,
int32_t length,
int32_t options,
uint16_t* bestPattern,
int32_t capacity,
int32_t* pErrorCode);
C, "icuin.dll");
// $ffi->udatpg_getBestPatternWithOptions(dtpg, skeleton, length, options, bestPattern, capacity, pErrorCode);
// dtpg : void** in/out
// skeleton : WORD*
// length : INT
// options : UDateTimePatternMatchOptions
// bestPattern : WORD* in/out
// capacity : INT
// pErrorCode : 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);
int udatpg_getBestPatternWithOptions(
Pointer dtpg, // void** in/out
ShortByReference skeleton, // WORD*
int length, // INT
int options, // UDateTimePatternMatchOptions
ShortByReference bestPattern, // WORD* in/out
int capacity, // INT
IntByReference pErrorCode // UErrorCode* in/out
);
}@[Link("icuin")]
lib Libicuin
fun udatpg_getBestPatternWithOptions = udatpg_getBestPatternWithOptions(
dtpg : Void**, # void** in/out
skeleton : UInt16*, # WORD*
length : Int32, # INT
options : Int32, # UDateTimePatternMatchOptions
bestPattern : UInt16*, # WORD* in/out
capacity : Int32, # INT
pErrorCode : Int32* # UErrorCode* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef udatpg_getBestPatternWithOptionsNative = Int32 Function(Pointer<Void>, Pointer<Uint16>, Int32, Int32, Pointer<Uint16>, Int32, Pointer<Int32>);
typedef udatpg_getBestPatternWithOptionsDart = int Function(Pointer<Void>, Pointer<Uint16>, int, int, Pointer<Uint16>, int, Pointer<Int32>);
final udatpg_getBestPatternWithOptions = DynamicLibrary.open('icuin.dll')
.lookupFunction<udatpg_getBestPatternWithOptionsNative, udatpg_getBestPatternWithOptionsDart>('udatpg_getBestPatternWithOptions');
// dtpg : void** in/out -> Pointer<Void>
// skeleton : WORD* -> Pointer<Uint16>
// length : INT -> Int32
// options : UDateTimePatternMatchOptions -> Int32
// bestPattern : WORD* in/out -> Pointer<Uint16>
// capacity : INT -> Int32
// pErrorCode : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function udatpg_getBestPatternWithOptions(
dtpg: Pointer; // void** in/out
skeleton: Pointer; // WORD*
length: Integer; // INT
options: Integer; // UDateTimePatternMatchOptions
bestPattern: Pointer; // WORD* in/out
capacity: Integer; // INT
pErrorCode: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuin.dll' name 'udatpg_getBestPatternWithOptions';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "udatpg_getBestPatternWithOptions"
c_udatpg_getBestPatternWithOptions :: Ptr () -> Ptr Word16 -> Int32 -> Int32 -> Ptr Word16 -> Int32 -> Ptr Int32 -> IO Int32
-- dtpg : void** in/out -> Ptr ()
-- skeleton : WORD* -> Ptr Word16
-- length : INT -> Int32
-- options : UDateTimePatternMatchOptions -> Int32
-- bestPattern : WORD* in/out -> Ptr Word16
-- capacity : INT -> Int32
-- pErrorCode : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let udatpg_getbestpatternwithoptions =
foreign "udatpg_getBestPatternWithOptions"
((ptr void) @-> (ptr uint16_t) @-> int32_t @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> (ptr int32_t) @-> returning int32_t)
(* dtpg : void** in/out -> (ptr void) *)
(* skeleton : WORD* -> (ptr uint16_t) *)
(* length : INT -> int32_t *)
(* options : UDateTimePatternMatchOptions -> int32_t *)
(* bestPattern : WORD* in/out -> (ptr uint16_t) *)
(* capacity : INT -> int32_t *)
(* pErrorCode : 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 ("udatpg_getBestPatternWithOptions" udatpg-get-best-pattern-with-options :convention :cdecl) :int32
(dtpg :pointer) ; void** in/out
(skeleton :pointer) ; WORD*
(length :int32) ; INT
(options :int32) ; UDateTimePatternMatchOptions
(best-pattern :pointer) ; WORD* in/out
(capacity :int32) ; INT
(p-error-code :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $udatpg_getBestPatternWithOptions = Win32::API::More->new('icuin',
'int udatpg_getBestPatternWithOptions(LPVOID dtpg, LPVOID skeleton, int length, int options, LPVOID bestPattern, int capacity, LPVOID pErrorCode)');
# my $ret = $udatpg_getBestPatternWithOptions->Call($dtpg, $skeleton, $length, $options, $bestPattern, $capacity, $pErrorCode);
# dtpg : void** in/out -> LPVOID
# skeleton : WORD* -> LPVOID
# length : INT -> int
# options : UDateTimePatternMatchOptions -> int
# bestPattern : WORD* in/out -> LPVOID
# capacity : INT -> int
# pErrorCode : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。