ホーム › Globalization › ucnv_openU
ucnv_openU
関数Unicode名で文字コード変換器を開く。
シグネチャ
// icuuc.dll
#include <windows.h>
UConverter* ucnv_openU(
const WORD* name,
UErrorCode* err
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| name | WORD* | in |
| err | UErrorCode* | inout |
戻り値の型: UConverter*
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
UConverter* ucnv_openU(
const WORD* name,
UErrorCode* err
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ucnv_openU(
ref ushort name, // WORD*
ref int err // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucnv_openU(
ByRef name As UShort, ' WORD*
ByRef err As Integer ' UErrorCode* in/out
) As IntPtr
End Function' name : WORD*
' err : UErrorCode* in/out
Declare PtrSafe Function ucnv_openU Lib "icuuc" ( _
ByRef name As Integer, _
ByRef err As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ucnv_openU = ctypes.cdll.icuuc.ucnv_openU
ucnv_openU.restype = ctypes.c_void_p
ucnv_openU.argtypes = [
ctypes.POINTER(ctypes.c_ushort), # name : WORD*
ctypes.c_void_p, # err : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
ucnv_openU = Fiddle::Function.new(
lib['ucnv_openU'],
[
Fiddle::TYPE_VOIDP, # name : WORD*
Fiddle::TYPE_VOIDP, # err : UErrorCode* in/out
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn ucnv_openU(
name: *const u16, // WORD*
err: *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 ucnv_openU(ref ushort name, ref int err);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucnv_openU' -Namespace Win32 -PassThru
# $api::ucnv_openU(name, err)#uselib "icuuc.dll"
#func global ucnv_openU "ucnv_openU" sptr, sptr
; ucnv_openU varptr(name), err ; 戻り値は stat
; name : WORD* -> "sptr"
; err : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global ucnv_openU "ucnv_openU" var, int ; res = ucnv_openU(name, err) ; name : WORD* -> "var" ; err : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global ucnv_openU "ucnv_openU" sptr, int ; res = ucnv_openU(varptr(name), err) ; name : WORD* -> "sptr" ; err : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; UConverter* ucnv_openU(WORD* name, UErrorCode* err) #uselib "icuuc.dll" #cfunc global ucnv_openU "ucnv_openU" var, int ; res = ucnv_openU(name, err) ; name : WORD* -> "var" ; err : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; UConverter* ucnv_openU(WORD* name, UErrorCode* err) #uselib "icuuc.dll" #cfunc global ucnv_openU "ucnv_openU" intptr, int ; res = ucnv_openU(varptr(name), err) ; name : WORD* -> "intptr" ; err : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procucnv_openU = icuuc.NewProc("ucnv_openU")
)
// name (WORD*), err (UErrorCode* in/out)
r1, _, err := procucnv_openU.Call(
uintptr(name),
uintptr(err),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // UConverter*function ucnv_openU(
name: Pointer; // WORD*
err: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icuuc.dll' name 'ucnv_openU';result := DllCall("icuuc\ucnv_openU"
, "Ptr", name ; WORD*
, "Ptr", err ; UErrorCode* in/out
, "Cdecl Ptr") ; return: UConverter*●ucnv_openU(name, err) = DLL("icuuc.dll", "void* ucnv_openU(void*, void*)")
# 呼び出し: ucnv_openU(name, err)
# name : WORD* -> "void*"
# err : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。