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