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

uspoof_areConfusableUTF8

関数
二つのUTF-8文字列が混同しやすいか判定する。
DLLicuin.dll呼出規約cdecl

シグネチャ

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

INT uspoof_areConfusableUTF8(
    const USpoofChecker* sc,
    LPCSTR id1,
    INT length1,
    LPCSTR id2,
    INT length2,
    UErrorCode* status
);

パラメーター

名前方向
scUSpoofChecker*in
id1LPCSTRin
length1INTin
id2LPCSTRin
length2INTin
statusUErrorCode*inout

戻り値の型: INT

各言語での呼び出し定義

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

INT uspoof_areConfusableUTF8(
    const USpoofChecker* sc,
    LPCSTR id1,
    INT length1,
    LPCSTR id2,
    INT length2,
    UErrorCode* status
);
[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int uspoof_areConfusableUTF8(
    ref IntPtr sc,   // USpoofChecker*
    [MarshalAs(UnmanagedType.LPStr)] string id1,   // LPCSTR
    int length1,   // INT
    [MarshalAs(UnmanagedType.LPStr)] string id2,   // LPCSTR
    int length2,   // INT
    ref int status   // UErrorCode* in/out
);
<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function uspoof_areConfusableUTF8(
    ByRef sc As IntPtr,   ' USpoofChecker*
    <MarshalAs(UnmanagedType.LPStr)> id1 As String,   ' LPCSTR
    length1 As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPStr)> id2 As String,   ' LPCSTR
    length2 As Integer,   ' INT
    ByRef status As Integer   ' UErrorCode* in/out
) As Integer
End Function
' sc : USpoofChecker*
' id1 : LPCSTR
' length1 : INT
' id2 : LPCSTR
' length2 : INT
' status : UErrorCode* in/out
Declare PtrSafe Function uspoof_areConfusableUTF8 Lib "icuin" ( _
    ByRef sc As LongPtr, _
    ByVal id1 As String, _
    ByVal length1 As Long, _
    ByVal id2 As String, _
    ByVal length2 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_areConfusableUTF8 = ctypes.cdll.icuin.uspoof_areConfusableUTF8
uspoof_areConfusableUTF8.restype = ctypes.c_int
uspoof_areConfusableUTF8.argtypes = [
    ctypes.c_void_p,  # sc : USpoofChecker*
    wintypes.LPCSTR,  # id1 : LPCSTR
    ctypes.c_int,  # length1 : INT
    wintypes.LPCSTR,  # id2 : LPCSTR
    ctypes.c_int,  # length2 : INT
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuin.dll')
uspoof_areConfusableUTF8 = Fiddle::Function.new(
  lib['uspoof_areConfusableUTF8'],
  [
    Fiddle::TYPE_VOIDP,  # sc : USpoofChecker*
    Fiddle::TYPE_VOIDP,  # id1 : LPCSTR
    Fiddle::TYPE_INT,  # length1 : INT
    Fiddle::TYPE_VOIDP,  # id2 : LPCSTR
    Fiddle::TYPE_INT,  # length2 : INT
    Fiddle::TYPE_VOIDP,  # status : UErrorCode* in/out
  ],
  Fiddle::TYPE_INT, Fiddle::Function::CDECL)
#[link(name = "icuin")]
extern "C" {
    fn uspoof_areConfusableUTF8(
        sc: *const isize,  // USpoofChecker*
        id1: *const u8,  // LPCSTR
        length1: i32,  // INT
        id2: *const u8,  // LPCSTR
        length2: i32,  // INT
        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_areConfusableUTF8(ref IntPtr sc, [MarshalAs(UnmanagedType.LPStr)] string id1, int length1, [MarshalAs(UnmanagedType.LPStr)] string id2, int length2, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_uspoof_areConfusableUTF8' -Namespace Win32 -PassThru
# $api::uspoof_areConfusableUTF8(sc, id1, length1, id2, length2, status)
#uselib "icuin.dll"
#func global uspoof_areConfusableUTF8 "uspoof_areConfusableUTF8" sptr, sptr, sptr, sptr, sptr, sptr
; uspoof_areConfusableUTF8 sc, id1, length1, id2, length2, status   ; 戻り値は stat
; sc : USpoofChecker* -> "sptr"
; id1 : LPCSTR -> "sptr"
; length1 : INT -> "sptr"
; id2 : LPCSTR -> "sptr"
; length2 : INT -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "icuin.dll"
#cfunc global uspoof_areConfusableUTF8 "uspoof_areConfusableUTF8" int, str, int, str, int, int
; res = uspoof_areConfusableUTF8(sc, id1, length1, id2, length2, status)
; sc : USpoofChecker* -> "int"
; id1 : LPCSTR -> "str"
; length1 : INT -> "int"
; id2 : LPCSTR -> "str"
; length2 : INT -> "int"
; status : UErrorCode* in/out -> "int"
; INT uspoof_areConfusableUTF8(USpoofChecker* sc, LPCSTR id1, INT length1, LPCSTR id2, INT length2, UErrorCode* status)
#uselib "icuin.dll"
#cfunc global uspoof_areConfusableUTF8 "uspoof_areConfusableUTF8" int, str, int, str, int, int
; res = uspoof_areConfusableUTF8(sc, id1, length1, id2, length2, status)
; sc : USpoofChecker* -> "int"
; id1 : LPCSTR -> "str"
; length1 : INT -> "int"
; id2 : LPCSTR -> "str"
; length2 : INT -> "int"
; status : UErrorCode* in/out -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuin = windows.NewLazySystemDLL("icuin.dll")
	procuspoof_areConfusableUTF8 = icuin.NewProc("uspoof_areConfusableUTF8")
)

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