ホーム › Globalization › ucptrie_openFromBinary
ucptrie_openFromBinary
関数バイナリデータからコードポイントトライを開く。
シグネチャ
// icu.dll
#include <windows.h>
UCPTrie* ucptrie_openFromBinary(
UCPTrieType type,
UCPTrieValueWidth valueWidth,
const void* data,
INT length,
INT* pActualLength,
UErrorCode* pErrorCode
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| type | UCPTrieType | in | 想定するトライ種別(FAST/SMALL)。UCPTRIE_TYPE_ANYで自動判定する。 |
| valueWidth | UCPTrieValueWidth | in | 想定する値の幅(16/32/8ビット)。UCPTRIE_VALUE_BITS_ANYで自動判定する。 |
| data | void* | in | ucptrie_toBinaryで生成された連続バイナリ領域へのポインタ。 |
| length | INT | in | dataの利用可能バイト数。実サイズ以上を指定する。 |
| pActualLength | INT* | inout | 実際に消費したバイト数を受け取る出力ポインタ。NULL可。 |
| pErrorCode | UErrorCode* | inout | ICOのエラーコードを入出力するポインタ。呼び出し前にU_ZERO_ERRORで初期化する。 |
戻り値の型: UCPTrie*
各言語での呼び出し定義
// icu.dll
#include <windows.h>
UCPTrie* ucptrie_openFromBinary(
UCPTrieType type,
UCPTrieValueWidth valueWidth,
const void* data,
INT length,
INT* pActualLength,
UErrorCode* pErrorCode
);[DllImport("icu.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ucptrie_openFromBinary(
int type, // UCPTrieType
int valueWidth, // UCPTrieValueWidth
IntPtr data, // void*
int length, // INT
ref int pActualLength, // INT* in/out
ref int pErrorCode // UErrorCode* in/out
);<DllImport("icu.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucptrie_openFromBinary(
type As Integer, ' UCPTrieType
valueWidth As Integer, ' UCPTrieValueWidth
data As IntPtr, ' void*
length As Integer, ' INT
ByRef pActualLength As Integer, ' INT* in/out
ByRef pErrorCode As Integer ' UErrorCode* in/out
) As IntPtr
End Function' type : UCPTrieType
' valueWidth : UCPTrieValueWidth
' data : void*
' length : INT
' pActualLength : INT* in/out
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function ucptrie_openFromBinary Lib "icu" ( _
ByVal type As Long, _
ByVal valueWidth As Long, _
ByVal data As LongPtr, _
ByVal length As Long, _
ByRef pActualLength As Long, _
ByRef pErrorCode As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ucptrie_openFromBinary = ctypes.cdll.icu.ucptrie_openFromBinary
ucptrie_openFromBinary.restype = ctypes.c_void_p
ucptrie_openFromBinary.argtypes = [
ctypes.c_int, # type : UCPTrieType
ctypes.c_int, # valueWidth : UCPTrieValueWidth
ctypes.POINTER(None), # data : void*
ctypes.c_int, # length : INT
ctypes.POINTER(ctypes.c_int), # pActualLength : INT* in/out
ctypes.c_void_p, # pErrorCode : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icu.dll')
ucptrie_openFromBinary = Fiddle::Function.new(
lib['ucptrie_openFromBinary'],
[
Fiddle::TYPE_INT, # type : UCPTrieType
Fiddle::TYPE_INT, # valueWidth : UCPTrieValueWidth
Fiddle::TYPE_VOIDP, # data : void*
Fiddle::TYPE_INT, # length : INT
Fiddle::TYPE_VOIDP, # pActualLength : INT* in/out
Fiddle::TYPE_VOIDP, # pErrorCode : UErrorCode* in/out
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icu")]
extern "C" {
fn ucptrie_openFromBinary(
type: i32, // UCPTrieType
valueWidth: i32, // UCPTrieValueWidth
data: *const (), // void*
length: i32, // INT
pActualLength: *mut i32, // INT* in/out
pErrorCode: *mut i32 // UErrorCode* in/out
) -> *mut UCPTrie;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icu.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ucptrie_openFromBinary(int type, int valueWidth, IntPtr data, int length, ref int pActualLength, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icu_ucptrie_openFromBinary' -Namespace Win32 -PassThru
# $api::ucptrie_openFromBinary(type, valueWidth, data, length, pActualLength, pErrorCode)#uselib "icu.dll"
#func global ucptrie_openFromBinary "ucptrie_openFromBinary" sptr, sptr, sptr, sptr, sptr, sptr
; ucptrie_openFromBinary type, valueWidth, data, length, varptr(pActualLength), varptr(pErrorCode) ; 戻り値は stat
; type : UCPTrieType -> "sptr"
; valueWidth : UCPTrieValueWidth -> "sptr"
; data : void* -> "sptr"
; length : INT -> "sptr"
; pActualLength : INT* in/out -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icu.dll" #cfunc global ucptrie_openFromBinary "ucptrie_openFromBinary" int, int, sptr, int, var, var ; res = ucptrie_openFromBinary(type, valueWidth, data, length, pActualLength, pErrorCode) ; type : UCPTrieType -> "int" ; valueWidth : UCPTrieValueWidth -> "int" ; data : void* -> "sptr" ; length : INT -> "int" ; pActualLength : INT* in/out -> "var" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icu.dll" #cfunc global ucptrie_openFromBinary "ucptrie_openFromBinary" int, int, sptr, int, sptr, sptr ; res = ucptrie_openFromBinary(type, valueWidth, data, length, varptr(pActualLength), varptr(pErrorCode)) ; type : UCPTrieType -> "int" ; valueWidth : UCPTrieValueWidth -> "int" ; data : void* -> "sptr" ; length : INT -> "int" ; pActualLength : INT* in/out -> "sptr" ; pErrorCode : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; UCPTrie* ucptrie_openFromBinary(UCPTrieType type, UCPTrieValueWidth valueWidth, void* data, INT length, INT* pActualLength, UErrorCode* pErrorCode) #uselib "icu.dll" #cfunc global ucptrie_openFromBinary "ucptrie_openFromBinary" int, int, intptr, int, var, var ; res = ucptrie_openFromBinary(type, valueWidth, data, length, pActualLength, pErrorCode) ; type : UCPTrieType -> "int" ; valueWidth : UCPTrieValueWidth -> "int" ; data : void* -> "intptr" ; length : INT -> "int" ; pActualLength : INT* in/out -> "var" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; UCPTrie* ucptrie_openFromBinary(UCPTrieType type, UCPTrieValueWidth valueWidth, void* data, INT length, INT* pActualLength, UErrorCode* pErrorCode) #uselib "icu.dll" #cfunc global ucptrie_openFromBinary "ucptrie_openFromBinary" int, int, intptr, int, intptr, intptr ; res = ucptrie_openFromBinary(type, valueWidth, data, length, varptr(pActualLength), varptr(pErrorCode)) ; type : UCPTrieType -> "int" ; valueWidth : UCPTrieValueWidth -> "int" ; data : void* -> "intptr" ; length : INT -> "int" ; pActualLength : INT* in/out -> "intptr" ; pErrorCode : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icu = windows.NewLazySystemDLL("icu.dll")
procucptrie_openFromBinary = icu.NewProc("ucptrie_openFromBinary")
)
// type (UCPTrieType), valueWidth (UCPTrieValueWidth), data (void*), length (INT), pActualLength (INT* in/out), pErrorCode (UErrorCode* in/out)
r1, _, err := procucptrie_openFromBinary.Call(
uintptr(type),
uintptr(valueWidth),
uintptr(data),
uintptr(length),
uintptr(pActualLength),
uintptr(pErrorCode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // UCPTrie*function ucptrie_openFromBinary(
type: Integer; // UCPTrieType
valueWidth: Integer; // UCPTrieValueWidth
data: Pointer; // void*
length: Integer; // INT
pActualLength: Pointer; // INT* in/out
pErrorCode: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icu.dll' name 'ucptrie_openFromBinary';result := DllCall("icu\ucptrie_openFromBinary"
, "Int", type ; UCPTrieType
, "Int", valueWidth ; UCPTrieValueWidth
, "Ptr", data ; void*
, "Int", length ; INT
, "Ptr", pActualLength ; INT* in/out
, "Ptr", pErrorCode ; UErrorCode* in/out
, "Cdecl Ptr") ; return: UCPTrie*●ucptrie_openFromBinary(type, valueWidth, data, length, pActualLength, pErrorCode) = DLL("icu.dll", "void* ucptrie_openFromBinary(int, int, void*, int, void*, void*)")
# 呼び出し: ucptrie_openFromBinary(type, valueWidth, data, length, pActualLength, pErrorCode)
# type : UCPTrieType -> "int"
# valueWidth : UCPTrieValueWidth -> "int"
# data : void* -> "void*"
# length : INT -> "int"
# pActualLength : INT* in/out -> "void*"
# 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 "icu" fn ucptrie_openFromBinary(
type: i32, // UCPTrieType
valueWidth: i32, // UCPTrieValueWidth
data: ?*anyopaque, // void*
length: i32, // INT
pActualLength: [*c]i32, // INT* in/out
pErrorCode: [*c]i32 // UErrorCode* in/out
) callconv(.c) [*c]UCPTrie;proc ucptrie_openFromBinary(
`type`: int32, # UCPTrieType
valueWidth: int32, # UCPTrieValueWidth
data: pointer, # void*
length: int32, # INT
pActualLength: ptr int32, # INT* in/out
pErrorCode: ptr int32 # UErrorCode* in/out
): ptr UCPTrie {.importc: "ucptrie_openFromBinary", cdecl, dynlib: "icu.dll".}pragma(lib, "icu");
extern(C)
UCPTrie* ucptrie_openFromBinary(
int type, // UCPTrieType
int valueWidth, // UCPTrieValueWidth
void* data, // void*
int length, // INT
int* pActualLength, // INT* in/out
int* pErrorCode // UErrorCode* in/out
);ccall((:ucptrie_openFromBinary, "icu.dll"), Ptr{UCPTrie},
(Int32, Int32, Ptr{Cvoid}, Int32, Ptr{Int32}, Ptr{Int32}),
type, valueWidth, data, length, pActualLength, pErrorCode)
# type : UCPTrieType -> Int32
# valueWidth : UCPTrieValueWidth -> Int32
# data : void* -> Ptr{Cvoid}
# length : INT -> Int32
# pActualLength : INT* in/out -> Ptr{Int32}
# pErrorCode : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
void* ucptrie_openFromBinary(
int32_t type,
int32_t valueWidth,
void* data,
int32_t length,
int32_t* pActualLength,
int32_t* pErrorCode);
]]
local icu = ffi.load("icu")
-- icu.ucptrie_openFromBinary(type, valueWidth, data, length, pActualLength, pErrorCode)
-- type : UCPTrieType
-- valueWidth : UCPTrieValueWidth
-- data : void*
-- length : INT
-- pActualLength : INT* in/out
-- pErrorCode : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icu.dll');
const ucptrie_openFromBinary = lib.func('__cdecl', 'ucptrie_openFromBinary', 'void *', ['int32_t', 'int32_t', 'void *', 'int32_t', 'int32_t *', 'int32_t *']);
// ucptrie_openFromBinary(type, valueWidth, data, length, pActualLength, pErrorCode)
// type : UCPTrieType -> 'int32_t'
// valueWidth : UCPTrieValueWidth -> 'int32_t'
// data : void* -> 'void *'
// length : INT -> 'int32_t'
// pActualLength : INT* in/out -> 'int32_t *'
// pErrorCode : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icu.dll", {
ucptrie_openFromBinary: { parameters: ["i32", "i32", "pointer", "i32", "pointer", "pointer"], result: "pointer" },
});
// lib.symbols.ucptrie_openFromBinary(type, valueWidth, data, length, pActualLength, pErrorCode)
// type : UCPTrieType -> "i32"
// valueWidth : UCPTrieValueWidth -> "i32"
// data : void* -> "pointer"
// length : INT -> "i32"
// pActualLength : INT* in/out -> "pointer"
// pErrorCode : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* ucptrie_openFromBinary(
int32_t type,
int32_t valueWidth,
void* data,
int32_t length,
int32_t* pActualLength,
int32_t* pErrorCode);
C, "icu.dll");
// $ffi->ucptrie_openFromBinary(type, valueWidth, data, length, pActualLength, pErrorCode);
// type : UCPTrieType
// valueWidth : UCPTrieValueWidth
// data : void*
// length : INT
// pActualLength : INT* in/out
// 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 Icu extends Library {
Icu INSTANCE = Native.load("icu", Icu.class);
Pointer ucptrie_openFromBinary(
int type, // UCPTrieType
int valueWidth, // UCPTrieValueWidth
Pointer data, // void*
int length, // INT
IntByReference pActualLength, // INT* in/out
IntByReference pErrorCode // UErrorCode* in/out
);
}@[Link("icu")]
lib Libicu
fun ucptrie_openFromBinary = ucptrie_openFromBinary(
type_ : Int32, # UCPTrieType
valueWidth : Int32, # UCPTrieValueWidth
data : Void*, # void*
length : Int32, # INT
pActualLength : Int32*, # INT* in/out
pErrorCode : Int32* # UErrorCode* in/out
) : UCPTrie*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ucptrie_openFromBinaryNative = Pointer<Void> Function(Int32, Int32, Pointer<Void>, Int32, Pointer<Int32>, Pointer<Int32>);
typedef ucptrie_openFromBinaryDart = Pointer<Void> Function(int, int, Pointer<Void>, int, Pointer<Int32>, Pointer<Int32>);
final ucptrie_openFromBinary = DynamicLibrary.open('icu.dll')
.lookupFunction<ucptrie_openFromBinaryNative, ucptrie_openFromBinaryDart>('ucptrie_openFromBinary');
// type : UCPTrieType -> Int32
// valueWidth : UCPTrieValueWidth -> Int32
// data : void* -> Pointer<Void>
// length : INT -> Int32
// pActualLength : INT* in/out -> Pointer<Int32>
// pErrorCode : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ucptrie_openFromBinary(
type: Integer; // UCPTrieType
valueWidth: Integer; // UCPTrieValueWidth
data: Pointer; // void*
length: Integer; // INT
pActualLength: Pointer; // INT* in/out
pErrorCode: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icu.dll' name 'ucptrie_openFromBinary';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ucptrie_openFromBinary"
c_ucptrie_openFromBinary :: Int32 -> Int32 -> Ptr () -> Int32 -> Ptr Int32 -> Ptr Int32 -> IO (Ptr ())
-- type : UCPTrieType -> Int32
-- valueWidth : UCPTrieValueWidth -> Int32
-- data : void* -> Ptr ()
-- length : INT -> Int32
-- pActualLength : INT* in/out -> Ptr Int32
-- pErrorCode : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ucptrie_openfrombinary =
foreign "ucptrie_openFromBinary"
(int32_t @-> int32_t @-> (ptr void) @-> int32_t @-> (ptr int32_t) @-> (ptr int32_t) @-> returning (ptr void))
(* type : UCPTrieType -> int32_t *)
(* valueWidth : UCPTrieValueWidth -> int32_t *)
(* data : void* -> (ptr void) *)
(* length : INT -> int32_t *)
(* pActualLength : INT* in/out -> (ptr int32_t) *)
(* pErrorCode : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icu (t "icu.dll"))
(cffi:use-foreign-library icu)
(cffi:defcfun ("ucptrie_openFromBinary" ucptrie-open-from-binary :convention :cdecl) :pointer
(type :int32) ; UCPTrieType
(value-width :int32) ; UCPTrieValueWidth
(data :pointer) ; void*
(length :int32) ; INT
(p-actual-length :pointer) ; INT* in/out
(p-error-code :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ucptrie_openFromBinary = Win32::API::More->new('icu',
'LPVOID ucptrie_openFromBinary(int type, int valueWidth, LPVOID data, int length, LPVOID pActualLength, LPVOID pErrorCode)');
# my $ret = $ucptrie_openFromBinary->Call($type, $valueWidth, $data, $length, $pActualLength, $pErrorCode);
# type : UCPTrieType -> int
# valueWidth : UCPTrieValueWidth -> int
# data : void* -> LPVOID
# length : INT -> int
# pActualLength : INT* in/out -> LPVOID
# pErrorCode : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。