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

u_vparseMessageWithError

関数
可変引数でメッセージ解析しエラー情報も返す。
DLLicuin.dll呼出規約cdecl

シグネチャ

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

void u_vparseMessageWithError(
    LPCSTR locale,
    const WORD* pattern,
    INT patternLength,
    const WORD* source,
    INT sourceLength,
    CHAR* ap,
    UParseError* parseError,
    UErrorCode* status
);

パラメーター

名前方向説明
localeLPCSTRinメッセージ解析に用いるロケール名。NULLで既定ロケールを使用する。
patternWORD*inMessageFormat構文のパターン文字列。UTF-16のWORD配列で渡す。
patternLengthINTinパターンの長さ(UTF-16単位)。-1でNUL終端として扱う。
sourceWORD*in解析対象の入力文字列。UTF-16のWORD配列で指定する。
sourceLengthINTin入力文字列の長さ(UTF-16単位)。-1でNUL終端として扱う。
apCHAR*inout解析結果の格納先を指す可変個引数リスト(va_list)。
parseErrorUParseError*inoutパターン解析エラーの位置・内容を受け取る構造体。NULL可。
statusUErrorCode*inoutICUのエラーコード。呼び出し前に成功値で初期化する。

戻り値の型: void

各言語での呼び出し定義

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

