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

uspoof_openFromSource

関数
混同文字定義データから検査オブジェクトを生成する。
DLLicuin.dll呼出規約cdecl

シグネチャ

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

USpoofChecker* uspoof_openFromSource(
    LPCSTR confusables,
    INT confusablesLen,
    LPCSTR confusablesWholeScript,
    INT confusablesWholeScriptLen,
    INT* errType,
    UParseError* pe,
    UErrorCode* status
);

パラメーター

名前方向説明
confusablesLPCSTRinconfusables.txtの内容を保持するUTF-8文字列へのポインター。
confusablesLenINTinconfusablesデータの長さ。NUL終端なら-1を指定可能。
confusablesWholeScriptLPCSTRinconfusablesWholeScript.txtの内容を保持するUTF-8文字列へのポインター。
confusablesWholeScriptLenINTinconfusablesWholeScriptデータの長さ。NUL終端なら-1を指定可能。
errTypeINT*inout解析エラー種別(USPOOF_SINGLE_SCRIPT_CONFUSABLE等)を受け取る出力ポインター。
peUParseError*inout解析エラーの行・桁位置を受け取るUParseError構造体へのポインター。NULL可。
statusUErrorCode*inoutICUのエラーコードを入出力するUErrorCodeへのポインター。

戻り値の型: USpoofChecker*

各言語での呼び出し定義

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

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

uspoof_openFromSource = ctypes.cdll.icuin.uspoof_openFromSource
uspoof_openFromSource.restype = ctypes.c_void_p
uspoof_openFromSource.argtypes = [
    wintypes.LPCSTR,  # confusables : LPCSTR
    ctypes.c_int,  # confusablesLen : INT
    wintypes.LPCSTR,  # confusablesWholeScript : LPCSTR
    ctypes.c_int,  # confusablesWholeScriptLen : INT
    ctypes.POINTER(ctypes.c_int),  # errType : INT* in/out
    ctypes.c_void_p,  # pe : UParseError* in/out
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	icuin = windows.NewLazySystemDLL("icuin.dll")
	procuspoof_openFromSource = icuin.NewProc("uspoof_openFromSource")
)

// confusables (LPCSTR), confusablesLen (INT), confusablesWholeScript (LPCSTR), confusablesWholeScriptLen (INT), errType (INT* in/out), pe (UParseError* in/out), status (UErrorCode* in/out)
r1, _, err := procuspoof_openFromSource.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(confusables))),
	uintptr(confusablesLen),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(confusablesWholeScript))),
	uintptr(confusablesWholeScriptLen),
	uintptr(errType),
	uintptr(pe),
	uintptr(status),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // USpoofChecker*
function uspoof_openFromSource(
  confusables: PAnsiChar;   // LPCSTR
  confusablesLen: Integer;   // INT
  confusablesWholeScript: PAnsiChar;   // LPCSTR
  confusablesWholeScriptLen: Integer;   // INT
  errType: Pointer;   // INT* in/out
  pe: Pointer;   // UParseError* in/out
  status: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icuin.dll' name 'uspoof_openFromSource';
result := DllCall("icuin\uspoof_openFromSource"
    , "AStr", confusables   ; LPCSTR
    , "Int", confusablesLen   ; INT
    , "AStr", confusablesWholeScript   ; LPCSTR
    , "Int", confusablesWholeScriptLen   ; INT
    , "Ptr", errType   ; INT* in/out
    , "Ptr", pe   ; UParseError* in/out
    , "Ptr", status   ; UErrorCode* in/out
    , "Cdecl Ptr")   ; return: USpoofChecker*
●uspoof_openFromSource(confusables, confusablesLen, confusablesWholeScript, confusablesWholeScriptLen, errType, pe, status) = DLL("icuin.dll", "void* uspoof_openFromSource(char*, int, char*, int, void*, void*, void*)")
# 呼び出し: uspoof_openFromSource(confusables, confusablesLen, confusablesWholeScript, confusablesWholeScriptLen, errType, pe, status)
# confusables : LPCSTR -> "char*"
# confusablesLen : INT -> "int"
# confusablesWholeScript : LPCSTR -> "char*"
# confusablesWholeScriptLen : INT -> "int"
# errType : INT* in/out -> "void*"
# pe : UParseError* in/out -> "void*"
# status : 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 "icuin" fn uspoof_openFromSource(
    confusables: [*c]const u8, // LPCSTR
    confusablesLen: i32, // INT
    confusablesWholeScript: [*c]const u8, // LPCSTR
    confusablesWholeScriptLen: i32, // INT
    errType: [*c]i32, // INT* in/out
    pe: [*c]UParseError, // UParseError* in/out
    status: [*c]i32 // UErrorCode* in/out
) callconv(.c) [*c]isize;
proc uspoof_openFromSource(
    confusables: cstring,  # LPCSTR
    confusablesLen: int32,  # INT
    confusablesWholeScript: cstring,  # LPCSTR
    confusablesWholeScriptLen: int32,  # INT
    errType: ptr int32,  # INT* in/out
    pe: ptr UParseError,  # UParseError* in/out
    status: ptr int32  # UErrorCode* in/out
): ptr int {.importc: "uspoof_openFromSource", cdecl, dynlib: "icuin.dll".}
pragma(lib, "icuin");
extern(C)
ptrdiff_t* uspoof_openFromSource(
    const(char)* confusables,   // LPCSTR
    int confusablesLen,   // INT
    const(char)* confusablesWholeScript,   // LPCSTR
    int confusablesWholeScriptLen,   // INT
    int* errType,   // INT* in/out
    UParseError* pe,   // UParseError* in/out
    int* status   // UErrorCode* in/out
);
ccall((:uspoof_openFromSource, "icuin.dll"), Ptr{Int},
      (Cstring, Int32, Cstring, Int32, Ptr{Int32}, Ptr{UParseError}, Ptr{Int32}),
      confusables, confusablesLen, confusablesWholeScript, confusablesWholeScriptLen, errType, pe, status)
