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