void u_vparseMessageWithError(
    LPCSTR locale,
    const WORD* pattern,
    INT patternLength,
    const WORD* source,
    INT sourceLength,
    CHAR* ap,
    UParseError* parseError,
    UErrorCode* status
);
[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern void u_vparseMessageWithError(
    [MarshalAs(UnmanagedType.LPStr)] string locale,   // LPCSTR
    ref ushort pattern,   // WORD*
    int patternLength,   // INT
    ref ushort source,   // WORD*
    int sourceLength,   // INT
    IntPtr ap,   // CHAR* in/out
    IntPtr parseError,   // UParseError* in/out
    ref int status   // UErrorCode* in/out
);
<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Sub u_vparseMessageWithError(
    <MarshalAs(UnmanagedType.LPStr)> locale As String,   ' LPCSTR
    ByRef pattern As UShort,   ' WORD*
    patternLength As Integer,   ' INT
    ByRef source As UShort,   ' WORD*
    sourceLength As Integer,   ' INT
    ap As IntPtr,   ' CHAR* in/out
    parseError As IntPtr,   ' UParseError* in/out
    ByRef status As Integer   ' UErrorCode* in/out
)
End Sub
' locale : LPCSTR
' pattern : WORD*
' patternLength : INT
' source : WORD*
' sourceLength : INT
' ap : CHAR* in/out
' parseError : UParseError* in/out
' status : UErrorCode* in/out
Declare PtrSafe Sub u_vparseMessageWithError Lib "icuin" ( _
    ByVal locale As String, _
    ByRef pattern As Integer, _
    ByVal patternLength As Long, _
    ByRef source As Integer, _
    ByVal sourceLength As Long, _
    ByVal ap As LongPtr, _
    ByVal parseError As LongPtr, _
    ByRef status As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

u_vparseMessageWithError = ctypes.cdll.icuin.u_vparseMessageWithError
u_vparseMessageWithError.restype = None
u_vparseMessageWithError.argtypes = [
    wintypes.LPCSTR,  # locale : LPCSTR
    ctypes.POINTER(ctypes.c_ushort),  # pattern : WORD*
    ctypes.c_int,  # patternLength : INT
    ctypes.POINTER(ctypes.c_ushort),  # source : WORD*
    ctypes.c_int,  # sourceLength : INT
    ctypes.POINTER(ctypes.c_byte),  # ap : CHAR* in/out
    ctypes.c_void_p,  # parseError : UParseError* in/out
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuin.dll')
u_vparseMessageWithError = Fiddle::Function.new(
  lib['u_vparseMessageWithError'],
  [
    Fiddle::TYPE_VOIDP,  # locale : LPCSTR
    Fiddle::TYPE_VOIDP,  # pattern : WORD*
    Fiddle::TYPE_INT,  # patternLength : INT
    Fiddle::TYPE_VOIDP,  # source : WORD*
    Fiddle::TYPE_INT,  # sourceLength : INT
    Fiddle::TYPE_VOIDP,  # ap : CHAR* in/out
    Fiddle::TYPE_VOIDP,  # parseError : UParseError* in/out
    Fiddle::TYPE_VOIDP,  # status : UErrorCode* in/out
  ],
  Fiddle::TYPE_VOID, Fiddle::Function::CDECL)
#[link(name = "icuin")]
extern "C" {
    fn u_vparseMessageWithError(
        locale: *const u8,  // LPCSTR
        pattern: *const u16,  // WORD*
        patternLength: i32,  // INT
        source: *const u16,  // WORD*
        sourceLength: i32,  // INT
        ap: *mut i8,  // CHAR* in/out
        parseError: *mut UParseError,  // UParseError* in/out
        status: *mut i32  // UErrorCode* in/out
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuin.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void u_vparseMessageWithError([MarshalAs(UnmanagedType.LPStr)] string locale, ref ushort pattern, int patternLength, ref ushort source, int sourceLength, IntPtr ap, IntPtr parseError, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_u_vparseMessageWithError' -Namespace Win32 -PassThru
# $api::u_vparseMessageWithError(locale, pattern, patternLength, source, sourceLength, ap, parseError, status)
#uselib "icuin.dll"
#func global u_vparseMessageWithError "u_vparseMessageWithError" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; u_vparseMessageWithError locale, varptr(pattern), patternLength, varptr(source), sourceLength, varptr(ap), varptr(parseError), varptr(status)
; locale : LPCSTR -> "sptr"
; pattern : WORD* -> "sptr"
; patternLength : INT -> "sptr"
; source : WORD* -> "sptr"
; sourceLength : INT -> "sptr"
; ap : CHAR* in/out -> "sptr"
; parseError : UParseError* in/out -> "sptr"
; status : UErrorCode* in/out -> "sptr"
出力引数:
#uselib "icuin.dll"
#func global u_vparseMessageWithError "u_vparseMessageWithError" str, var, int, var, int, var, var, var
; u_vparseMessageWithError locale, pattern, patternLength, source, sourceLength, ap, parseError, status
; locale : LPCSTR -> "str"
; pattern : WORD* -> "var"
; patternLength : INT -> "int"
; source : WORD* -> "var"
; sourceLength : INT -> "int"
; ap : CHAR* in/out -> "var"
; parseError : UParseError* in/out -> "var"
; status : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void u_vparseMessageWithError(LPCSTR locale, WORD* pattern, INT patternLength, WORD* source, INT sourceLength, CHAR* ap, UParseError* parseError, UErrorCode* status)
#uselib "icuin.dll"
#func global u_vparseMessageWithError "u_vparseMessageWithError" str, var, int, var, int, var, var, var
; u_vparseMessageWithError locale, pattern, patternLength, source, sourceLength, ap, parseError, status
; locale : LPCSTR -> "str"
; pattern : WORD* -> "var"
; patternLength : INT -> "int"
; source : WORD* -> "var"
; sourceLength : INT -> "int"
; ap : CHAR* in/out -> "var"
; parseError : UParseError* in/out -> "var"
; status : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuin = windows.NewLazySystemDLL("icuin.dll")
	procu_vparseMessageWithError = icuin.NewProc("u_vparseMessageWithError")
)

// locale (LPCSTR), pattern (WORD*), patternLength (INT), source (WORD*), sourceLength (INT), ap (CHAR* in/out), parseError (UParseError* in/out), status (UErrorCode* in/out)
r1, _, err := procu_vparseMessageWithError.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(locale))),
	uintptr(pattern),
	uintptr(patternLength),
	uintptr(source),
	uintptr(sourceLength),
	uintptr(ap),
	uintptr(parseError),
	uintptr(status),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure u_vparseMessageWithError(
  locale: PAnsiChar;   // LPCSTR
  pattern: Pointer;   // WORD*
  patternLength: Integer;   // INT
  source: Pointer;   // WORD*
  sourceLength: Integer;   // INT
  ap: Pointer;   // CHAR* in/out
  parseError: Pointer;   // UParseError* in/out
  status: Pointer   // UErrorCode* in/out
); cdecl;
  external 'icuin.dll' name 'u_vparseMessageWithError';
result := DllCall("icuin\u_vparseMessageWithError"
    , "AStr", locale   ; LPCSTR
    , "Ptr", pattern   ; WORD*
    , "Int", patternLength   ; INT
    , "Ptr", source   ; WORD*
    , "Int", sourceLength   ; INT
    , "Ptr", ap   ; CHAR* in/out
    , "Ptr", parseError   ; UParseError* in/out
    , "Ptr", status   ; UErrorCode* in/out
    , "Cdecl Int")   ; return: void
●u_vparseMessageWithError(locale, pattern, patternLength, source, sourceLength, ap, parseError, status) = DLL("icuin.dll", "int u_vparseMessageWithError(char*, void*, int, void*, int, void*, void*, void*)")
# 呼び出し: u_vparseMessageWithError(locale, pattern, patternLength, source, sourceLength, ap, parseError, status)
# locale : LPCSTR -> "char*"
# pattern : WORD* -> "void*"
# patternLength : INT -> "int"
# source : WORD* -> "void*"
# sourceLength : INT -> "int"
# ap : CHAR* in/out -> "void*"
# parseError : 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 u_vparseMessageWithError(
    locale: [*c]const u8, // LPCSTR
    pattern: [*c]u16, // WORD*
    patternLength: i32, // INT
    source: [*c]u16, // WORD*
    sourceLength: i32, // INT
    ap: [*c]i8, // CHAR* in/out
    parseError: [*c]UParseError, // UParseError* in/out
    status: [*c]i32 // UErrorCode* in/out
) callconv(.c) void;
proc u_vparseMessageWithError(
    locale: cstring,  # LPCSTR
    pattern: ptr uint16,  # WORD*
    patternLength: int32,  # INT
    source: ptr uint16,  # WORD*
    sourceLength: int32,  # INT
    ap: ptr int8,  # CHAR* in/out
    parseError: ptr UParseError,  # UParseError* in/out
    status: ptr int32  # UErrorCode* in/out
) {.importc: "u_vparseMessageWithError", cdecl, dynlib: "icuin.dll".}
pragma(lib, "icuin");
extern(C)
void u_vparseMessageWithError(
    const(char)* locale,   // LPCSTR
    ushort* pattern,   // WORD*
    int patternLength,   // INT
    ushort* source,   // WORD*
    int sourceLength,   // INT
    byte* ap,   // CHAR* in/out
    UParseError* parseError,   // UParseError* in/out
    int* status   // UErrorCode* in/out
);
ccall((:u_vparseMessageWithError, "icuin.dll"), Cvoid,
      (Cstring, Ptr{UInt16}, Int32, Ptr{UInt16}, Int32, Ptr{Int8}, Ptr{UParseError}, Ptr{Int32}),
      locale, pattern, patternLength, source, sourceLength, ap, parseError, status)
# locale : LPCSTR -> Cstring
# pattern : WORD* -> Ptr{UInt16}
# patternLength : INT -> Int32
# source : WORD* -> Ptr{UInt16}
# sourceLength : INT -> Int32
# ap : CHAR* in/out -> Ptr{Int8}
# parseError : UParseError* in/out -> Ptr{UParseError}
# status : UErrorCode* in/out -> Ptr{Int32}
local ffi = require("ffi")
ffi.cdef[[
void u_vparseMessageWithError(
    const char* locale,
    uint16_t* pattern,
    int32_t patternLength,
    uint16_t* source,
    int32_t sourceLength,
    int8_t* ap,
    void* parseError,
    int32_t* status);
]]
local icuin = ffi.load("icuin")
-- icuin.u_vparseMessageWithError(locale, pattern, patternLength, source, sourceLength, ap, parseError, status)
-- locale : LPCSTR
-- pattern : WORD*
-- patternLength : INT
-- source : WORD*
-- sourceLength : INT
-- ap : CHAR* in/out
-- parseError : UParseError* in/out
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuin.dll');
const u_vparseMessageWithError = lib.func('__cdecl', 'u_vparseMessageWithError', 'void', ['str', 'uint16_t *', 'int32_t', 'uint16_t *', 'int32_t', 'int8_t *', 'void *', 'int32_t *']);
// u_vparseMessageWithError(locale, pattern, patternLength, source, sourceLength, ap, parseError, status)
// locale : LPCSTR -> 'str'
// pattern : WORD* -> 'uint16_t *'
// patternLength : INT -> 'int32_t'
// source : WORD* -> 'uint16_t *'
// sourceLength : INT -> 'int32_t'
// ap : CHAR* in/out -> 'int8_t *'
// parseError : UParseError* in/out -> 'void *'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuin.dll", {
  u_vparseMessageWithError: { parameters: ["buffer", "pointer", "i32", "pointer", "i32", "pointer", "pointer", "pointer"], result: "void" },
});
// lib.symbols.u_vparseMessageWithError(locale, pattern, patternLength, source, sourceLength, ap, parseError, status)
// locale : LPCSTR -> "buffer"
// pattern : WORD* -> "pointer"
// patternLength : INT -> "i32"
// source : WORD* -> "pointer"
// sourceLength : INT -> "i32"
// ap : CHAR* in/out -> "pointer"
// parseError : UParseError* in/out -> "pointer"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void u_vparseMessageWithError(
    const char* locale,
    uint16_t* pattern,
    int32_t patternLength,
    uint16_t* source,
    int32_t sourceLength,
    int8_t* ap,
    void* parseError,
    int32_t* status);