# confusables : LPCSTR -> Cstring
# confusablesLen : INT -> Int32
# confusablesWholeScript : LPCSTR -> Cstring
# confusablesWholeScriptLen : INT -> Int32
# errType : INT* in/out -> Ptr{Int32}
# pe : UParseError* in/out -> Ptr{UParseError}
# status : UErrorCode* in/out -> Ptr{Int32}
local ffi = require("ffi")
ffi.cdef[[
intptr_t* uspoof_openFromSource(
    const char* confusables,
    int32_t confusablesLen,
    const char* confusablesWholeScript,
    int32_t confusablesWholeScriptLen,
    int32_t* errType,
    void* pe,
    int32_t* status);
]]
local icuin = ffi.load("icuin")
-- icuin.uspoof_openFromSource(confusables, confusablesLen, confusablesWholeScript, confusablesWholeScriptLen, errType, pe, status)
-- confusables : LPCSTR
-- confusablesLen : INT
-- confusablesWholeScript : LPCSTR
-- confusablesWholeScriptLen : INT
-- errType : INT* in/out
-- pe : UParseError* in/out
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuin.dll');
const uspoof_openFromSource = lib.func('__cdecl', 'uspoof_openFromSource', 'intptr_t *', ['str', 'int32_t', 'str', 'int32_t', 'int32_t *', 'void *', 'int32_t *']);
// uspoof_openFromSource(confusables, confusablesLen, confusablesWholeScript, confusablesWholeScriptLen, errType, pe, status)
// confusables : LPCSTR -> 'str'
// confusablesLen : INT -> 'int32_t'
// confusablesWholeScript : LPCSTR -> 'str'
// confusablesWholeScriptLen : INT -> 'int32_t'
// errType : INT* in/out -> 'int32_t *'
// pe : UParseError* in/out -> 'void *'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuin.dll", {
  uspoof_openFromSource: { parameters: ["buffer", "i32", "buffer", "i32", "pointer", "pointer", "pointer"], result: "pointer" },
});
// lib.symbols.uspoof_openFromSource(confusables, confusablesLen, confusablesWholeScript, confusablesWholeScriptLen, errType, pe, status)
// confusables : LPCSTR -> "buffer"
// confusablesLen : INT -> "i32"
// confusablesWholeScript : LPCSTR -> "buffer"
// confusablesWholeScriptLen : INT -> "i32"
// errType : INT* in/out -> "pointer"
// pe : UParseError* in/out -> "pointer"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
intptr_t* uspoof_openFromSource(
    const char* confusables,
    int32_t confusablesLen,
    const char* confusablesWholeScript,
    int32_t confusablesWholeScriptLen,
    int32_t* errType,
    void* pe,
    int32_t* status);
