ホーム › Globalization › utf8_appendCharSafeBody
utf8_appendCharSafeBody
関数UTF-8バッファにコードポイントを安全に追加する。
シグネチャ
// icuuc.dll
#include <windows.h>
INT utf8_appendCharSafeBody(
BYTE* s,
INT i,
INT length,
INT c,
CHAR* pIsError
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| s | BYTE* | inout |
| i | INT | in |
| length | INT | in |
| c | INT | in |
| pIsError | CHAR* | inout |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT utf8_appendCharSafeBody(
BYTE* s,
INT i,
INT length,
INT c,
CHAR* pIsError
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int utf8_appendCharSafeBody(
IntPtr s, // BYTE* in/out
int i, // INT
int length, // INT
int c, // INT
IntPtr pIsError // CHAR* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function utf8_appendCharSafeBody(
s As IntPtr, ' BYTE* in/out
i As Integer, ' INT
length As Integer, ' INT
c As Integer, ' INT
pIsError As IntPtr ' CHAR* in/out
) As Integer
End Function' s : BYTE* in/out
' i : INT
' length : INT
' c : INT
' pIsError : CHAR* in/out
Declare PtrSafe Function utf8_appendCharSafeBody Lib "icuuc" ( _
ByVal s As LongPtr, _
ByVal i As Long, _
ByVal length As Long, _
ByVal c As Long, _
ByVal pIsError As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
utf8_appendCharSafeBody = ctypes.cdll.icuuc.utf8_appendCharSafeBody
utf8_appendCharSafeBody.restype = ctypes.c_int
utf8_appendCharSafeBody.argtypes = [
ctypes.POINTER(ctypes.c_ubyte), # s : BYTE* in/out
ctypes.c_int, # i : INT
ctypes.c_int, # length : INT
ctypes.c_int, # c : INT
ctypes.POINTER(ctypes.c_byte), # pIsError : CHAR* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
utf8_appendCharSafeBody = Fiddle::Function.new(
lib['utf8_appendCharSafeBody'],
[
Fiddle::TYPE_VOIDP, # s : BYTE* in/out
Fiddle::TYPE_INT, # i : INT
Fiddle::TYPE_INT, # length : INT
Fiddle::TYPE_INT, # c : INT
Fiddle::TYPE_VOIDP, # pIsError : CHAR* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn utf8_appendCharSafeBody(
s: *mut u8, // BYTE* in/out
i: i32, // INT
length: i32, // INT
c: i32, // INT
pIsError: *mut i8 // CHAR* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int utf8_appendCharSafeBody(IntPtr s, int i, int length, int c, IntPtr pIsError);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_utf8_appendCharSafeBody' -Namespace Win32 -PassThru
# $api::utf8_appendCharSafeBody(s, i, length, c, pIsError)#uselib "icuuc.dll"
#func global utf8_appendCharSafeBody "utf8_appendCharSafeBody" sptr, sptr, sptr, sptr, sptr
; utf8_appendCharSafeBody varptr(s), i, length, c, varptr(pIsError) ; 戻り値は stat
; s : BYTE* in/out -> "sptr"
; i : INT -> "sptr"
; length : INT -> "sptr"
; c : INT -> "sptr"
; pIsError : CHAR* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global utf8_appendCharSafeBody "utf8_appendCharSafeBody" var, int, int, int, var ; res = utf8_appendCharSafeBody(s, i, length, c, pIsError) ; s : BYTE* in/out -> "var" ; i : INT -> "int" ; length : INT -> "int" ; c : INT -> "int" ; pIsError : CHAR* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global utf8_appendCharSafeBody "utf8_appendCharSafeBody" sptr, int, int, int, sptr ; res = utf8_appendCharSafeBody(varptr(s), i, length, c, varptr(pIsError)) ; s : BYTE* in/out -> "sptr" ; i : INT -> "int" ; length : INT -> "int" ; c : INT -> "int" ; pIsError : CHAR* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT utf8_appendCharSafeBody(BYTE* s, INT i, INT length, INT c, CHAR* pIsError) #uselib "icuuc.dll" #cfunc global utf8_appendCharSafeBody "utf8_appendCharSafeBody" var, int, int, int, var ; res = utf8_appendCharSafeBody(s, i, length, c, pIsError) ; s : BYTE* in/out -> "var" ; i : INT -> "int" ; length : INT -> "int" ; c : INT -> "int" ; pIsError : CHAR* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT utf8_appendCharSafeBody(BYTE* s, INT i, INT length, INT c, CHAR* pIsError) #uselib "icuuc.dll" #cfunc global utf8_appendCharSafeBody "utf8_appendCharSafeBody" intptr, int, int, int, intptr ; res = utf8_appendCharSafeBody(varptr(s), i, length, c, varptr(pIsError)) ; s : BYTE* in/out -> "intptr" ; i : INT -> "int" ; length : INT -> "int" ; c : INT -> "int" ; pIsError : CHAR* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procutf8_appendCharSafeBody = icuuc.NewProc("utf8_appendCharSafeBody")
)
// s (BYTE* in/out), i (INT), length (INT), c (INT), pIsError (CHAR* in/out)
r1, _, err := procutf8_appendCharSafeBody.Call(
uintptr(s),
uintptr(i),
uintptr(length),
uintptr(c),
uintptr(pIsError),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction utf8_appendCharSafeBody(
s: Pointer; // BYTE* in/out
i: Integer; // INT
length: Integer; // INT
c: Integer; // INT
pIsError: Pointer // CHAR* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'utf8_appendCharSafeBody';result := DllCall("icuuc\utf8_appendCharSafeBody"
, "Ptr", s ; BYTE* in/out
, "Int", i ; INT
, "Int", length ; INT
, "Int", c ; INT
, "Ptr", pIsError ; CHAR* in/out
, "Cdecl Int") ; return: INT●utf8_appendCharSafeBody(s, i, length, c, pIsError) = DLL("icuuc.dll", "int utf8_appendCharSafeBody(void*, int, int, int, void*)")
# 呼び出し: utf8_appendCharSafeBody(s, i, length, c, pIsError)
# s : BYTE* in/out -> "void*"
# i : INT -> "int"
# length : INT -> "int"
# c : INT -> "int"
# pIsError : CHAR* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。