ホーム › Globalization › UCNV_TO_U_CALLBACK_SKIP
UCNV_TO_U_CALLBACK_SKIP
関数Unicodeへの変換失敗時に該当バイトを無視するコールバック。
シグネチャ
// icuuc.dll
#include <windows.h>
void UCNV_TO_U_CALLBACK_SKIP(
const void* context,
UConverterToUnicodeArgs* toUArgs,
LPCSTR codeUnits,
INT length,
UConverterCallbackReason reason,
UErrorCode* err
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| context | void* | in |
| toUArgs | UConverterToUnicodeArgs* | inout |
| codeUnits | LPCSTR | in |
| length | INT | in |
| reason | UConverterCallbackReason | in |
| err | UErrorCode* | inout |
戻り値の型: void
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
void UCNV_TO_U_CALLBACK_SKIP(
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_SKIP(
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_SKIP(
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_SKIP 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_SKIP = ctypes.cdll.icuuc.UCNV_TO_U_CALLBACK_SKIP
UCNV_TO_U_CALLBACK_SKIP.restype = None
UCNV_TO_U_CALLBACK_SKIP.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_SKIP = Fiddle::Function.new(
lib['UCNV_TO_U_CALLBACK_SKIP'],
[
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_SKIP(
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_SKIP(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_SKIP' -Namespace Win32 -PassThru
# $api::UCNV_TO_U_CALLBACK_SKIP(context, toUArgs, codeUnits, length, reason, err)#uselib "icuuc.dll"
#func global UCNV_TO_U_CALLBACK_SKIP "UCNV_TO_U_CALLBACK_SKIP" sptr, sptr, sptr, sptr, sptr, sptr
; UCNV_TO_U_CALLBACK_SKIP 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_SKIP "UCNV_TO_U_CALLBACK_SKIP" sptr, var, str, int, int, int ; UCNV_TO_U_CALLBACK_SKIP 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 方式にも切替可。#uselib "icuuc.dll" #func global UCNV_TO_U_CALLBACK_SKIP "UCNV_TO_U_CALLBACK_SKIP" sptr, sptr, str, int, int, int ; UCNV_TO_U_CALLBACK_SKIP context, varptr(toUArgs), codeUnits, length, reason, err ; context : void* -> "sptr" ; toUArgs : UConverterToUnicodeArgs* in/out -> "sptr" ; codeUnits : LPCSTR -> "str" ; length : INT -> "int" ; reason : UConverterCallbackReason -> "int" ; err : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void UCNV_TO_U_CALLBACK_SKIP(void* context, UConverterToUnicodeArgs* toUArgs, LPCSTR codeUnits, INT length, UConverterCallbackReason reason, UErrorCode* err) #uselib "icuuc.dll" #func global UCNV_TO_U_CALLBACK_SKIP "UCNV_TO_U_CALLBACK_SKIP" intptr, var, str, int, int, int ; UCNV_TO_U_CALLBACK_SKIP 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 方式にも切替可。; void UCNV_TO_U_CALLBACK_SKIP(void* context, UConverterToUnicodeArgs* toUArgs, LPCSTR codeUnits, INT length, UConverterCallbackReason reason, UErrorCode* err) #uselib "icuuc.dll" #func global UCNV_TO_U_CALLBACK_SKIP "UCNV_TO_U_CALLBACK_SKIP" intptr, intptr, str, int, int, int ; UCNV_TO_U_CALLBACK_SKIP context, varptr(toUArgs), codeUnits, length, reason, err ; context : void* -> "intptr" ; toUArgs : UConverterToUnicodeArgs* in/out -> "intptr" ; codeUnits : LPCSTR -> "str" ; length : INT -> "int" ; reason : UConverterCallbackReason -> "int" ; err : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procUCNV_TO_U_CALLBACK_SKIP = icuuc.NewProc("UCNV_TO_U_CALLBACK_SKIP")
)
// context (void*), toUArgs (UConverterToUnicodeArgs* in/out), codeUnits (LPCSTR), length (INT), reason (UConverterCallbackReason), err (UErrorCode* in/out)
r1, _, err := procUCNV_TO_U_CALLBACK_SKIP.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 // voidprocedure UCNV_TO_U_CALLBACK_SKIP(
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_SKIP';result := DllCall("icuuc\UCNV_TO_U_CALLBACK_SKIP"
, "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_SKIP(context, toUArgs, codeUnits, length, reason, err) = DLL("icuuc.dll", "int UCNV_TO_U_CALLBACK_SKIP(void*, void*, char*, int, int, void*)")
# 呼び出し: UCNV_TO_U_CALLBACK_SKIP(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`,…) を使用。