C, "icuin.dll");
// $ffi->uspoof_openFromSource(confusables, confusablesLen, confusablesWholeScript, confusablesWholeScriptLen, errType, pe, status);
// confusables : LPCSTR
// confusablesLen : INT
// confusablesWholeScript : LPCSTR
// confusablesWholeScriptLen : INT
// errType : INT* in/out
// pe : UParseError* in/out
// status : 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 Icuin extends Library {
    Icuin INSTANCE = Native.load("icuin", Icuin.class);
    Pointer uspoof_openFromSource(
        String confusables,   // LPCSTR
        int confusablesLen,   // INT
        String confusablesWholeScript,   // LPCSTR
        int confusablesWholeScriptLen,   // INT
        IntByReference errType,   // INT* in/out
        Pointer pe,   // UParseError* in/out
        IntByReference status   // UErrorCode* in/out
    );
}
@[Link("icuin")]
lib Libicuin
  fun uspoof_openFromSource = uspoof_openFromSource(
    confusables : UInt8*,   # LPCSTR
    confusablesLen : Int32,   # INT
    confusablesWholeScript : UInt8*,   # LPCSTR
    confusablesWholeScriptLen : Int32,   # INT
    errType : Int32*,   # INT* in/out
    pe : UParseError*,   # UParseError* in/out
    status : Int32*   # UErrorCode* in/out
  ) : LibC::SSizeT*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef uspoof_openFromSourceNative = Pointer<IntPtr> Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Int32>, Pointer<Void>, Pointer<Int32>);
typedef uspoof_openFromSourceDart = Pointer<IntPtr> Function(Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Int32>, Pointer<Void>, Pointer<Int32>);
final uspoof_openFromSource = DynamicLibrary.open('icuin.dll')
    .lookupFunction<uspoof_openFromSourceNative, uspoof_openFromSourceDart>('uspoof_openFromSource');
// confusables : LPCSTR -> Pointer<Utf8>
// confusablesLen : INT -> Int32
// confusablesWholeScript : LPCSTR -> Pointer<Utf8>
// confusablesWholeScriptLen : INT -> Int32
// errType : INT* in/out -> Pointer<Int32>
// pe : UParseError* in/out -> Pointer<Void>
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function uspoof_openFromSource(
  confusables: PAnsiChar;   // LPCSTR
  confusablesLen: Integer;   // INT
  confusablesWholeScript: PAnsiChar;   // LPCSTR
  confusablesWholeScriptLen: Integer;   // INT
  errType: Pointer;   // INT* in/out
  pe: Pointer;   // UParseError* in/out
  status: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icuin.dll' name 'uspoof_openFromSource';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "uspoof_openFromSource"
  c_uspoof_openFromSource :: CString -> Int32 -> CString -> Int32 -> Ptr Int32 -> Ptr () -> Ptr Int32 -> IO (Ptr CIntPtr)
-- confusables : LPCSTR -> CString
-- confusablesLen : INT -> Int32
-- confusablesWholeScript : LPCSTR -> CString
-- confusablesWholeScriptLen : INT -> Int32
-- errType : INT* in/out -> Ptr Int32
-- pe : UParseError* in/out -> Ptr ()
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let uspoof_openfromsource =
  foreign "uspoof_openFromSource"
    (string @-> int32_t @-> string @-> int32_t @-> (ptr int32_t) @-> (ptr void) @-> (ptr int32_t) @-> returning (ptr intptr_t))
(* confusables : LPCSTR -> string *)
(* confusablesLen : INT -> int32_t *)
(* confusablesWholeScript : LPCSTR -> string *)
(* confusablesWholeScriptLen : INT -> int32_t *)
(* errType : INT* in/out -> (ptr int32_t) *)
(* pe : UParseError* in/out -> (ptr void) *)
(* status : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library icuin (t "icuin.dll"))
(cffi:use-foreign-library icuin)

(cffi:defcfun ("uspoof_openFromSource" uspoof-open-from-source :convention :cdecl) :pointer
  (confusables :string)   ; LPCSTR
  (confusables-len :int32)   ; INT
  (confusables-whole-script :string)   ; LPCSTR
  (confusables-whole-script-len :int32)   ; INT
  (err-type :pointer)   ; INT* in/out
  (pe :pointer)   ; UParseError* in/out
  (status :pointer))   ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $uspoof_openFromSource = Win32::API::More->new('icuin',
    'LPVOID uspoof_openFromSource(LPCSTR confusables, int confusablesLen, LPCSTR confusablesWholeScript, int confusablesWholeScriptLen, LPVOID errType, LPVOID pe, LPVOID status)');
# my $ret = $uspoof_openFromSource->Call($confusables, $confusablesLen, $confusablesWholeScript, $confusablesWholeScriptLen, $errType, $pe, $status);
# confusables : LPCSTR -> LPCSTR
# confusablesLen : INT -> int
# confusablesWholeScript : LPCSTR -> LPCSTR
# confusablesWholeScriptLen : INT -> int
# errType : INT* in/out -> LPVOID
# pe : UParseError* in/out -> LPVOID
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型