Win32 API 日本語リファレンス
ホームGlobalization › uidna_labelToUnicodeUTF8

uidna_labelToUnicodeUTF8

関数
ASCIIラベルをUTF-8のUnicode形式へ逆変換する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

// icuuc.dll
#include <windows.h>

INT uidna_labelToUnicodeUTF8(
    const UIDNA* idna,
    LPCSTR label,
    INT length,
    LPSTR dest,
    INT capacity,
    UIDNAInfo* pInfo,
    UErrorCode* pErrorCode
);

パラメーター

名前方向
idnaUIDNA*in
labelLPCSTRin
lengthINTin
destLPSTRin
capacityINTin
pInfoUIDNAInfo*inout
pErrorCodeUErrorCode*inout

戻り値の型: INT

各言語での呼び出し定義

// icuuc.dll
#include <windows.h>

INT uidna_labelToUnicodeUTF8(
    const UIDNA* idna,
    LPCSTR label,
    INT length,
    LPSTR dest,
    INT capacity,
    UIDNAInfo* pInfo,
    UErrorCode* pErrorCode
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int uidna_labelToUnicodeUTF8(
    ref IntPtr idna,   // UIDNA*
    [MarshalAs(UnmanagedType.LPStr)] string label,   // LPCSTR
    int length,   // INT
    [MarshalAs(UnmanagedType.LPStr)] string dest,   // LPSTR
    int capacity,   // INT
    IntPtr pInfo,   // UIDNAInfo* in/out
    ref int pErrorCode   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function uidna_labelToUnicodeUTF8(
    ByRef idna As IntPtr,   ' UIDNA*
    <MarshalAs(UnmanagedType.LPStr)> label As String,   ' LPCSTR
    length As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPStr)> dest As String,   ' LPSTR
    capacity As Integer,   ' INT
    pInfo As IntPtr,   ' UIDNAInfo* in/out
    ByRef pErrorCode As Integer   ' UErrorCode* in/out
) As Integer
End Function
' idna : UIDNA*
' label : LPCSTR
' length : INT
' dest : LPSTR
' capacity : INT
' pInfo : UIDNAInfo* in/out
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function uidna_labelToUnicodeUTF8 Lib "icuuc" ( _
    ByRef idna As LongPtr, _
    ByVal label As String, _
    ByVal length As Long, _
    ByVal dest As String, _
    ByVal capacity As Long, _
    ByVal pInfo As LongPtr, _
    ByRef pErrorCode As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

uidna_labelToUnicodeUTF8 = ctypes.cdll.icuuc.uidna_labelToUnicodeUTF8
uidna_labelToUnicodeUTF8.restype = ctypes.c_int
uidna_labelToUnicodeUTF8.argtypes = [
    ctypes.c_void_p,  # idna : UIDNA*
    wintypes.LPCSTR,  # label : LPCSTR
    ctypes.c_int,  # length : INT
    wintypes.LPCSTR,  # dest : LPSTR
    ctypes.c_int,  # capacity : INT
    ctypes.c_void_p,  # pInfo : UIDNAInfo* in/out
    ctypes.c_void_p,  # pErrorCode : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
uidna_labelToUnicodeUTF8 = Fiddle::Function.new(
  lib['uidna_labelToUnicodeUTF8'],
  [
    Fiddle::TYPE_VOIDP,  # idna : UIDNA*
    Fiddle::TYPE_VOIDP,  # label : LPCSTR
    Fiddle::TYPE_INT,  # length : INT
    Fiddle::TYPE_VOIDP,  # dest : LPSTR
    Fiddle::TYPE_INT,  # capacity : INT
    Fiddle::TYPE_VOIDP,  # pInfo : UIDNAInfo* in/out
    Fiddle::TYPE_VOIDP,  # pErrorCode : UErrorCode* in/out
  ],
  Fiddle::TYPE_INT, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn uidna_labelToUnicodeUTF8(
        idna: *const isize,  // UIDNA*
        label: *const u8,  // LPCSTR
        length: i32,  // INT
        dest: *mut u8,  // LPSTR
        capacity: i32,  // INT
        pInfo: *mut UIDNAInfo,  // UIDNAInfo* in/out
        pErrorCode: *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 uidna_labelToUnicodeUTF8(ref IntPtr idna, [MarshalAs(UnmanagedType.LPStr)] string label, int length, [MarshalAs(UnmanagedType.LPStr)] string dest, int capacity, IntPtr pInfo, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_uidna_labelToUnicodeUTF8' -Namespace Win32 -PassThru
# $api::uidna_labelToUnicodeUTF8(idna, label, length, dest, capacity, pInfo, pErrorCode)
#uselib "icuuc.dll"
#func global uidna_labelToUnicodeUTF8 "uidna_labelToUnicodeUTF8" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; uidna_labelToUnicodeUTF8 idna, label, length, dest, capacity, varptr(pInfo), pErrorCode   ; 戻り値は stat
; idna : UIDNA* -> "sptr"
; label : LPCSTR -> "sptr"
; length : INT -> "sptr"
; dest : LPSTR -> "sptr"
; capacity : INT -> "sptr"
; pInfo : UIDNAInfo* in/out -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global uidna_labelToUnicodeUTF8 "uidna_labelToUnicodeUTF8" int, str, int, str, int, var, int
; res = uidna_labelToUnicodeUTF8(idna, label, length, dest, capacity, pInfo, pErrorCode)
; idna : UIDNA* -> "int"
; label : LPCSTR -> "str"
; length : INT -> "int"
; dest : LPSTR -> "str"
; capacity : INT -> "int"
; pInfo : UIDNAInfo* in/out -> "var"
; pErrorCode : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT uidna_labelToUnicodeUTF8(UIDNA* idna, LPCSTR label, INT length, LPSTR dest, INT capacity, UIDNAInfo* pInfo, UErrorCode* pErrorCode)
#uselib "icuuc.dll"
#cfunc global uidna_labelToUnicodeUTF8 "uidna_labelToUnicodeUTF8" int, str, int, str, int, var, int
; res = uidna_labelToUnicodeUTF8(idna, label, length, dest, capacity, pInfo, pErrorCode)
; idna : UIDNA* -> "int"
; label : LPCSTR -> "str"
; length : INT -> "int"
; dest : LPSTR -> "str"
; capacity : INT -> "int"
; pInfo : UIDNAInfo* in/out -> "var"
; pErrorCode : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procuidna_labelToUnicodeUTF8 = icuuc.NewProc("uidna_labelToUnicodeUTF8")
)

// idna (UIDNA*), label (LPCSTR), length (INT), dest (LPSTR), capacity (INT), pInfo (UIDNAInfo* in/out), pErrorCode (UErrorCode* in/out)
r1, _, err := procuidna_labelToUnicodeUTF8.Call(
	uintptr(idna),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(label))),
	uintptr(length),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(dest))),
	uintptr(capacity),
	uintptr(pInfo),
	uintptr(pErrorCode),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function uidna_labelToUnicodeUTF8(
  idna: Pointer;   // UIDNA*
  label: PAnsiChar;   // LPCSTR
  length: Integer;   // INT
  dest: PAnsiChar;   // LPSTR
  capacity: Integer;   // INT
  pInfo: Pointer;   // UIDNAInfo* in/out
  pErrorCode: Pointer   // UErrorCode* in/out
): Integer; cdecl;
  external 'icuuc.dll' name 'uidna_labelToUnicodeUTF8';
result := DllCall("icuuc\uidna_labelToUnicodeUTF8"
    , "Ptr", idna   ; UIDNA*
    , "AStr", label   ; LPCSTR
    , "Int", length   ; INT
    , "AStr", dest   ; LPSTR
    , "Int", capacity   ; INT
    , "Ptr", pInfo   ; UIDNAInfo* in/out
    , "Ptr", pErrorCode   ; UErrorCode* in/out
    , "Cdecl Int")   ; return: INT
●uidna_labelToUnicodeUTF8(idna, label, length, dest, capacity, pInfo, pErrorCode) = DLL("icuuc.dll", "int uidna_labelToUnicodeUTF8(void*, char*, int, char*, int, void*, void*)")
# 呼び出し: uidna_labelToUnicodeUTF8(idna, label, length, dest, capacity, pInfo, pErrorCode)
# idna : UIDNA* -> "void*"
# label : LPCSTR -> "char*"
# length : INT -> "int"
# dest : LPSTR -> "char*"
# capacity : INT -> "int"
# pInfo : UIDNAInfo* in/out -> "void*"
# pErrorCode : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。