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

UCNV_TO_U_CALLBACK_ESCAPE

関数
Unicodeへの変換失敗時にエスケープ表記へ置換するコールバック。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

void UCNV_TO_U_CALLBACK_ESCAPE(
    const void* context,
    UConverterToUnicodeArgs* toUArgs,
    LPCSTR codeUnits,
    INT length,
    UConverterCallbackReason reason,
    UErrorCode* err
);

パラメーター

名前方向
contextvoid*in
toUArgsUConverterToUnicodeArgs*inout
codeUnitsLPCSTRin
lengthINTin
reasonUConverterCallbackReasonin
errUErrorCode*inout

戻り値の型: void

各言語での呼び出し定義

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

void UCNV_TO_U_CALLBACK_ESCAPE(
    const void* context,
    UConverterToUnicodeArgs* toUArgs,
    LPCSTR codeUnits,
    INT length,
    UConverterCallbackReason reason,
    UErrorCode* err
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern void UCNV_TO_U_CALLBACK_ESCAPE(
    IntPtr context,   // void*
    IntPtr toUArgs,   // UConverterToUnicodeArgs* in/out
    [MarshalAs(UnmanagedType.LPStr)] string codeUnits,   // LPCSTR
    int length,   // INT
    int reason,   // UConverterCallbackReason
    ref int err   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Sub UCNV_TO_U_CALLBACK_ESCAPE(
    context As IntPtr,   ' void*
    toUArgs As IntPtr,   ' UConverterToUnicodeArgs* in/out
    <MarshalAs(UnmanagedType.LPStr)> codeUnits As String,   ' LPCSTR
    length As Integer,   ' INT
    reason As Integer,   ' UConverterCallbackReason
    ByRef err As Integer   ' UErrorCode* in/out
)
End Sub
' context : void*
' toUArgs : UConverterToUnicodeArgs* in/out
' codeUnits : LPCSTR
' length : INT
' reason : UConverterCallbackReason
' err : UErrorCode* in/out
Declare PtrSafe Sub UCNV_TO_U_CALLBACK_ESCAPE Lib "icuuc" ( _
    ByVal context As LongPtr, _
    ByVal toUArgs As LongPtr, _
    ByVal codeUnits As String, _
    ByVal length As Long, _
    ByVal reason As Long, _
    ByRef err As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

UCNV_TO_U_CALLBACK_ESCAPE = ctypes.cdll.icuuc.UCNV_TO_U_CALLBACK_ESCAPE
UCNV_TO_U_CALLBACK_ESCAPE.restype = None
UCNV_TO_U_CALLBACK_ESCAPE.argtypes = [
    ctypes.POINTER(None),  # context : void*
    ctypes.c_void_p,  # toUArgs : UConverterToUnicodeArgs* in/out
    wintypes.LPCSTR,  # codeUnits : LPCSTR
    ctypes.c_int,  # length : INT
    ctypes.c_int,  # reason : UConverterCallbackReason
    ctypes.c_void_p,  # err : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
UCNV_TO_U_CALLBACK_ESCAPE = Fiddle::Function.new(
  lib['UCNV_TO_U_CALLBACK_ESCAPE'],
  [
    Fiddle::TYPE_VOIDP,  # context : void*
    Fiddle::TYPE_VOIDP,  # toUArgs : UConverterToUnicodeArgs* in/out
    Fiddle::TYPE_VOIDP,  # codeUnits : LPCSTR
    Fiddle::TYPE_INT,  # length : INT
    Fiddle::TYPE_INT,  # reason : UConverterCallbackReason
    Fiddle::TYPE_VOIDP,  # err : UErrorCode* in/out
  ],
  Fiddle::TYPE_VOID, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn UCNV_TO_U_CALLBACK_ESCAPE(
        context: *const (),  // void*
        toUArgs: *mut UConverterToUnicodeArgs,  // UConverterToUnicodeArgs* in/out
        codeUnits: *const u8,  // LPCSTR
        length: i32,  // INT
        reason: i32,  // UConverterCallbackReason
        err: *mut i32  // UErrorCode* in/out
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void UCNV_TO_U_CALLBACK_ESCAPE(IntPtr context, IntPtr toUArgs, [MarshalAs(UnmanagedType.LPStr)] string codeUnits, int length, int reason, ref int err);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_UCNV_TO_U_CALLBACK_ESCAPE' -Namespace Win32 -PassThru
# $api::UCNV_TO_U_CALLBACK_ESCAPE(context, toUArgs, codeUnits, length, reason, err)
#uselib "icuuc.dll"
#func global UCNV_TO_U_CALLBACK_ESCAPE "UCNV_TO_U_CALLBACK_ESCAPE" sptr, sptr, sptr, sptr, sptr, sptr
; UCNV_TO_U_CALLBACK_ESCAPE context, varptr(toUArgs), codeUnits, length, reason, err
; context : void* -> "sptr"
; toUArgs : UConverterToUnicodeArgs* in/out -> "sptr"
; codeUnits : LPCSTR -> "sptr"
; length : INT -> "sptr"
; reason : UConverterCallbackReason -> "sptr"
; err : UErrorCode* in/out -> "sptr"
出力引数:
#uselib "icuuc.dll"
#func global UCNV_TO_U_CALLBACK_ESCAPE "UCNV_TO_U_CALLBACK_ESCAPE" sptr, var, str, int, int, int
; UCNV_TO_U_CALLBACK_ESCAPE context, toUArgs, codeUnits, length, reason, err
; context : void* -> "sptr"
; toUArgs : UConverterToUnicodeArgs* in/out -> "var"
; codeUnits : LPCSTR -> "str"
; length : INT -> "int"
; reason : UConverterCallbackReason -> "int"
; err : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void UCNV_TO_U_CALLBACK_ESCAPE(void* context, UConverterToUnicodeArgs* toUArgs, LPCSTR codeUnits, INT length, UConverterCallbackReason reason, UErrorCode* err)
#uselib "icuuc.dll"
#func global UCNV_TO_U_CALLBACK_ESCAPE "UCNV_TO_U_CALLBACK_ESCAPE" intptr, var, str, int, int, int
; UCNV_TO_U_CALLBACK_ESCAPE context, toUArgs, codeUnits, length, reason, err
; context : void* -> "intptr"
; toUArgs : UConverterToUnicodeArgs* in/out -> "var"
; codeUnits : LPCSTR -> "str"
; length : INT -> "int"
; reason : UConverterCallbackReason -> "int"
; err : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procUCNV_TO_U_CALLBACK_ESCAPE = icuuc.NewProc("UCNV_TO_U_CALLBACK_ESCAPE")
)

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