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

uidna_labelToASCII

関数
ドメインラベルをPunycode等のASCII形式へ変換する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

INT uidna_labelToASCII(
    const UIDNA* idna,
    const WORD* label,
    INT length,
    WORD* dest,
    INT capacity,
    UIDNAInfo* pInfo,
    UErrorCode* pErrorCode
);

パラメーター

名前方向
idnaUIDNA*in
labelWORD*in
lengthINTin
destWORD*inout
capacityINTin
pInfoUIDNAInfo*inout
pErrorCodeUErrorCode*inout

戻り値の型: INT

各言語での呼び出し定義

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

INT uidna_labelToASCII(
    const UIDNA* idna,
    const WORD* label,
    INT length,
    WORD* dest,
    INT capacity,
    UIDNAInfo* pInfo,
    UErrorCode* pErrorCode
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int uidna_labelToASCII(
    ref IntPtr idna,   // UIDNA*
    ref ushort label,   // WORD*
    int length,   // INT
    ref ushort dest,   // WORD* in/out
    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_labelToASCII(
    ByRef idna As IntPtr,   ' UIDNA*
    ByRef label As UShort,   ' WORD*
    length As Integer,   ' INT
    ByRef dest As UShort,   ' WORD* in/out
    capacity As Integer,   ' INT
    pInfo As IntPtr,   ' UIDNAInfo* in/out
    ByRef pErrorCode As Integer   ' UErrorCode* in/out
) As Integer
End Function
' idna : UIDNA*
' label : WORD*
' length : INT
' dest : WORD* in/out
' capacity : INT
' pInfo : UIDNAInfo* in/out
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function uidna_labelToASCII Lib "icuuc" ( _
    ByRef idna As LongPtr, _
    ByRef label As Integer, _
    ByVal length As Long, _
    ByRef dest As Integer, _
    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_labelToASCII = ctypes.cdll.icuuc.uidna_labelToASCII
uidna_labelToASCII.restype = ctypes.c_int
uidna_labelToASCII.argtypes = [
    ctypes.c_void_p,  # idna : UIDNA*
    ctypes.POINTER(ctypes.c_ushort),  # label : WORD*
    ctypes.c_int,  # length : INT
    ctypes.POINTER(ctypes.c_ushort),  # dest : WORD* in/out
    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_labelToASCII = Fiddle::Function.new(
  lib['uidna_labelToASCII'],
  [
    Fiddle::TYPE_VOIDP,  # idna : UIDNA*
    Fiddle::TYPE_VOIDP,  # label : WORD*
    Fiddle::TYPE_INT,  # length : INT
    Fiddle::TYPE_VOIDP,  # dest : WORD* in/out
    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_labelToASCII(
        idna: *const isize,  // UIDNA*
        label: *const u16,  // WORD*
        length: i32,  // INT
        dest: *mut u16,  // WORD* in/out
        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_labelToASCII(ref IntPtr idna, ref ushort label, int length, ref ushort dest, int capacity, IntPtr pInfo, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_uidna_labelToASCII' -Namespace Win32 -PassThru
# $api::uidna_labelToASCII(idna, label, length, dest, capacity, pInfo, pErrorCode)
#uselib "icuuc.dll"
#func global uidna_labelToASCII "uidna_labelToASCII" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; uidna_labelToASCII idna, varptr(label), length, varptr(dest), capacity, varptr(pInfo), pErrorCode   ; 戻り値は stat
; idna : UIDNA* -> "sptr"
; label : WORD* -> "sptr"
; length : INT -> "sptr"
; dest : WORD* in/out -> "sptr"
; capacity : INT -> "sptr"
; pInfo : UIDNAInfo* in/out -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global uidna_labelToASCII "uidna_labelToASCII" int, var, int, var, int, var, int
; res = uidna_labelToASCII(idna, label, length, dest, capacity, pInfo, pErrorCode)
; idna : UIDNA* -> "int"
; label : WORD* -> "var"
; length : INT -> "int"
; dest : WORD* in/out -> "var"
; capacity : INT -> "int"
; pInfo : UIDNAInfo* in/out -> "var"
; pErrorCode : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT uidna_labelToASCII(UIDNA* idna, WORD* label, INT length, WORD* dest, INT capacity, UIDNAInfo* pInfo, UErrorCode* pErrorCode)
#uselib "icuuc.dll"
#cfunc global uidna_labelToASCII "uidna_labelToASCII" int, var, int, var, int, var, int
; res = uidna_labelToASCII(idna, label, length, dest, capacity, pInfo, pErrorCode)
; idna : UIDNA* -> "int"
; label : WORD* -> "var"
; length : INT -> "int"
; dest : WORD* in/out -> "var"
; 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_labelToASCII = icuuc.NewProc("uidna_labelToASCII")
)

// idna (UIDNA*), label (WORD*), length (INT), dest (WORD* in/out), capacity (INT), pInfo (UIDNAInfo* in/out), pErrorCode (UErrorCode* in/out)
r1, _, err := procuidna_labelToASCII.Call(
	uintptr(idna),
	uintptr(label),
	uintptr(length),
	uintptr(dest),
	uintptr(capacity),
	uintptr(pInfo),
	uintptr(pErrorCode),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function uidna_labelToASCII(
  idna: Pointer;   // UIDNA*
  label: Pointer;   // WORD*
  length: Integer;   // INT
  dest: Pointer;   // WORD* in/out
  capacity: Integer;   // INT
  pInfo: Pointer;   // UIDNAInfo* in/out
  pErrorCode: Pointer   // UErrorCode* in/out
): Integer; cdecl;
  external 'icuuc.dll' name 'uidna_labelToASCII';
result := DllCall("icuuc\uidna_labelToASCII"
    , "Ptr", idna   ; UIDNA*
    , "Ptr", label   ; WORD*
    , "Int", length   ; INT
    , "Ptr", dest   ; WORD* in/out
    , "Int", capacity   ; INT
    , "Ptr", pInfo   ; UIDNAInfo* in/out
    , "Ptr", pErrorCode   ; UErrorCode* in/out
    , "Cdecl Int")   ; return: INT
●uidna_labelToASCII(idna, label, length, dest, capacity, pInfo, pErrorCode) = DLL("icuuc.dll", "int uidna_labelToASCII(void*, void*, int, void*, int, void*, void*)")
# 呼び出し: uidna_labelToASCII(idna, label, length, dest, capacity, pInfo, pErrorCode)
# idna : UIDNA* -> "void*"
# label : WORD* -> "void*"
# length : INT -> "int"
# dest : WORD* in/out -> "void*"
# 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`,…) を使用。