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