ホーム › Globalization › u_vformatMessageWithError
u_vformatMessageWithError
関数可変引数でメッセージ整形しエラー情報も返す。
シグネチャ
// icuin.dll
#include <windows.h>
INT u_vformatMessageWithError(
LPCSTR locale,
const WORD* pattern,
INT patternLength,
WORD* result,
INT resultLength,
UParseError* parseError,
CHAR* ap,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| locale | LPCSTR | in |
| pattern | WORD* | in |
| patternLength | INT | in |
| result | WORD* | inout |
| resultLength | INT | in |
| parseError | UParseError* | inout |
| ap | CHAR* | inout |
| status | UErrorCode* | inout |
戻り値の型: INT
各言語での呼び出し定義
// icuin.dll
#include <windows.h>
INT u_vformatMessageWithError(
LPCSTR locale,
const WORD* pattern,
INT patternLength,
WORD* result,
INT resultLength,
UParseError* parseError,
CHAR* ap,
UErrorCode* status
);[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int u_vformatMessageWithError(
[MarshalAs(UnmanagedType.LPStr)] string locale, // LPCSTR
ref ushort pattern, // WORD*
int patternLength, // INT
ref ushort result, // WORD* in/out
int resultLength, // INT
IntPtr parseError, // UParseError* in/out
IntPtr ap, // CHAR* in/out
ref int status // UErrorCode* in/out
);<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function u_vformatMessageWithError(
<MarshalAs(UnmanagedType.LPStr)> locale As String, ' LPCSTR
ByRef pattern As UShort, ' WORD*
patternLength As Integer, ' INT
ByRef result As UShort, ' WORD* in/out
resultLength As Integer, ' INT
parseError As IntPtr, ' UParseError* in/out
ap As IntPtr, ' CHAR* in/out
ByRef status As Integer ' UErrorCode* in/out
) As Integer
End Function' locale : LPCSTR
' pattern : WORD*
' patternLength : INT
' result : WORD* in/out
' resultLength : INT
' parseError : UParseError* in/out
' ap : CHAR* in/out
' status : UErrorCode* in/out
Declare PtrSafe Function u_vformatMessageWithError Lib "icuin" ( _
ByVal locale As String, _
ByRef pattern As Integer, _
ByVal patternLength As Long, _
ByRef result As Integer, _
ByVal resultLength As Long, _
ByVal parseError As LongPtr, _
ByVal ap As LongPtr, _
ByRef status As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
u_vformatMessageWithError = ctypes.cdll.icuin.u_vformatMessageWithError
u_vformatMessageWithError.restype = ctypes.c_int
u_vformatMessageWithError.argtypes = [
wintypes.LPCSTR, # locale : LPCSTR
ctypes.POINTER(ctypes.c_ushort), # pattern : WORD*
ctypes.c_int, # patternLength : INT
ctypes.POINTER(ctypes.c_ushort), # result : WORD* in/out
ctypes.c_int, # resultLength : INT
ctypes.c_void_p, # parseError : UParseError* in/out
ctypes.POINTER(ctypes.c_byte), # ap : CHAR* in/out
ctypes.c_void_p, # status : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuin.dll')
u_vformatMessageWithError = Fiddle::Function.new(
lib['u_vformatMessageWithError'],
[
Fiddle::TYPE_VOIDP, # locale : LPCSTR
Fiddle::TYPE_VOIDP, # pattern : WORD*
Fiddle::TYPE_INT, # patternLength : INT
Fiddle::TYPE_VOIDP, # result : WORD* in/out
Fiddle::TYPE_INT, # resultLength : INT
Fiddle::TYPE_VOIDP, # parseError : UParseError* in/out
Fiddle::TYPE_VOIDP, # ap : CHAR* in/out
Fiddle::TYPE_VOIDP, # status : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuin")]
extern "C" {
fn u_vformatMessageWithError(
locale: *const u8, // LPCSTR
pattern: *const u16, // WORD*
patternLength: i32, // INT
result: *mut u16, // WORD* in/out
resultLength: i32, // INT
parseError: *mut UParseError, // UParseError* in/out
ap: *mut i8, // CHAR* in/out
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 u_vformatMessageWithError([MarshalAs(UnmanagedType.LPStr)] string locale, ref ushort pattern, int patternLength, ref ushort result, int resultLength, IntPtr parseError, IntPtr ap, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_u_vformatMessageWithError' -Namespace Win32 -PassThru
# $api::u_vformatMessageWithError(locale, pattern, patternLength, result, resultLength, parseError, ap, status)#uselib "icuin.dll"
#func global u_vformatMessageWithError "u_vformatMessageWithError" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; u_vformatMessageWithError locale, varptr(pattern), patternLength, varptr(result), resultLength, varptr(parseError), varptr(ap), status ; 戻り値は stat
; locale : LPCSTR -> "sptr"
; pattern : WORD* -> "sptr"
; patternLength : INT -> "sptr"
; result : WORD* in/out -> "sptr"
; resultLength : INT -> "sptr"
; parseError : UParseError* in/out -> "sptr"
; ap : CHAR* in/out -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuin.dll" #cfunc global u_vformatMessageWithError "u_vformatMessageWithError" str, var, int, var, int, var, var, int ; res = u_vformatMessageWithError(locale, pattern, patternLength, result, resultLength, parseError, ap, status) ; locale : LPCSTR -> "str" ; pattern : WORD* -> "var" ; patternLength : INT -> "int" ; result : WORD* in/out -> "var" ; resultLength : INT -> "int" ; parseError : UParseError* in/out -> "var" ; ap : CHAR* in/out -> "var" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuin.dll" #cfunc global u_vformatMessageWithError "u_vformatMessageWithError" str, sptr, int, sptr, int, sptr, sptr, int ; res = u_vformatMessageWithError(locale, varptr(pattern), patternLength, varptr(result), resultLength, varptr(parseError), varptr(ap), status) ; locale : LPCSTR -> "str" ; pattern : WORD* -> "sptr" ; patternLength : INT -> "int" ; result : WORD* in/out -> "sptr" ; resultLength : INT -> "int" ; parseError : UParseError* in/out -> "sptr" ; ap : CHAR* in/out -> "sptr" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT u_vformatMessageWithError(LPCSTR locale, WORD* pattern, INT patternLength, WORD* result, INT resultLength, UParseError* parseError, CHAR* ap, UErrorCode* status) #uselib "icuin.dll" #cfunc global u_vformatMessageWithError "u_vformatMessageWithError" str, var, int, var, int, var, var, int ; res = u_vformatMessageWithError(locale, pattern, patternLength, result, resultLength, parseError, ap, status) ; locale : LPCSTR -> "str" ; pattern : WORD* -> "var" ; patternLength : INT -> "int" ; result : WORD* in/out -> "var" ; resultLength : INT -> "int" ; parseError : UParseError* in/out -> "var" ; ap : CHAR* in/out -> "var" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT u_vformatMessageWithError(LPCSTR locale, WORD* pattern, INT patternLength, WORD* result, INT resultLength, UParseError* parseError, CHAR* ap, UErrorCode* status) #uselib "icuin.dll" #cfunc global u_vformatMessageWithError "u_vformatMessageWithError" str, intptr, int, intptr, int, intptr, intptr, int ; res = u_vformatMessageWithError(locale, varptr(pattern), patternLength, varptr(result), resultLength, varptr(parseError), varptr(ap), status) ; locale : LPCSTR -> "str" ; pattern : WORD* -> "intptr" ; patternLength : INT -> "int" ; result : WORD* in/out -> "intptr" ; resultLength : INT -> "int" ; parseError : UParseError* in/out -> "intptr" ; ap : CHAR* in/out -> "intptr" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuin = windows.NewLazySystemDLL("icuin.dll")
procu_vformatMessageWithError = icuin.NewProc("u_vformatMessageWithError")
)
// locale (LPCSTR), pattern (WORD*), patternLength (INT), result (WORD* in/out), resultLength (INT), parseError (UParseError* in/out), ap (CHAR* in/out), status (UErrorCode* in/out)
r1, _, err := procu_vformatMessageWithError.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(locale))),
uintptr(pattern),
uintptr(patternLength),
uintptr(result),
uintptr(resultLength),
uintptr(parseError),
uintptr(ap),
uintptr(status),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction u_vformatMessageWithError(
locale: PAnsiChar; // LPCSTR
pattern: Pointer; // WORD*
patternLength: Integer; // INT
result: Pointer; // WORD* in/out
resultLength: Integer; // INT
parseError: Pointer; // UParseError* in/out
ap: Pointer; // CHAR* in/out
status: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuin.dll' name 'u_vformatMessageWithError';result := DllCall("icuin\u_vformatMessageWithError"
, "AStr", locale ; LPCSTR
, "Ptr", pattern ; WORD*
, "Int", patternLength ; INT
, "Ptr", result ; WORD* in/out
, "Int", resultLength ; INT
, "Ptr", parseError ; UParseError* in/out
, "Ptr", ap ; CHAR* in/out
, "Ptr", status ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●u_vformatMessageWithError(locale, pattern, patternLength, result, resultLength, parseError, ap, status) = DLL("icuin.dll", "int u_vformatMessageWithError(char*, void*, int, void*, int, void*, void*, void*)")
# 呼び出し: u_vformatMessageWithError(locale, pattern, patternLength, result, resultLength, parseError, ap, status)
# locale : LPCSTR -> "char*"
# pattern : WORD* -> "void*"
# patternLength : INT -> "int"
# result : WORD* in/out -> "void*"
# resultLength : INT -> "int"
# parseError : UParseError* in/out -> "void*"
# ap : CHAR* in/out -> "void*"
# status : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。