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

uspoof_checkUTF8

関数
UTF-8文字列のなりすまし可能性を検査する。
DLLicuin.dll呼出規約cdecl

シグネチャ

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

INT uspoof_checkUTF8(
    const USpoofChecker* sc,
    LPCSTR id,
    INT length,
    INT* position,
    UErrorCode* status
);

パラメーター

名前方向
scUSpoofChecker*in
idLPCSTRin
lengthINTin
positionINT*inout
statusUErrorCode*inout

戻り値の型: INT

各言語での呼び出し定義

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

INT uspoof_checkUTF8(
    const USpoofChecker* sc,
    LPCSTR id,
    INT length,
    INT* position,
    UErrorCode* status
);
[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int uspoof_checkUTF8(
    ref IntPtr sc,   // USpoofChecker*
    [MarshalAs(UnmanagedType.LPStr)] string id,   // LPCSTR
    int length,   // INT
    ref int position,   // INT* in/out
    ref int status   // UErrorCode* in/out
);
<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function uspoof_checkUTF8(
    ByRef sc As IntPtr,   ' USpoofChecker*
    <MarshalAs(UnmanagedType.LPStr)> id As String,   ' LPCSTR
    length As Integer,   ' INT
    ByRef position As Integer,   ' INT* in/out
    ByRef status As Integer   ' UErrorCode* in/out
) As Integer
End Function
' sc : USpoofChecker*
' id : LPCSTR
' length : INT
' position : INT* in/out
' status : UErrorCode* in/out
Declare PtrSafe Function uspoof_checkUTF8 Lib "icuin" ( _
    ByRef sc As LongPtr, _
    ByVal id As String, _
    ByVal length As Long, _
    ByRef position As Long, _
    ByRef status As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

uspoof_checkUTF8 = ctypes.cdll.icuin.uspoof_checkUTF8
uspoof_checkUTF8.restype = ctypes.c_int
uspoof_checkUTF8.argtypes = [
    ctypes.c_void_p,  # sc : USpoofChecker*
    wintypes.LPCSTR,  # id : LPCSTR
    ctypes.c_int,  # length : INT
    ctypes.POINTER(ctypes.c_int),  # position : INT* in/out
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuin.dll')
uspoof_checkUTF8 = Fiddle::Function.new(
  lib['uspoof_checkUTF8'],
  [
    Fiddle::TYPE_VOIDP,  # sc : USpoofChecker*
    Fiddle::TYPE_VOIDP,  # id : LPCSTR
    Fiddle::TYPE_INT,  # length : INT
    Fiddle::TYPE_VOIDP,  # position : INT* in/out
    Fiddle::TYPE_VOIDP,  # status : UErrorCode* in/out
  ],
  Fiddle::TYPE_INT, Fiddle::Function::CDECL)
#[link(name = "icuin")]
extern "C" {
    fn uspoof_checkUTF8(
        sc: *const isize,  // USpoofChecker*
        id: *const u8,  // LPCSTR
        length: i32,  // INT
        position: *mut i32,  // INT* in/out
        status: *mut i32  // UErrorCode* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuin.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int uspoof_checkUTF8(ref IntPtr sc, [MarshalAs(UnmanagedType.LPStr)] string id, int length, ref int position, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_uspoof_checkUTF8' -Namespace Win32 -PassThru
# $api::uspoof_checkUTF8(sc, id, length, position, status)
#uselib "icuin.dll"
#func global uspoof_checkUTF8 "uspoof_checkUTF8" sptr, sptr, sptr, sptr, sptr
; uspoof_checkUTF8 sc, id, length, varptr(position), status   ; 戻り値は stat
; sc : USpoofChecker* -> "sptr"
; id : LPCSTR -> "sptr"
; length : INT -> "sptr"
; position : INT* in/out -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuin.dll"
#cfunc global uspoof_checkUTF8 "uspoof_checkUTF8" int, str, int, var, int
; res = uspoof_checkUTF8(sc, id, length, position, status)
; sc : USpoofChecker* -> "int"
; id : LPCSTR -> "str"
; length : INT -> "int"
; position : INT* in/out -> "var"
; status : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT uspoof_checkUTF8(USpoofChecker* sc, LPCSTR id, INT length, INT* position, UErrorCode* status)
#uselib "icuin.dll"
#cfunc global uspoof_checkUTF8 "uspoof_checkUTF8" int, str, int, var, int
; res = uspoof_checkUTF8(sc, id, length, position, status)
; sc : USpoofChecker* -> "int"
; id : LPCSTR -> "str"
; length : INT -> "int"
; position : INT* in/out -> "var"
; status : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuin = windows.NewLazySystemDLL("icuin.dll")
	procuspoof_checkUTF8 = icuin.NewProc("uspoof_checkUTF8")
)

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