ホーム › Globalization › ucol_openBinary
ucol_openBinary
関数バイナリデータから照合器を生成して開く。
シグネチャ
// icuin.dll
#include <windows.h>
UCollator* ucol_openBinary(
const BYTE* bin,
INT length,
const UCollator* base,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| bin | BYTE* | in | コレーターを復元する元のバイナリデータ。 |
| length | INT | in | binの長さ(バイト数)。-1で自動判定する。 |
| base | UCollator* | in | 復元の基底とするコレーター。通常はUCAコレーターを指定する。 |
| status | UErrorCode* | inout | エラーコードへのポインタ。生成の成否が反映される。 |
戻り値の型: UCollator*
各言語での呼び出し定義
// icuin.dll
#include <windows.h>
UCollator* ucol_openBinary(
const BYTE* bin,
INT length,
const UCollator* base,
UErrorCode* status
);[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ucol_openBinary(
IntPtr bin, // BYTE*
int length, // INT
ref IntPtr base, // UCollator*
ref int status // UErrorCode* in/out
);<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucol_openBinary(
bin As IntPtr, ' BYTE*
length As Integer, ' INT
ByRef base As IntPtr, ' UCollator*
ByRef status As Integer ' UErrorCode* in/out
) As IntPtr
End Function' bin : BYTE*
' length : INT
' base : UCollator*
' status : UErrorCode* in/out
Declare PtrSafe Function ucol_openBinary Lib "icuin" ( _
ByVal bin As LongPtr, _
ByVal length As Long, _
ByRef base As LongPtr, _
ByRef status As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ucol_openBinary = ctypes.cdll.icuin.ucol_openBinary
ucol_openBinary.restype = ctypes.c_void_p
ucol_openBinary.argtypes = [
ctypes.POINTER(ctypes.c_ubyte), # bin : BYTE*
ctypes.c_int, # length : INT
ctypes.c_void_p, # base : UCollator*
ctypes.c_void_p, # status : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuin.dll')
ucol_openBinary = Fiddle::Function.new(
lib['ucol_openBinary'],
[
Fiddle::TYPE_VOIDP, # bin : BYTE*
Fiddle::TYPE_INT, # length : INT
Fiddle::TYPE_VOIDP, # base : UCollator*
Fiddle::TYPE_VOIDP, # status : UErrorCode* in/out
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icuin")]
extern "C" {
fn ucol_openBinary(
bin: *const u8, // BYTE*
length: i32, // INT
base: *const isize, // UCollator*
status: *mut i32 // UErrorCode* in/out
) -> *mut isize;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuin.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ucol_openBinary(IntPtr bin, int length, ref IntPtr base, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_ucol_openBinary' -Namespace Win32 -PassThru
# $api::ucol_openBinary(bin, length, base, status)#uselib "icuin.dll"
#func global ucol_openBinary "ucol_openBinary" sptr, sptr, sptr, sptr
; ucol_openBinary varptr(bin), length, varptr(base), varptr(status) ; 戻り値は stat
; bin : BYTE* -> "sptr"
; length : INT -> "sptr"
; base : UCollator* -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuin.dll" #cfunc global ucol_openBinary "ucol_openBinary" var, int, var, var ; res = ucol_openBinary(bin, length, base, status) ; bin : BYTE* -> "var" ; length : INT -> "int" ; base : UCollator* -> "var" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuin.dll" #cfunc global ucol_openBinary "ucol_openBinary" sptr, int, sptr, sptr ; res = ucol_openBinary(varptr(bin), length, varptr(base), varptr(status)) ; bin : BYTE* -> "sptr" ; length : INT -> "int" ; base : UCollator* -> "sptr" ; status : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; UCollator* ucol_openBinary(BYTE* bin, INT length, UCollator* base, UErrorCode* status) #uselib "icuin.dll" #cfunc global ucol_openBinary "ucol_openBinary" var, int, var, var ; res = ucol_openBinary(bin, length, base, status) ; bin : BYTE* -> "var" ; length : INT -> "int" ; base : UCollator* -> "var" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; UCollator* ucol_openBinary(BYTE* bin, INT length, UCollator* base, UErrorCode* status) #uselib "icuin.dll" #cfunc global ucol_openBinary "ucol_openBinary" intptr, int, intptr, intptr ; res = ucol_openBinary(varptr(bin), length, varptr(base), varptr(status)) ; bin : BYTE* -> "intptr" ; length : INT -> "int" ; base : UCollator* -> "intptr" ; status : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuin = windows.NewLazySystemDLL("icuin.dll")
procucol_openBinary = icuin.NewProc("ucol_openBinary")
)
// bin (BYTE*), length (INT), base (UCollator*), status (UErrorCode* in/out)
r1, _, err := procucol_openBinary.Call(
uintptr(bin),
uintptr(length),
uintptr(base),
uintptr(status),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // UCollator*function ucol_openBinary(
bin: Pointer; // BYTE*
length: Integer; // INT
base: Pointer; // UCollator*
status: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icuin.dll' name 'ucol_openBinary';result := DllCall("icuin\ucol_openBinary"
, "Ptr", bin ; BYTE*
, "Int", length ; INT
, "Ptr", base ; UCollator*
, "Ptr", status ; UErrorCode* in/out
, "Cdecl Ptr") ; return: UCollator*●ucol_openBinary(bin, length, base, status) = DLL("icuin.dll", "void* ucol_openBinary(void*, int, void*, void*)")
# 呼び出し: ucol_openBinary(bin, length, base, status)
# bin : BYTE* -> "void*"
# length : INT -> "int"
# base : UCollator* -> "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 ucol_openBinary(
bin: [*c]u8, // BYTE*
length: i32, // INT
base: [*c]isize, // UCollator*
status: [*c]i32 // UErrorCode* in/out
) callconv(.c) [*c]isize;proc ucol_openBinary(
bin: ptr uint8, # BYTE*
length: int32, # INT
base: ptr int, # UCollator*
status: ptr int32 # UErrorCode* in/out
): ptr int {.importc: "ucol_openBinary", cdecl, dynlib: "icuin.dll".}pragma(lib, "icuin");
extern(C)
ptrdiff_t* ucol_openBinary(
ubyte* bin, // BYTE*
int length, // INT
ptrdiff_t* base, // UCollator*
int* status // UErrorCode* in/out
);ccall((:ucol_openBinary, "icuin.dll"), Ptr{Int},
(Ptr{UInt8}, Int32, Ptr{Int}, Ptr{Int32}),
bin, length, base, status)
# bin : BYTE* -> Ptr{UInt8}
# length : INT -> Int32
# base : UCollator* -> Ptr{Int}
# status : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
intptr_t* ucol_openBinary(
uint8_t* bin,
int32_t length,
intptr_t* base,
int32_t* status);
]]
local icuin = ffi.load("icuin")
-- icuin.ucol_openBinary(bin, length, base, status)
-- bin : BYTE*
-- length : INT
-- base : UCollator*
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuin.dll');
const ucol_openBinary = lib.func('__cdecl', 'ucol_openBinary', 'intptr_t *', ['uint8_t *', 'int32_t', 'intptr_t *', 'int32_t *']);
// ucol_openBinary(bin, length, base, status)
// bin : BYTE* -> 'uint8_t *'
// length : INT -> 'int32_t'
// base : UCollator* -> 'intptr_t *'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuin.dll", {
ucol_openBinary: { parameters: ["pointer", "i32", "pointer", "pointer"], result: "pointer" },
});
// lib.symbols.ucol_openBinary(bin, length, base, status)
// bin : BYTE* -> "pointer"
// length : INT -> "i32"
// base : UCollator* -> "pointer"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
intptr_t* ucol_openBinary(
uint8_t* bin,
int32_t length,
intptr_t* base,
int32_t* status);
C, "icuin.dll");
// $ffi->ucol_openBinary(bin, length, base, status);
// bin : BYTE*
// length : INT
// base : UCollator*
// 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 ucol_openBinary(
byte[] bin, // BYTE*
int length, // INT
LongByReference base, // UCollator*
IntByReference status // UErrorCode* in/out
);
}@[Link("icuin")]
lib Libicuin
fun ucol_openBinary = ucol_openBinary(
bin : UInt8*, # BYTE*
length : Int32, # INT
base : LibC::SSizeT*, # UCollator*
status : Int32* # UErrorCode* in/out
) : LibC::SSizeT*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ucol_openBinaryNative = Pointer<IntPtr> Function(Pointer<Uint8>, Int32, Pointer<IntPtr>, Pointer<Int32>);
typedef ucol_openBinaryDart = Pointer<IntPtr> Function(Pointer<Uint8>, int, Pointer<IntPtr>, Pointer<Int32>);
final ucol_openBinary = DynamicLibrary.open('icuin.dll')
.lookupFunction<ucol_openBinaryNative, ucol_openBinaryDart>('ucol_openBinary');
// bin : BYTE* -> Pointer<Uint8>
// length : INT -> Int32
// base : UCollator* -> Pointer<IntPtr>
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ucol_openBinary(
bin: Pointer; // BYTE*
length: Integer; // INT
base: Pointer; // UCollator*
status: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icuin.dll' name 'ucol_openBinary';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ucol_openBinary"
c_ucol_openBinary :: Ptr Word8 -> Int32 -> Ptr CIntPtr -> Ptr Int32 -> IO (Ptr CIntPtr)
-- bin : BYTE* -> Ptr Word8
-- length : INT -> Int32
-- base : UCollator* -> Ptr CIntPtr
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ucol_openbinary =
foreign "ucol_openBinary"
((ptr uint8_t) @-> int32_t @-> (ptr intptr_t) @-> (ptr int32_t) @-> returning (ptr intptr_t))
(* bin : BYTE* -> (ptr uint8_t) *)
(* length : INT -> int32_t *)
(* base : UCollator* -> (ptr intptr_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 ("ucol_openBinary" ucol-open-binary :convention :cdecl) :pointer
(bin :pointer) ; BYTE*
(length :int32) ; INT
(base :pointer) ; UCollator*
(status :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ucol_openBinary = Win32::API::More->new('icuin',
'LPVOID ucol_openBinary(LPVOID bin, int length, LPVOID base, LPVOID status)');
# my $ret = $ucol_openBinary->Call($bin, $length, $base, $status);
# bin : BYTE* -> LPVOID
# length : INT -> int
# base : UCollator* -> LPVOID
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型