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