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