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