C, "icuin.dll");
// $ffi->u_vparseMessageWithError(locale, pattern, patternLength, source, sourceLength, ap, parseError, status);
// locale : LPCSTR
// pattern : WORD*
// patternLength : INT
// source : WORD*
// sourceLength : INT
// ap : CHAR* in/out
// parseError : 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);
    void u_vparseMessageWithError(
        String locale,   // LPCSTR
        ShortByReference pattern,   // WORD*
        int patternLength,   // INT
        ShortByReference source,   // WORD*
        int sourceLength,   // INT
        byte[] ap,   // CHAR* in/out
        Pointer parseError,   // UParseError* in/out
        IntByReference status   // UErrorCode* in/out
    );
}
@[Link("icuin")]
lib Libicuin
  fun u_vparseMessageWithError = u_vparseMessageWithError(
    locale : UInt8*,   # LPCSTR
    pattern : UInt16*,   # WORD*
    patternLength : Int32,   # INT
    source : UInt16*,   # WORD*
    sourceLength : Int32,   # INT
    ap : Int8*,   # CHAR* in/out
    parseError : UParseError*,   # UParseError* in/out
    status : Int32*   # UErrorCode* in/out
  ) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef u_vparseMessageWithErrorNative = Void Function(Pointer<Utf8>, Pointer<Uint16>, Int32, Pointer<Uint16>, Int32, Pointer<Int8>, Pointer<Void>, Pointer<Int32>);
