ホーム › Globalization › ubrk_openBinaryRules
ubrk_openBinaryRules
関数バイナリ規則からテキスト分割イテレータを開く。
シグネチャ
// icuuc.dll
#include <windows.h>
UBreakIterator* ubrk_openBinaryRules(
const BYTE* binaryRules,
INT rulesLength,
const WORD* text,
INT textLength,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| binaryRules | BYTE* | in | コンパイル済みのバイナリ規則データを指す。 |
| rulesLength | INT | in | binaryRulesの長さをバイト単位で指定する。 |
| text | WORD* | in | 走査対象のUTF-16テキストを指す。NULL可。 |
| textLength | INT | in | textの長さをUChar単位で指定する。-1でNUL終端。 |
| status | UErrorCode* | inout | ICUエラーコードを入出力するポインタ。呼出前に成功値で初期化する。 |
戻り値の型: UBreakIterator*
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
UBreakIterator* ubrk_openBinaryRules(
const BYTE* binaryRules,
INT rulesLength,
const WORD* text,
INT textLength,
UErrorCode* status
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ubrk_openBinaryRules(
IntPtr binaryRules, // BYTE*
int rulesLength, // INT
ref ushort text, // WORD*
int textLength, // INT
ref int status // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ubrk_openBinaryRules(
binaryRules As IntPtr, ' BYTE*
rulesLength As Integer, ' INT
ByRef text As UShort, ' WORD*
textLength As Integer, ' INT
ByRef status As Integer ' UErrorCode* in/out
) As IntPtr
End Function' binaryRules : BYTE*
' rulesLength : INT
' text : WORD*
' textLength : INT
' status : UErrorCode* in/out
Declare PtrSafe Function ubrk_openBinaryRules Lib "icuuc" ( _
ByVal binaryRules As LongPtr, _
ByVal rulesLength As Long, _
ByRef text As Integer, _
ByVal textLength 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
ubrk_openBinaryRules = ctypes.cdll.icuuc.ubrk_openBinaryRules
ubrk_openBinaryRules.restype = ctypes.c_void_p
ubrk_openBinaryRules.argtypes = [
ctypes.POINTER(ctypes.c_ubyte), # binaryRules : BYTE*
ctypes.c_int, # rulesLength : INT
ctypes.POINTER(ctypes.c_ushort), # text : WORD*
ctypes.c_int, # textLength : INT
ctypes.c_void_p, # status : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
ubrk_openBinaryRules = Fiddle::Function.new(
lib['ubrk_openBinaryRules'],
[
Fiddle::TYPE_VOIDP, # binaryRules : BYTE*
Fiddle::TYPE_INT, # rulesLength : INT
Fiddle::TYPE_VOIDP, # text : WORD*
Fiddle::TYPE_INT, # textLength : INT
Fiddle::TYPE_VOIDP, # status : UErrorCode* in/out
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn ubrk_openBinaryRules(
binaryRules: *const u8, // BYTE*
rulesLength: i32, // INT
text: *const u16, // WORD*
textLength: i32, // INT
status: *mut i32 // UErrorCode* in/out
) -> *mut isize;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ubrk_openBinaryRules(IntPtr binaryRules, int rulesLength, ref ushort text, int textLength, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ubrk_openBinaryRules' -Namespace Win32 -PassThru
# $api::ubrk_openBinaryRules(binaryRules, rulesLength, text, textLength, status)#uselib "icuuc.dll"
#func global ubrk_openBinaryRules "ubrk_openBinaryRules" sptr, sptr, sptr, sptr, sptr
; ubrk_openBinaryRules varptr(binaryRules), rulesLength, varptr(text), textLength, varptr(status) ; 戻り値は stat
; binaryRules : BYTE* -> "sptr"
; rulesLength : INT -> "sptr"
; text : WORD* -> "sptr"
; textLength : INT -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global ubrk_openBinaryRules "ubrk_openBinaryRules" var, int, var, int, var ; res = ubrk_openBinaryRules(binaryRules, rulesLength, text, textLength, status) ; binaryRules : BYTE* -> "var" ; rulesLength : INT -> "int" ; text : WORD* -> "var" ; textLength : INT -> "int" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global ubrk_openBinaryRules "ubrk_openBinaryRules" sptr, int, sptr, int, sptr ; res = ubrk_openBinaryRules(varptr(binaryRules), rulesLength, varptr(text), textLength, varptr(status)) ; binaryRules : BYTE* -> "sptr" ; rulesLength : INT -> "int" ; text : WORD* -> "sptr" ; textLength : INT -> "int" ; status : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; UBreakIterator* ubrk_openBinaryRules(BYTE* binaryRules, INT rulesLength, WORD* text, INT textLength, UErrorCode* status) #uselib "icuuc.dll" #cfunc global ubrk_openBinaryRules "ubrk_openBinaryRules" var, int, var, int, var ; res = ubrk_openBinaryRules(binaryRules, rulesLength, text, textLength, status) ; binaryRules : BYTE* -> "var" ; rulesLength : INT -> "int" ; text : WORD* -> "var" ; textLength : INT -> "int" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; UBreakIterator* ubrk_openBinaryRules(BYTE* binaryRules, INT rulesLength, WORD* text, INT textLength, UErrorCode* status) #uselib "icuuc.dll" #cfunc global ubrk_openBinaryRules "ubrk_openBinaryRules" intptr, int, intptr, int, intptr ; res = ubrk_openBinaryRules(varptr(binaryRules), rulesLength, varptr(text), textLength, varptr(status)) ; binaryRules : BYTE* -> "intptr" ; rulesLength : INT -> "int" ; text : WORD* -> "intptr" ; textLength : INT -> "int" ; status : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procubrk_openBinaryRules = icuuc.NewProc("ubrk_openBinaryRules")
)
// binaryRules (BYTE*), rulesLength (INT), text (WORD*), textLength (INT), status (UErrorCode* in/out)
r1, _, err := procubrk_openBinaryRules.Call(
uintptr(binaryRules),
uintptr(rulesLength),
uintptr(text),
uintptr(textLength),
uintptr(status),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // UBreakIterator*function ubrk_openBinaryRules(
binaryRules: Pointer; // BYTE*
rulesLength: Integer; // INT
text: Pointer; // WORD*
textLength: Integer; // INT
status: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icuuc.dll' name 'ubrk_openBinaryRules';result := DllCall("icuuc\ubrk_openBinaryRules"
, "Ptr", binaryRules ; BYTE*
, "Int", rulesLength ; INT
, "Ptr", text ; WORD*
, "Int", textLength ; INT
, "Ptr", status ; UErrorCode* in/out
, "Cdecl Ptr") ; return: UBreakIterator*●ubrk_openBinaryRules(binaryRules, rulesLength, text, textLength, status) = DLL("icuuc.dll", "void* ubrk_openBinaryRules(void*, int, void*, int, void*)")
# 呼び出し: ubrk_openBinaryRules(binaryRules, rulesLength, text, textLength, status)
# binaryRules : BYTE* -> "void*"
# rulesLength : INT -> "int"
# text : WORD* -> "void*"
# textLength : 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 "icuuc" fn ubrk_openBinaryRules(
binaryRules: [*c]u8, // BYTE*
rulesLength: i32, // INT
text: [*c]u16, // WORD*
textLength: i32, // INT
status: [*c]i32 // UErrorCode* in/out
) callconv(.c) [*c]isize;proc ubrk_openBinaryRules(
binaryRules: ptr uint8, # BYTE*
rulesLength: int32, # INT
text: ptr uint16, # WORD*
textLength: int32, # INT
status: ptr int32 # UErrorCode* in/out
): ptr int {.importc: "ubrk_openBinaryRules", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
ptrdiff_t* ubrk_openBinaryRules(
ubyte* binaryRules, // BYTE*
int rulesLength, // INT
ushort* text, // WORD*
int textLength, // INT
int* status // UErrorCode* in/out
);ccall((:ubrk_openBinaryRules, "icuuc.dll"), Ptr{Int},
(Ptr{UInt8}, Int32, Ptr{UInt16}, Int32, Ptr{Int32}),
binaryRules, rulesLength, text, textLength, status)
# binaryRules : BYTE* -> Ptr{UInt8}
# rulesLength : INT -> Int32
# text : WORD* -> Ptr{UInt16}
# textLength : INT -> Int32
# status : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
intptr_t* ubrk_openBinaryRules(
uint8_t* binaryRules,
int32_t rulesLength,
uint16_t* text,
int32_t textLength,
int32_t* status);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.ubrk_openBinaryRules(binaryRules, rulesLength, text, textLength, status)
-- binaryRules : BYTE*
-- rulesLength : INT
-- text : WORD*
-- textLength : INT
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const ubrk_openBinaryRules = lib.func('__cdecl', 'ubrk_openBinaryRules', 'intptr_t *', ['uint8_t *', 'int32_t', 'uint16_t *', 'int32_t', 'int32_t *']);
// ubrk_openBinaryRules(binaryRules, rulesLength, text, textLength, status)
// binaryRules : BYTE* -> 'uint8_t *'
// rulesLength : INT -> 'int32_t'
// text : WORD* -> 'uint16_t *'
// textLength : INT -> 'int32_t'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
ubrk_openBinaryRules: { parameters: ["pointer", "i32", "pointer", "i32", "pointer"], result: "pointer" },
});
// lib.symbols.ubrk_openBinaryRules(binaryRules, rulesLength, text, textLength, status)
// binaryRules : BYTE* -> "pointer"
// rulesLength : INT -> "i32"
// text : WORD* -> "pointer"
// textLength : INT -> "i32"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
intptr_t* ubrk_openBinaryRules(
uint8_t* binaryRules,
int32_t rulesLength,
uint16_t* text,
int32_t textLength,
int32_t* status);
C, "icuuc.dll");
// $ffi->ubrk_openBinaryRules(binaryRules, rulesLength, text, textLength, status);
// binaryRules : BYTE*
// rulesLength : INT
// text : WORD*
// textLength : 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 Icuuc extends Library {
Icuuc INSTANCE = Native.load("icuuc", Icuuc.class);
Pointer ubrk_openBinaryRules(
byte[] binaryRules, // BYTE*
int rulesLength, // INT
ShortByReference text, // WORD*
int textLength, // INT
IntByReference status // UErrorCode* in/out
);
}@[Link("icuuc")]
lib Libicuuc
fun ubrk_openBinaryRules = ubrk_openBinaryRules(
binaryRules : UInt8*, # BYTE*
rulesLength : Int32, # INT
text : UInt16*, # WORD*
textLength : Int32, # INT
status : Int32* # UErrorCode* in/out
) : LibC::SSizeT*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ubrk_openBinaryRulesNative = Pointer<IntPtr> Function(Pointer<Uint8>, Int32, Pointer<Uint16>, Int32, Pointer<Int32>);
typedef ubrk_openBinaryRulesDart = Pointer<IntPtr> Function(Pointer<Uint8>, int, Pointer<Uint16>, int, Pointer<Int32>);
final ubrk_openBinaryRules = DynamicLibrary.open('icuuc.dll')
.lookupFunction<ubrk_openBinaryRulesNative, ubrk_openBinaryRulesDart>('ubrk_openBinaryRules');
// binaryRules : BYTE* -> Pointer<Uint8>
// rulesLength : INT -> Int32
// text : WORD* -> Pointer<Uint16>
// textLength : INT -> Int32
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ubrk_openBinaryRules(
binaryRules: Pointer; // BYTE*
rulesLength: Integer; // INT
text: Pointer; // WORD*
textLength: Integer; // INT
status: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icuuc.dll' name 'ubrk_openBinaryRules';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ubrk_openBinaryRules"
c_ubrk_openBinaryRules :: Ptr Word8 -> Int32 -> Ptr Word16 -> Int32 -> Ptr Int32 -> IO (Ptr CIntPtr)
-- binaryRules : BYTE* -> Ptr Word8
-- rulesLength : INT -> Int32
-- text : WORD* -> Ptr Word16
-- textLength : INT -> Int32
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ubrk_openbinaryrules =
foreign "ubrk_openBinaryRules"
((ptr uint8_t) @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> (ptr int32_t) @-> returning (ptr intptr_t))
(* binaryRules : BYTE* -> (ptr uint8_t) *)
(* rulesLength : INT -> int32_t *)
(* text : WORD* -> (ptr uint16_t) *)
(* textLength : INT -> int32_t *)
(* status : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)
(cffi:defcfun ("ubrk_openBinaryRules" ubrk-open-binary-rules :convention :cdecl) :pointer
(binary-rules :pointer) ; BYTE*
(rules-length :int32) ; INT
(text :pointer) ; WORD*
(text-length :int32) ; INT
(status :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ubrk_openBinaryRules = Win32::API::More->new('icuuc',
'LPVOID ubrk_openBinaryRules(LPVOID binaryRules, int rulesLength, LPVOID text, int textLength, LPVOID status)');
# my $ret = $ubrk_openBinaryRules->Call($binaryRules, $rulesLength, $text, $textLength, $status);
# binaryRules : BYTE* -> LPVOID
# rulesLength : INT -> int
# text : WORD* -> LPVOID
# textLength : INT -> int
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型