ホーム › Globalization › usprep_prepare
usprep_prepare
関数StringPrep規則に従い文字列を正規化・検証して整形する。
シグネチャ
// icuuc.dll
#include <windows.h>
INT usprep_prepare(
const UStringPrepProfile* prep,
const WORD* src,
INT srcLength,
WORD* dest,
INT destCapacity,
INT options,
UParseError* parseError,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| prep | UStringPrepProfile* | in | 前処理に用いる開いたStringPrepプロファイルを指す。 |
| src | WORD* | in | 前処理対象の入力UTF-16文字列を指す。 |
| srcLength | INT | in | srcの長さをUChar単位で指定する。-1でNUL終端。 |
| dest | WORD* | inout | 前処理結果を格納するUTF-16出力バッファ。NULL可。 |
| destCapacity | INT | in | destの容量をUChar単位で指定する。0で事前長取得。 |
| options | INT | in | 処理オプションビット。USPREP_ALLOW_UNASSIGNED等を指定する。 |
| parseError | UParseError* | inout | 解析エラー位置の詳細を受け取る構造体。NULL可。 |
| status | UErrorCode* | inout | ICUエラーコードを入出力するポインタ。呼出前に成功値で初期化する。 |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT usprep_prepare(
const UStringPrepProfile* prep,
const WORD* src,
INT srcLength,
WORD* dest,
INT destCapacity,
INT options,
UParseError* parseError,
UErrorCode* status
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int usprep_prepare(
ref IntPtr prep, // UStringPrepProfile*
ref ushort src, // WORD*
int srcLength, // INT
ref ushort dest, // WORD* in/out
int destCapacity, // INT
int options, // INT
IntPtr parseError, // UParseError* in/out
ref int status // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function usprep_prepare(
ByRef prep As IntPtr, ' UStringPrepProfile*
ByRef src As UShort, ' WORD*
srcLength As Integer, ' INT
ByRef dest As UShort, ' WORD* in/out
destCapacity As Integer, ' INT
options As Integer, ' INT
parseError As IntPtr, ' UParseError* in/out
ByRef status As Integer ' UErrorCode* in/out
) As Integer
End Function' prep : UStringPrepProfile*
' src : WORD*
' srcLength : INT
' dest : WORD* in/out
' destCapacity : INT
' options : INT
' parseError : UParseError* in/out
' status : UErrorCode* in/out
Declare PtrSafe Function usprep_prepare Lib "icuuc" ( _
ByRef prep As LongPtr, _
ByRef src As Integer, _
ByVal srcLength As Long, _
ByRef dest As Integer, _
ByVal destCapacity As Long, _
ByVal options As Long, _
ByVal parseError 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
usprep_prepare = ctypes.cdll.icuuc.usprep_prepare
usprep_prepare.restype = ctypes.c_int
usprep_prepare.argtypes = [
ctypes.c_void_p, # prep : UStringPrepProfile*
ctypes.POINTER(ctypes.c_ushort), # src : WORD*
ctypes.c_int, # srcLength : INT
ctypes.POINTER(ctypes.c_ushort), # dest : WORD* in/out
ctypes.c_int, # destCapacity : INT
ctypes.c_int, # options : INT
ctypes.c_void_p, # parseError : UParseError* in/out
ctypes.c_void_p, # status : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
usprep_prepare = Fiddle::Function.new(
lib['usprep_prepare'],
[
Fiddle::TYPE_VOIDP, # prep : UStringPrepProfile*
Fiddle::TYPE_VOIDP, # src : WORD*
Fiddle::TYPE_INT, # srcLength : INT
Fiddle::TYPE_VOIDP, # dest : WORD* in/out
Fiddle::TYPE_INT, # destCapacity : INT
Fiddle::TYPE_INT, # options : INT
Fiddle::TYPE_VOIDP, # parseError : UParseError* in/out
Fiddle::TYPE_VOIDP, # status : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn usprep_prepare(
prep: *const isize, // UStringPrepProfile*
src: *const u16, // WORD*
srcLength: i32, // INT
dest: *mut u16, // WORD* in/out
destCapacity: i32, // INT
options: i32, // INT
parseError: *mut UParseError, // UParseError* in/out
status: *mut i32 // UErrorCode* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int usprep_prepare(ref IntPtr prep, ref ushort src, int srcLength, ref ushort dest, int destCapacity, int options, IntPtr parseError, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_usprep_prepare' -Namespace Win32 -PassThru
# $api::usprep_prepare(prep, src, srcLength, dest, destCapacity, options, parseError, status)#uselib "icuuc.dll"
#func global usprep_prepare "usprep_prepare" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; usprep_prepare varptr(prep), varptr(src), srcLength, varptr(dest), destCapacity, options, varptr(parseError), varptr(status) ; 戻り値は stat
; prep : UStringPrepProfile* -> "sptr"
; src : WORD* -> "sptr"
; srcLength : INT -> "sptr"
; dest : WORD* in/out -> "sptr"
; destCapacity : INT -> "sptr"
; options : INT -> "sptr"
; parseError : UParseError* in/out -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global usprep_prepare "usprep_prepare" var, var, int, var, int, int, var, var ; res = usprep_prepare(prep, src, srcLength, dest, destCapacity, options, parseError, status) ; prep : UStringPrepProfile* -> "var" ; src : WORD* -> "var" ; srcLength : INT -> "int" ; dest : WORD* in/out -> "var" ; destCapacity : INT -> "int" ; options : INT -> "int" ; parseError : UParseError* in/out -> "var" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global usprep_prepare "usprep_prepare" sptr, sptr, int, sptr, int, int, sptr, sptr ; res = usprep_prepare(varptr(prep), varptr(src), srcLength, varptr(dest), destCapacity, options, varptr(parseError), varptr(status)) ; prep : UStringPrepProfile* -> "sptr" ; src : WORD* -> "sptr" ; srcLength : INT -> "int" ; dest : WORD* in/out -> "sptr" ; destCapacity : INT -> "int" ; options : INT -> "int" ; parseError : UParseError* in/out -> "sptr" ; status : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT usprep_prepare(UStringPrepProfile* prep, WORD* src, INT srcLength, WORD* dest, INT destCapacity, INT options, UParseError* parseError, UErrorCode* status) #uselib "icuuc.dll" #cfunc global usprep_prepare "usprep_prepare" var, var, int, var, int, int, var, var ; res = usprep_prepare(prep, src, srcLength, dest, destCapacity, options, parseError, status) ; prep : UStringPrepProfile* -> "var" ; src : WORD* -> "var" ; srcLength : INT -> "int" ; dest : WORD* in/out -> "var" ; destCapacity : INT -> "int" ; options : INT -> "int" ; parseError : UParseError* in/out -> "var" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT usprep_prepare(UStringPrepProfile* prep, WORD* src, INT srcLength, WORD* dest, INT destCapacity, INT options, UParseError* parseError, UErrorCode* status) #uselib "icuuc.dll" #cfunc global usprep_prepare "usprep_prepare" intptr, intptr, int, intptr, int, int, intptr, intptr ; res = usprep_prepare(varptr(prep), varptr(src), srcLength, varptr(dest), destCapacity, options, varptr(parseError), varptr(status)) ; prep : UStringPrepProfile* -> "intptr" ; src : WORD* -> "intptr" ; srcLength : INT -> "int" ; dest : WORD* in/out -> "intptr" ; destCapacity : INT -> "int" ; options : INT -> "int" ; parseError : UParseError* in/out -> "intptr" ; status : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procusprep_prepare = icuuc.NewProc("usprep_prepare")
)
// prep (UStringPrepProfile*), src (WORD*), srcLength (INT), dest (WORD* in/out), destCapacity (INT), options (INT), parseError (UParseError* in/out), status (UErrorCode* in/out)
r1, _, err := procusprep_prepare.Call(
uintptr(prep),
uintptr(src),
uintptr(srcLength),
uintptr(dest),
uintptr(destCapacity),
uintptr(options),
uintptr(parseError),
uintptr(status),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction usprep_prepare(
prep: Pointer; // UStringPrepProfile*
src: Pointer; // WORD*
srcLength: Integer; // INT
dest: Pointer; // WORD* in/out
destCapacity: Integer; // INT
options: Integer; // INT
parseError: Pointer; // UParseError* in/out
status: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'usprep_prepare';result := DllCall("icuuc\usprep_prepare"
, "Ptr", prep ; UStringPrepProfile*
, "Ptr", src ; WORD*
, "Int", srcLength ; INT
, "Ptr", dest ; WORD* in/out
, "Int", destCapacity ; INT
, "Int", options ; INT
, "Ptr", parseError ; UParseError* in/out
, "Ptr", status ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●usprep_prepare(prep, src, srcLength, dest, destCapacity, options, parseError, status) = DLL("icuuc.dll", "int usprep_prepare(void*, void*, int, void*, int, int, void*, void*)")
# 呼び出し: usprep_prepare(prep, src, srcLength, dest, destCapacity, options, parseError, status)
# prep : UStringPrepProfile* -> "void*"
# src : WORD* -> "void*"
# srcLength : INT -> "int"
# dest : WORD* in/out -> "void*"
# destCapacity : INT -> "int"
# options : INT -> "int"
# 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 "icuuc" fn usprep_prepare(
prep: [*c]isize, // UStringPrepProfile*
src: [*c]u16, // WORD*
srcLength: i32, // INT
dest: [*c]u16, // WORD* in/out
destCapacity: i32, // INT
options: i32, // INT
parseError: [*c]UParseError, // UParseError* in/out
status: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;proc usprep_prepare(
prep: ptr int, # UStringPrepProfile*
src: ptr uint16, # WORD*
srcLength: int32, # INT
dest: ptr uint16, # WORD* in/out
destCapacity: int32, # INT
options: int32, # INT
parseError: ptr UParseError, # UParseError* in/out
status: ptr int32 # UErrorCode* in/out
): int32 {.importc: "usprep_prepare", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
int usprep_prepare(
ptrdiff_t* prep, // UStringPrepProfile*
ushort* src, // WORD*
int srcLength, // INT
ushort* dest, // WORD* in/out
int destCapacity, // INT
int options, // INT
UParseError* parseError, // UParseError* in/out
int* status // UErrorCode* in/out
);ccall((:usprep_prepare, "icuuc.dll"), Int32,
(Ptr{Int}, Ptr{UInt16}, Int32, Ptr{UInt16}, Int32, Int32, Ptr{UParseError}, Ptr{Int32}),
prep, src, srcLength, dest, destCapacity, options, parseError, status)
# prep : UStringPrepProfile* -> Ptr{Int}
# src : WORD* -> Ptr{UInt16}
# srcLength : INT -> Int32
# dest : WORD* in/out -> Ptr{UInt16}
# destCapacity : INT -> Int32
# options : INT -> Int32
# parseError : UParseError* in/out -> Ptr{UParseError}
# status : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
int32_t usprep_prepare(
intptr_t* prep,
uint16_t* src,
int32_t srcLength,
uint16_t* dest,
int32_t destCapacity,
int32_t options,
void* parseError,
int32_t* status);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.usprep_prepare(prep, src, srcLength, dest, destCapacity, options, parseError, status)
-- prep : UStringPrepProfile*
-- src : WORD*
-- srcLength : INT
-- dest : WORD* in/out
-- destCapacity : INT
-- options : INT
-- parseError : UParseError* in/out
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const usprep_prepare = lib.func('__cdecl', 'usprep_prepare', 'int32_t', ['intptr_t *', 'uint16_t *', 'int32_t', 'uint16_t *', 'int32_t', 'int32_t', 'void *', 'int32_t *']);
// usprep_prepare(prep, src, srcLength, dest, destCapacity, options, parseError, status)
// prep : UStringPrepProfile* -> 'intptr_t *'
// src : WORD* -> 'uint16_t *'
// srcLength : INT -> 'int32_t'
// dest : WORD* in/out -> 'uint16_t *'
// destCapacity : INT -> 'int32_t'
// options : INT -> 'int32_t'
// parseError : UParseError* in/out -> 'void *'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
usprep_prepare: { parameters: ["pointer", "pointer", "i32", "pointer", "i32", "i32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.usprep_prepare(prep, src, srcLength, dest, destCapacity, options, parseError, status)
// prep : UStringPrepProfile* -> "pointer"
// src : WORD* -> "pointer"
// srcLength : INT -> "i32"
// dest : WORD* in/out -> "pointer"
// destCapacity : INT -> "i32"
// options : INT -> "i32"
// parseError : UParseError* in/out -> "pointer"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t usprep_prepare(
intptr_t* prep,
uint16_t* src,
int32_t srcLength,
uint16_t* dest,
int32_t destCapacity,
int32_t options,
void* parseError,
int32_t* status);
C, "icuuc.dll");
// $ffi->usprep_prepare(prep, src, srcLength, dest, destCapacity, options, parseError, status);
// prep : UStringPrepProfile*
// src : WORD*
// srcLength : INT
// dest : WORD* in/out
// destCapacity : INT
// options : INT
// 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 Icuuc extends Library {
Icuuc INSTANCE = Native.load("icuuc", Icuuc.class);
int usprep_prepare(
LongByReference prep, // UStringPrepProfile*
ShortByReference src, // WORD*
int srcLength, // INT
ShortByReference dest, // WORD* in/out
int destCapacity, // INT
int options, // INT
Pointer parseError, // UParseError* in/out
IntByReference status // UErrorCode* in/out
);
}@[Link("icuuc")]
lib Libicuuc
fun usprep_prepare = usprep_prepare(
prep : LibC::SSizeT*, # UStringPrepProfile*
src : UInt16*, # WORD*
srcLength : Int32, # INT
dest : UInt16*, # WORD* in/out
destCapacity : Int32, # INT
options : Int32, # INT
parseError : UParseError*, # UParseError* in/out
status : Int32* # UErrorCode* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef usprep_prepareNative = Int32 Function(Pointer<IntPtr>, Pointer<Uint16>, Int32, Pointer<Uint16>, Int32, Int32, Pointer<Void>, Pointer<Int32>);
typedef usprep_prepareDart = int Function(Pointer<IntPtr>, Pointer<Uint16>, int, Pointer<Uint16>, int, int, Pointer<Void>, Pointer<Int32>);
final usprep_prepare = DynamicLibrary.open('icuuc.dll')
.lookupFunction<usprep_prepareNative, usprep_prepareDart>('usprep_prepare');
// prep : UStringPrepProfile* -> Pointer<IntPtr>
// src : WORD* -> Pointer<Uint16>
// srcLength : INT -> Int32
// dest : WORD* in/out -> Pointer<Uint16>
// destCapacity : INT -> Int32
// options : INT -> Int32
// parseError : UParseError* in/out -> Pointer<Void>
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function usprep_prepare(
prep: Pointer; // UStringPrepProfile*
src: Pointer; // WORD*
srcLength: Integer; // INT
dest: Pointer; // WORD* in/out
destCapacity: Integer; // INT
options: Integer; // INT
parseError: Pointer; // UParseError* in/out
status: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'usprep_prepare';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "usprep_prepare"
c_usprep_prepare :: Ptr CIntPtr -> Ptr Word16 -> Int32 -> Ptr Word16 -> Int32 -> Int32 -> Ptr () -> Ptr Int32 -> IO Int32
-- prep : UStringPrepProfile* -> Ptr CIntPtr
-- src : WORD* -> Ptr Word16
-- srcLength : INT -> Int32
-- dest : WORD* in/out -> Ptr Word16
-- destCapacity : INT -> Int32
-- options : INT -> Int32
-- parseError : UParseError* in/out -> Ptr ()
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let usprep_prepare =
foreign "usprep_prepare"
((ptr intptr_t) @-> (ptr uint16_t) @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> int32_t @-> (ptr void) @-> (ptr int32_t) @-> returning int32_t)
(* prep : UStringPrepProfile* -> (ptr intptr_t) *)
(* src : WORD* -> (ptr uint16_t) *)
(* srcLength : INT -> int32_t *)
(* dest : WORD* in/out -> (ptr uint16_t) *)
(* destCapacity : INT -> int32_t *)
(* options : INT -> int32_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 icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)
(cffi:defcfun ("usprep_prepare" usprep-prepare :convention :cdecl) :int32
(prep :pointer) ; UStringPrepProfile*
(src :pointer) ; WORD*
(src-length :int32) ; INT
(dest :pointer) ; WORD* in/out
(dest-capacity :int32) ; INT
(options :int32) ; INT
(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 $usprep_prepare = Win32::API::More->new('icuuc',
'int usprep_prepare(LPVOID prep, LPVOID src, int srcLength, LPVOID dest, int destCapacity, int options, LPVOID parseError, LPVOID status)');
# my $ret = $usprep_prepare->Call($prep, $src, $srcLength, $dest, $destCapacity, $options, $parseError, $status);
# prep : UStringPrepProfile* -> LPVOID
# src : WORD* -> LPVOID
# srcLength : INT -> int
# dest : WORD* in/out -> LPVOID
# destCapacity : INT -> int
# options : INT -> int
# parseError : UParseError* in/out -> LPVOID
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。