ホーム › Globalization › ucnv_openPackage
ucnv_openPackage
関数指定パッケージから文字コード変換器を開く。
シグネチャ
// icuuc.dll
#include <windows.h>
UConverter* ucnv_openPackage(
LPCSTR packageName,
LPCSTR converterName,
UErrorCode* err
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| packageName | LPCSTR | in |
| converterName | LPCSTR | in |
| err | UErrorCode* | inout |
戻り値の型: UConverter*
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
UConverter* ucnv_openPackage(
LPCSTR packageName,
LPCSTR converterName,
UErrorCode* err
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ucnv_openPackage(
[MarshalAs(UnmanagedType.LPStr)] string packageName, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string converterName, // LPCSTR
ref int err // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucnv_openPackage(
<MarshalAs(UnmanagedType.LPStr)> packageName As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> converterName As String, ' LPCSTR
ByRef err As Integer ' UErrorCode* in/out
) As IntPtr
End Function' packageName : LPCSTR
' converterName : LPCSTR
' err : UErrorCode* in/out
Declare PtrSafe Function ucnv_openPackage Lib "icuuc" ( _
ByVal packageName As String, _
ByVal converterName As String, _
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_openPackage = ctypes.cdll.icuuc.ucnv_openPackage
ucnv_openPackage.restype = ctypes.c_void_p
ucnv_openPackage.argtypes = [
wintypes.LPCSTR, # packageName : LPCSTR
wintypes.LPCSTR, # converterName : LPCSTR
ctypes.c_void_p, # err : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
ucnv_openPackage = Fiddle::Function.new(
lib['ucnv_openPackage'],
[
Fiddle::TYPE_VOIDP, # packageName : LPCSTR
Fiddle::TYPE_VOIDP, # converterName : LPCSTR
Fiddle::TYPE_VOIDP, # err : UErrorCode* in/out
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn ucnv_openPackage(
packageName: *const u8, // LPCSTR
converterName: *const u8, // LPCSTR
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_openPackage([MarshalAs(UnmanagedType.LPStr)] string packageName, [MarshalAs(UnmanagedType.LPStr)] string converterName, ref int err);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucnv_openPackage' -Namespace Win32 -PassThru
# $api::ucnv_openPackage(packageName, converterName, err)#uselib "icuuc.dll"
#func global ucnv_openPackage "ucnv_openPackage" sptr, sptr, sptr
; ucnv_openPackage packageName, converterName, err ; 戻り値は stat
; packageName : LPCSTR -> "sptr"
; converterName : LPCSTR -> "sptr"
; err : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "icuuc.dll"
#cfunc global ucnv_openPackage "ucnv_openPackage" str, str, int
; res = ucnv_openPackage(packageName, converterName, err)
; packageName : LPCSTR -> "str"
; converterName : LPCSTR -> "str"
; err : UErrorCode* in/out -> "int"; UConverter* ucnv_openPackage(LPCSTR packageName, LPCSTR converterName, UErrorCode* err)
#uselib "icuuc.dll"
#cfunc global ucnv_openPackage "ucnv_openPackage" str, str, int
; res = ucnv_openPackage(packageName, converterName, err)
; packageName : LPCSTR -> "str"
; converterName : LPCSTR -> "str"
; err : UErrorCode* in/out -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procucnv_openPackage = icuuc.NewProc("ucnv_openPackage")
)
// packageName (LPCSTR), converterName (LPCSTR), err (UErrorCode* in/out)
r1, _, err := procucnv_openPackage.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(packageName))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(converterName))),
uintptr(err),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // UConverter*function ucnv_openPackage(
packageName: PAnsiChar; // LPCSTR
converterName: PAnsiChar; // LPCSTR
err: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icuuc.dll' name 'ucnv_openPackage';result := DllCall("icuuc\ucnv_openPackage"
, "AStr", packageName ; LPCSTR
, "AStr", converterName ; LPCSTR
, "Ptr", err ; UErrorCode* in/out
, "Cdecl Ptr") ; return: UConverter*●ucnv_openPackage(packageName, converterName, err) = DLL("icuuc.dll", "void* ucnv_openPackage(char*, char*, void*)")
# 呼び出し: ucnv_openPackage(packageName, converterName, err)
# packageName : LPCSTR -> "char*"
# converterName : LPCSTR -> "char*"
# err : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。