ホーム › Globalization › uidna_nameToASCII
uidna_nameToASCII
関数ドメイン名全体をASCII互換形式へ変換する。
シグネチャ
// icuuc.dll
#include <windows.h>
INT uidna_nameToASCII(
const UIDNA* idna,
const WORD* name,
INT length,
WORD* dest,
INT capacity,
UIDNAInfo* pInfo,
UErrorCode* pErrorCode
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| idna | UIDNA* | in | 変換に用いる開いたUIDNAインスタンスを指す。 |
| name | WORD* | in | ASCII形式へ変換するドメイン名全体を指す。 |
| length | INT | in | nameの長さをUChar単位で指定する。-1でNUL終端。 |
| dest | WORD* | inout | 変換結果のASCIIドメイン名を格納する出力バッファ。NULL可。 |
| capacity | INT | in | destの容量をUChar単位で指定する。0で事前長取得。 |
| pInfo | UIDNAInfo* | inout | 処理結果やエラーフラグを受け取るUIDNAInfo構造体を指す。 |
| pErrorCode | UErrorCode* | inout | ICUエラーコードを入出力するポインタ。呼出前に成功値で初期化する。 |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT uidna_nameToASCII(
const UIDNA* idna,
const WORD* name,
INT length,
WORD* dest,
INT capacity,
UIDNAInfo* pInfo,
UErrorCode* pErrorCode
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int uidna_nameToASCII(
ref IntPtr idna, // UIDNA*
ref ushort name, // 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_nameToASCII(
ByRef idna As IntPtr, ' UIDNA*
ByRef name 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*
' name : WORD*
' length : INT
' dest : WORD* in/out
' capacity : INT
' pInfo : UIDNAInfo* in/out
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function uidna_nameToASCII Lib "icuuc" ( _
ByRef idna As LongPtr, _
ByRef name 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_nameToASCII = ctypes.cdll.icuuc.uidna_nameToASCII
uidna_nameToASCII.restype = ctypes.c_int
uidna_nameToASCII.argtypes = [
ctypes.c_void_p, # idna : UIDNA*
ctypes.POINTER(ctypes.c_ushort), # name : 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_nameToASCII = Fiddle::Function.new(
lib['uidna_nameToASCII'],
[
Fiddle::TYPE_VOIDP, # idna : UIDNA*
Fiddle::TYPE_VOIDP, # name : 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_nameToASCII(
idna: *const isize, // UIDNA*
name: *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_nameToASCII(ref IntPtr idna, ref ushort name, int length, ref ushort dest, int capacity, IntPtr pInfo, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_uidna_nameToASCII' -Namespace Win32 -PassThru
# $api::uidna_nameToASCII(idna, name, length, dest, capacity, pInfo, pErrorCode)#uselib "icuuc.dll"
#func global uidna_nameToASCII "uidna_nameToASCII" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; uidna_nameToASCII varptr(idna), varptr(name), length, varptr(dest), capacity, varptr(pInfo), varptr(pErrorCode) ; 戻り値は stat
; idna : UIDNA* -> "sptr"
; name : 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_nameToASCII "uidna_nameToASCII" var, var, int, var, int, var, var ; res = uidna_nameToASCII(idna, name, length, dest, capacity, pInfo, pErrorCode) ; idna : UIDNA* -> "var" ; name : WORD* -> "var" ; length : INT -> "int" ; dest : WORD* in/out -> "var" ; capacity : INT -> "int" ; pInfo : UIDNAInfo* in/out -> "var" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global uidna_nameToASCII "uidna_nameToASCII" sptr, sptr, int, sptr, int, sptr, sptr ; res = uidna_nameToASCII(varptr(idna), varptr(name), length, varptr(dest), capacity, varptr(pInfo), varptr(pErrorCode)) ; idna : UIDNA* -> "sptr" ; name : WORD* -> "sptr" ; length : INT -> "int" ; dest : WORD* in/out -> "sptr" ; capacity : INT -> "int" ; pInfo : UIDNAInfo* in/out -> "sptr" ; pErrorCode : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT uidna_nameToASCII(UIDNA* idna, WORD* name, INT length, WORD* dest, INT capacity, UIDNAInfo* pInfo, UErrorCode* pErrorCode) #uselib "icuuc.dll" #cfunc global uidna_nameToASCII "uidna_nameToASCII" var, var, int, var, int, var, var ; res = uidna_nameToASCII(idna, name, length, dest, capacity, pInfo, pErrorCode) ; idna : UIDNA* -> "var" ; name : WORD* -> "var" ; length : INT -> "int" ; dest : WORD* in/out -> "var" ; capacity : INT -> "int" ; pInfo : UIDNAInfo* in/out -> "var" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT uidna_nameToASCII(UIDNA* idna, WORD* name, INT length, WORD* dest, INT capacity, UIDNAInfo* pInfo, UErrorCode* pErrorCode) #uselib "icuuc.dll" #cfunc global uidna_nameToASCII "uidna_nameToASCII" intptr, intptr, int, intptr, int, intptr, intptr ; res = uidna_nameToASCII(varptr(idna), varptr(name), length, varptr(dest), capacity, varptr(pInfo), varptr(pErrorCode)) ; idna : UIDNA* -> "intptr" ; name : WORD* -> "intptr" ; length : INT -> "int" ; dest : WORD* in/out -> "intptr" ; capacity : INT -> "int" ; pInfo : UIDNAInfo* in/out -> "intptr" ; pErrorCode : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procuidna_nameToASCII = icuuc.NewProc("uidna_nameToASCII")
)
// idna (UIDNA*), name (WORD*), length (INT), dest (WORD* in/out), capacity (INT), pInfo (UIDNAInfo* in/out), pErrorCode (UErrorCode* in/out)
r1, _, err := procuidna_nameToASCII.Call(
uintptr(idna),
uintptr(name),
uintptr(length),
uintptr(dest),
uintptr(capacity),
uintptr(pInfo),
uintptr(pErrorCode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction uidna_nameToASCII(
idna: Pointer; // UIDNA*
name: 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_nameToASCII';result := DllCall("icuuc\uidna_nameToASCII"
, "Ptr", idna ; UIDNA*
, "Ptr", name ; 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_nameToASCII(idna, name, length, dest, capacity, pInfo, pErrorCode) = DLL("icuuc.dll", "int uidna_nameToASCII(void*, void*, int, void*, int, void*, void*)")
# 呼び出し: uidna_nameToASCII(idna, name, length, dest, capacity, pInfo, pErrorCode)
# idna : UIDNA* -> "void*"
# name : 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`,…) を使用。const std = @import("std");
extern "icuuc" fn uidna_nameToASCII(
idna: [*c]isize, // UIDNA*
name: [*c]u16, // WORD*
length: i32, // INT
dest: [*c]u16, // WORD* in/out
capacity: i32, // INT
pInfo: [*c]UIDNAInfo, // UIDNAInfo* in/out
pErrorCode: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;proc uidna_nameToASCII(
idna: ptr int, # UIDNA*
name: ptr uint16, # WORD*
length: int32, # INT
dest: ptr uint16, # WORD* in/out
capacity: int32, # INT
pInfo: ptr UIDNAInfo, # UIDNAInfo* in/out
pErrorCode: ptr int32 # UErrorCode* in/out
): int32 {.importc: "uidna_nameToASCII", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
int uidna_nameToASCII(
ptrdiff_t* idna, // UIDNA*
ushort* name, // WORD*
int length, // INT
ushort* dest, // WORD* in/out
int capacity, // INT
UIDNAInfo* pInfo, // UIDNAInfo* in/out
int* pErrorCode // UErrorCode* in/out
);ccall((:uidna_nameToASCII, "icuuc.dll"), Int32,
(Ptr{Int}, Ptr{UInt16}, Int32, Ptr{UInt16}, Int32, Ptr{UIDNAInfo}, Ptr{Int32}),
idna, name, length, dest, capacity, pInfo, pErrorCode)
# idna : UIDNA* -> Ptr{Int}
# name : WORD* -> Ptr{UInt16}
# length : INT -> Int32
# dest : WORD* in/out -> Ptr{UInt16}
# capacity : INT -> Int32
# pInfo : UIDNAInfo* in/out -> Ptr{UIDNAInfo}
# pErrorCode : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
int32_t uidna_nameToASCII(
intptr_t* idna,
uint16_t* name,
int32_t length,
uint16_t* dest,
int32_t capacity,
void* pInfo,
int32_t* pErrorCode);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.uidna_nameToASCII(idna, name, length, dest, capacity, pInfo, pErrorCode)
-- idna : UIDNA*
-- name : WORD*
-- length : INT
-- dest : WORD* in/out
-- capacity : INT
-- pInfo : UIDNAInfo* in/out
-- pErrorCode : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const uidna_nameToASCII = lib.func('__cdecl', 'uidna_nameToASCII', 'int32_t', ['intptr_t *', 'uint16_t *', 'int32_t', 'uint16_t *', 'int32_t', 'void *', 'int32_t *']);
// uidna_nameToASCII(idna, name, length, dest, capacity, pInfo, pErrorCode)
// idna : UIDNA* -> 'intptr_t *'
// name : WORD* -> 'uint16_t *'
// length : INT -> 'int32_t'
// dest : WORD* in/out -> 'uint16_t *'
// capacity : INT -> 'int32_t'
// pInfo : UIDNAInfo* in/out -> 'void *'
// pErrorCode : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
uidna_nameToASCII: { parameters: ["pointer", "pointer", "i32", "pointer", "i32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.uidna_nameToASCII(idna, name, length, dest, capacity, pInfo, pErrorCode)
// idna : UIDNA* -> "pointer"
// name : WORD* -> "pointer"
// length : INT -> "i32"
// dest : WORD* in/out -> "pointer"
// capacity : INT -> "i32"
// pInfo : UIDNAInfo* in/out -> "pointer"
// pErrorCode : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t uidna_nameToASCII(
intptr_t* idna,
uint16_t* name,
int32_t length,
uint16_t* dest,
int32_t capacity,
void* pInfo,
int32_t* pErrorCode);
C, "icuuc.dll");
// $ffi->uidna_nameToASCII(idna, name, length, dest, capacity, pInfo, pErrorCode);
// idna : UIDNA*
// name : WORD*
// length : INT
// dest : WORD* in/out
// capacity : INT
// pInfo : UIDNAInfo* in/out
// pErrorCode : UErrorCode* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Icuuc extends Library {
Icuuc INSTANCE = Native.load("icuuc", Icuuc.class);
int uidna_nameToASCII(
LongByReference idna, // UIDNA*
ShortByReference name, // WORD*
int length, // INT
ShortByReference dest, // WORD* in/out
int capacity, // INT
Pointer pInfo, // UIDNAInfo* in/out
IntByReference pErrorCode // UErrorCode* in/out
);
}@[Link("icuuc")]
lib Libicuuc
fun uidna_nameToASCII = uidna_nameToASCII(
idna : LibC::SSizeT*, # UIDNA*
name : UInt16*, # WORD*
length : Int32, # INT
dest : UInt16*, # WORD* in/out
capacity : Int32, # INT
pInfo : UIDNAInfo*, # UIDNAInfo* in/out
pErrorCode : Int32* # UErrorCode* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef uidna_nameToASCIINative = Int32 Function(Pointer<IntPtr>, Pointer<Uint16>, Int32, Pointer<Uint16>, Int32, Pointer<Void>, Pointer<Int32>);
typedef uidna_nameToASCIIDart = int Function(Pointer<IntPtr>, Pointer<Uint16>, int, Pointer<Uint16>, int, Pointer<Void>, Pointer<Int32>);
final uidna_nameToASCII = DynamicLibrary.open('icuuc.dll')
.lookupFunction<uidna_nameToASCIINative, uidna_nameToASCIIDart>('uidna_nameToASCII');
// idna : UIDNA* -> Pointer<IntPtr>
// name : WORD* -> Pointer<Uint16>
// length : INT -> Int32
// dest : WORD* in/out -> Pointer<Uint16>
// capacity : INT -> Int32
// pInfo : UIDNAInfo* in/out -> Pointer<Void>
// pErrorCode : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function uidna_nameToASCII(
idna: Pointer; // UIDNA*
name: 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_nameToASCII';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "uidna_nameToASCII"
c_uidna_nameToASCII :: Ptr CIntPtr -> Ptr Word16 -> Int32 -> Ptr Word16 -> Int32 -> Ptr () -> Ptr Int32 -> IO Int32
-- idna : UIDNA* -> Ptr CIntPtr
-- name : WORD* -> Ptr Word16
-- length : INT -> Int32
-- dest : WORD* in/out -> Ptr Word16
-- capacity : INT -> Int32
-- pInfo : UIDNAInfo* in/out -> Ptr ()
-- pErrorCode : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let uidna_nametoascii =
foreign "uidna_nameToASCII"
((ptr intptr_t) @-> (ptr uint16_t) @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> (ptr void) @-> (ptr int32_t) @-> returning int32_t)
(* idna : UIDNA* -> (ptr intptr_t) *)
(* name : WORD* -> (ptr uint16_t) *)
(* length : INT -> int32_t *)
(* dest : WORD* in/out -> (ptr uint16_t) *)
(* capacity : INT -> int32_t *)
(* pInfo : UIDNAInfo* in/out -> (ptr void) *)
(* pErrorCode : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)
(cffi:defcfun ("uidna_nameToASCII" uidna-name-to-ascii :convention :cdecl) :int32
(idna :pointer) ; UIDNA*
(name :pointer) ; WORD*
(length :int32) ; INT
(dest :pointer) ; WORD* in/out
(capacity :int32) ; INT
(p-info :pointer) ; UIDNAInfo* in/out
(p-error-code :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $uidna_nameToASCII = Win32::API::More->new('icuuc',
'int uidna_nameToASCII(LPVOID idna, LPVOID name, int length, LPVOID dest, int capacity, LPVOID pInfo, LPVOID pErrorCode)');
# my $ret = $uidna_nameToASCII->Call($idna, $name, $length, $dest, $capacity, $pInfo, $pErrorCode);
# idna : UIDNA* -> LPVOID
# name : WORD* -> LPVOID
# length : INT -> int
# dest : WORD* in/out -> LPVOID
# capacity : INT -> int
# pInfo : UIDNAInfo* in/out -> LPVOID
# pErrorCode : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。