typedef u_vparseMessageWithErrorDart = void Function(Pointer<Utf8>, Pointer<Uint16>, int, Pointer<Uint16>, int, Pointer<Int8>, Pointer<Void>, Pointer<Int32>);
final u_vparseMessageWithError = DynamicLibrary.open('icuin.dll')
    .lookupFunction<u_vparseMessageWithErrorNative, u_vparseMessageWithErrorDart>('u_vparseMessageWithError');
// locale : LPCSTR -> Pointer<Utf8>
// pattern : WORD* -> Pointer<Uint16>
// patternLength : INT -> Int32
// source : WORD* -> Pointer<Uint16>
// sourceLength : INT -> Int32
// ap : CHAR* in/out -> Pointer<Int8>
// parseError : UParseError* in/out -> Pointer<Void>
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
procedure u_vparseMessageWithError(
  locale: PAnsiChar;   // LPCSTR
  pattern: Pointer;   // WORD*
  patternLength: Integer;   // INT
  source: Pointer;   // WORD*
  sourceLength: Integer;   // INT
  ap: Pointer;   // CHAR* in/out
  parseError: Pointer;   // UParseError* in/out
  status: Pointer   // UErrorCode* in/out
); cdecl;
  external 'icuin.dll' name 'u_vparseMessageWithError';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "u_vparseMessageWithError"
  c_u_vparseMessageWithError :: CString -> Ptr Word16 -> Int32 -> Ptr Word16 -> Int32 -> Ptr Int8 -> Ptr () -> Ptr Int32 -> IO ()
-- locale : LPCSTR -> CString
-- pattern : WORD* -> Ptr Word16
-- patternLength : INT -> Int32
-- source : WORD* -> Ptr Word16
-- sourceLength : INT -> Int32
-- ap : CHAR* in/out -> Ptr Int8
-- parseError : UParseError* in/out -> Ptr ()
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let u_vparsemessagewitherror =
  foreign "u_vparseMessageWithError"
    (string @-> (ptr uint16_t) @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> (ptr int8_t) @-> (ptr void) @-> (ptr int32_t) @-> returning void)
(* locale : LPCSTR -> string *)
(* pattern : WORD* -> (ptr uint16_t) *)
(* patternLength : INT -> int32_t *)
(* source : WORD* -> (ptr uint16_t) *)
(* sourceLength : INT -> int32_t *)
(* ap : CHAR* in/out -> (ptr int8_t) *)
(* parseError : 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 ("u_vparseMessageWithError" u-vparse-message-with-error :convention :cdecl) :void
  (locale :string)   ; LPCSTR
  (pattern :pointer)   ; WORD*
  (pattern-length :int32)   ; INT
  (source :pointer)   ; WORD*
  (source-length :int32)   ; INT
  (ap :pointer)   ; CHAR* in/out
  (parse-error :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 $u_vparseMessageWithError = Win32::API::More->new('icuin',
    'void u_vparseMessageWithError(LPCSTR locale, LPVOID pattern, int patternLength, LPVOID source, int sourceLength, LPVOID ap, LPVOID parseError, LPVOID status)');
# my $ret = $u_vparseMessageWithError->Call($locale, $pattern, $patternLength, $source, $sourceLength, $ap, $parseError, $status);
# locale : LPCSTR -> LPCSTR
# pattern : WORD* -> LPVOID
# patternLength : INT -> int
# source : WORD* -> LPVOID
# sourceLength : INT -> int
# ap : CHAR* in/out -> LPVOID
# parseError : UParseError* in/out -> LPVOID
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型