ホーム › Globalization › uidna_nameToUnicodeUTF8
uidna_nameToUnicodeUTF8
関数ASCIIのドメイン名をUTF-8のUnicode形式へ逆変換する。
シグネチャ
// icuuc.dll
#include <windows.h>
INT uidna_nameToUnicodeUTF8(
const UIDNA* idna,
LPCSTR name,
INT length,
LPSTR dest,
INT capacity,
UIDNAInfo* pInfo,
UErrorCode* pErrorCode
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| idna | UIDNA* | in |
| name | LPCSTR | in |
| length | INT | in |
| dest | LPSTR | in |
| capacity | INT | in |
| pInfo | UIDNAInfo* | inout |
| pErrorCode | UErrorCode* | inout |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT uidna_nameToUnicodeUTF8(
const UIDNA* idna,
LPCSTR name,
INT length,
LPSTR dest,
INT capacity,
UIDNAInfo* pInfo,
UErrorCode* pErrorCode
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int uidna_nameToUnicodeUTF8(
ref IntPtr idna, // UIDNA*
[MarshalAs(UnmanagedType.LPStr)] string name, // 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_nameToUnicodeUTF8(
ByRef idna As IntPtr, ' UIDNA*
<MarshalAs(UnmanagedType.LPStr)> name 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*
' name : LPCSTR
' length : INT
' dest : LPSTR
' capacity : INT
' pInfo : UIDNAInfo* in/out
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function uidna_nameToUnicodeUTF8 Lib "icuuc" ( _
ByRef idna As LongPtr, _
ByVal name 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_nameToUnicodeUTF8 = ctypes.cdll.icuuc.uidna_nameToUnicodeUTF8
uidna_nameToUnicodeUTF8.restype = ctypes.c_int
uidna_nameToUnicodeUTF8.argtypes = [
ctypes.c_void_p, # idna : UIDNA*
wintypes.LPCSTR, # name : 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_nameToUnicodeUTF8 = Fiddle::Function.new(
lib['uidna_nameToUnicodeUTF8'],
[
Fiddle::TYPE_VOIDP, # idna : UIDNA*
Fiddle::TYPE_VOIDP, # name : 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_nameToUnicodeUTF8(
idna: *const isize, // UIDNA*
name: *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_nameToUnicodeUTF8(ref IntPtr idna, [MarshalAs(UnmanagedType.LPStr)] string name, int length, [MarshalAs(UnmanagedType.LPStr)] string dest, int capacity, IntPtr pInfo, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_uidna_nameToUnicodeUTF8' -Namespace Win32 -PassThru
# $api::uidna_nameToUnicodeUTF8(idna, name, length, dest, capacity, pInfo, pErrorCode)#uselib "icuuc.dll"
#func global uidna_nameToUnicodeUTF8 "uidna_nameToUnicodeUTF8" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; uidna_nameToUnicodeUTF8 idna, name, length, dest, capacity, varptr(pInfo), pErrorCode ; 戻り値は stat
; idna : UIDNA* -> "sptr"
; name : 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_nameToUnicodeUTF8 "uidna_nameToUnicodeUTF8" int, str, int, str, int, var, int ; res = uidna_nameToUnicodeUTF8(idna, name, length, dest, capacity, pInfo, pErrorCode) ; idna : UIDNA* -> "int" ; name : LPCSTR -> "str" ; length : INT -> "int" ; dest : LPSTR -> "str" ; capacity : INT -> "int" ; pInfo : UIDNAInfo* in/out -> "var" ; pErrorCode : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global uidna_nameToUnicodeUTF8 "uidna_nameToUnicodeUTF8" int, str, int, str, int, sptr, int ; res = uidna_nameToUnicodeUTF8(idna, name, length, dest, capacity, varptr(pInfo), pErrorCode) ; idna : UIDNA* -> "int" ; name : LPCSTR -> "str" ; length : INT -> "int" ; dest : LPSTR -> "str" ; capacity : INT -> "int" ; pInfo : UIDNAInfo* in/out -> "sptr" ; pErrorCode : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT uidna_nameToUnicodeUTF8(UIDNA* idna, LPCSTR name, INT length, LPSTR dest, INT capacity, UIDNAInfo* pInfo, UErrorCode* pErrorCode) #uselib "icuuc.dll" #cfunc global uidna_nameToUnicodeUTF8 "uidna_nameToUnicodeUTF8" int, str, int, str, int, var, int ; res = uidna_nameToUnicodeUTF8(idna, name, length, dest, capacity, pInfo, pErrorCode) ; idna : UIDNA* -> "int" ; name : 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_nameToUnicodeUTF8(UIDNA* idna, LPCSTR name, INT length, LPSTR dest, INT capacity, UIDNAInfo* pInfo, UErrorCode* pErrorCode) #uselib "icuuc.dll" #cfunc global uidna_nameToUnicodeUTF8 "uidna_nameToUnicodeUTF8" int, str, int, str, int, intptr, int ; res = uidna_nameToUnicodeUTF8(idna, name, length, dest, capacity, varptr(pInfo), pErrorCode) ; idna : UIDNA* -> "int" ; name : LPCSTR -> "str" ; length : INT -> "int" ; dest : LPSTR -> "str" ; capacity : INT -> "int" ; pInfo : UIDNAInfo* in/out -> "intptr" ; pErrorCode : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procuidna_nameToUnicodeUTF8 = icuuc.NewProc("uidna_nameToUnicodeUTF8")
)
// idna (UIDNA*), name (LPCSTR), length (INT), dest (LPSTR), capacity (INT), pInfo (UIDNAInfo* in/out), pErrorCode (UErrorCode* in/out)
r1, _, err := procuidna_nameToUnicodeUTF8.Call(
uintptr(idna),
uintptr(unsafe.Pointer(windows.BytePtrFromString(name))),
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 // INTfunction uidna_nameToUnicodeUTF8(
idna: Pointer; // UIDNA*
name: 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_nameToUnicodeUTF8';result := DllCall("icuuc\uidna_nameToUnicodeUTF8"
, "Ptr", idna ; UIDNA*
, "AStr", name ; 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_nameToUnicodeUTF8(idna, name, length, dest, capacity, pInfo, pErrorCode) = DLL("icuuc.dll", "int uidna_nameToUnicodeUTF8(void*, char*, int, char*, int, void*, void*)")
# 呼び出し: uidna_nameToUnicodeUTF8(idna, name, length, dest, capacity, pInfo, pErrorCode)
# idna : UIDNA* -> "void*"
# name : 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`,…) を使用。