ホーム › Globalization › uregex_appendReplacement
uregex_appendReplacement
関数一致箇所の置換結果を出力バッファに追記する。
シグネチャ
// icuin.dll
#include <windows.h>
INT uregex_appendReplacement(
URegularExpression* regexp,
const WORD* replacementText,
INT replacementLength,
WORD** destBuf,
INT* destCapacity,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| regexp | URegularExpression* | inout | 逐次置換で直前の一致を置換し、その手前部分も追記する正規表現オブジェクト。 |
| replacementText | WORD* | in | 現在の一致に対する置換文字列。UTF-16配列で後方参照を含められる。 |
| replacementLength | INT | in | replacementTextの長さ(コード単位数)。NUL終端文字列なら-1を指定できる。 |
| destBuf | WORD** | inout | 出力位置を指すポインタへのポインタ。書き込み後に書き込み末尾へ前進させられる。 |
| destCapacity | INT* | inout | 残り容量(コード単位数)を入出力するポインタ。書き込んだ分だけ減算される。 |
| status | UErrorCode* | inout | ICUエラーコードの入出力ポインタ。事前にU_ZERO_ERRORへ初期化する。 |
戻り値の型: INT
各言語での呼び出し定義
// icuin.dll
#include <windows.h>
INT uregex_appendReplacement(
URegularExpression* regexp,
const WORD* replacementText,
INT replacementLength,
WORD** destBuf,
INT* destCapacity,
UErrorCode* status
);[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int uregex_appendReplacement(
ref IntPtr regexp, // URegularExpression* in/out
ref ushort replacementText, // WORD*
int replacementLength, // INT
IntPtr destBuf, // WORD** in/out
ref int destCapacity, // INT* in/out
ref int status // UErrorCode* in/out
);<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function uregex_appendReplacement(
ByRef regexp As IntPtr, ' URegularExpression* in/out
ByRef replacementText As UShort, ' WORD*
replacementLength As Integer, ' INT
destBuf As IntPtr, ' WORD** in/out
ByRef destCapacity As Integer, ' INT* in/out
ByRef status As Integer ' UErrorCode* in/out
) As Integer
End Function' regexp : URegularExpression* in/out
' replacementText : WORD*
' replacementLength : INT
' destBuf : WORD** in/out
' destCapacity : INT* in/out
' status : UErrorCode* in/out
Declare PtrSafe Function uregex_appendReplacement Lib "icuin" ( _
ByRef regexp As LongPtr, _
ByRef replacementText As Integer, _
ByVal replacementLength As Long, _
ByVal destBuf As LongPtr, _
ByRef destCapacity As Long, _
ByRef status As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
uregex_appendReplacement = ctypes.cdll.icuin.uregex_appendReplacement
uregex_appendReplacement.restype = ctypes.c_int
uregex_appendReplacement.argtypes = [
ctypes.c_void_p, # regexp : URegularExpression* in/out
ctypes.POINTER(ctypes.c_ushort), # replacementText : WORD*
ctypes.c_int, # replacementLength : INT
ctypes.c_void_p, # destBuf : WORD** in/out
ctypes.POINTER(ctypes.c_int), # destCapacity : INT* in/out
ctypes.c_void_p, # status : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuin.dll')
uregex_appendReplacement = Fiddle::Function.new(
lib['uregex_appendReplacement'],
[
Fiddle::TYPE_VOIDP, # regexp : URegularExpression* in/out
Fiddle::TYPE_VOIDP, # replacementText : WORD*
Fiddle::TYPE_INT, # replacementLength : INT
Fiddle::TYPE_VOIDP, # destBuf : WORD** in/out
Fiddle::TYPE_VOIDP, # destCapacity : INT* in/out
Fiddle::TYPE_VOIDP, # status : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuin")]
extern "C" {
fn uregex_appendReplacement(
regexp: *mut isize, // URegularExpression* in/out
replacementText: *const u16, // WORD*
replacementLength: i32, // INT
destBuf: *mut *mut u16, // WORD** in/out
destCapacity: *mut i32, // INT* 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 uregex_appendReplacement(ref IntPtr regexp, ref ushort replacementText, int replacementLength, IntPtr destBuf, ref int destCapacity, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_uregex_appendReplacement' -Namespace Win32 -PassThru
# $api::uregex_appendReplacement(regexp, replacementText, replacementLength, destBuf, destCapacity, status)#uselib "icuin.dll"
#func global uregex_appendReplacement "uregex_appendReplacement" sptr, sptr, sptr, sptr, sptr, sptr
; uregex_appendReplacement varptr(regexp), varptr(replacementText), replacementLength, varptr(destBuf), varptr(destCapacity), varptr(status) ; 戻り値は stat
; regexp : URegularExpression* in/out -> "sptr"
; replacementText : WORD* -> "sptr"
; replacementLength : INT -> "sptr"
; destBuf : WORD** in/out -> "sptr"
; destCapacity : INT* in/out -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuin.dll" #cfunc global uregex_appendReplacement "uregex_appendReplacement" var, var, int, var, var, var ; res = uregex_appendReplacement(regexp, replacementText, replacementLength, destBuf, destCapacity, status) ; regexp : URegularExpression* in/out -> "var" ; replacementText : WORD* -> "var" ; replacementLength : INT -> "int" ; destBuf : WORD** in/out -> "var" ; destCapacity : INT* in/out -> "var" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuin.dll" #cfunc global uregex_appendReplacement "uregex_appendReplacement" sptr, sptr, int, sptr, sptr, sptr ; res = uregex_appendReplacement(varptr(regexp), varptr(replacementText), replacementLength, varptr(destBuf), varptr(destCapacity), varptr(status)) ; regexp : URegularExpression* in/out -> "sptr" ; replacementText : WORD* -> "sptr" ; replacementLength : INT -> "int" ; destBuf : WORD** in/out -> "sptr" ; destCapacity : INT* in/out -> "sptr" ; status : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT uregex_appendReplacement(URegularExpression* regexp, WORD* replacementText, INT replacementLength, WORD** destBuf, INT* destCapacity, UErrorCode* status) #uselib "icuin.dll" #cfunc global uregex_appendReplacement "uregex_appendReplacement" var, var, int, var, var, var ; res = uregex_appendReplacement(regexp, replacementText, replacementLength, destBuf, destCapacity, status) ; regexp : URegularExpression* in/out -> "var" ; replacementText : WORD* -> "var" ; replacementLength : INT -> "int" ; destBuf : WORD** in/out -> "var" ; destCapacity : INT* in/out -> "var" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT uregex_appendReplacement(URegularExpression* regexp, WORD* replacementText, INT replacementLength, WORD** destBuf, INT* destCapacity, UErrorCode* status) #uselib "icuin.dll" #cfunc global uregex_appendReplacement "uregex_appendReplacement" intptr, intptr, int, intptr, intptr, intptr ; res = uregex_appendReplacement(varptr(regexp), varptr(replacementText), replacementLength, varptr(destBuf), varptr(destCapacity), varptr(status)) ; regexp : URegularExpression* in/out -> "intptr" ; replacementText : WORD* -> "intptr" ; replacementLength : INT -> "int" ; destBuf : WORD** in/out -> "intptr" ; destCapacity : INT* in/out -> "intptr" ; status : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuin = windows.NewLazySystemDLL("icuin.dll")
procuregex_appendReplacement = icuin.NewProc("uregex_appendReplacement")
)
// regexp (URegularExpression* in/out), replacementText (WORD*), replacementLength (INT), destBuf (WORD** in/out), destCapacity (INT* in/out), status (UErrorCode* in/out)
r1, _, err := procuregex_appendReplacement.Call(
uintptr(regexp),
uintptr(replacementText),
uintptr(replacementLength),
uintptr(destBuf),
uintptr(destCapacity),
uintptr(status),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction uregex_appendReplacement(
regexp: Pointer; // URegularExpression* in/out
replacementText: Pointer; // WORD*
replacementLength: Integer; // INT
destBuf: Pointer; // WORD** in/out
destCapacity: Pointer; // INT* in/out
status: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuin.dll' name 'uregex_appendReplacement';result := DllCall("icuin\uregex_appendReplacement"
, "Ptr", regexp ; URegularExpression* in/out
, "Ptr", replacementText ; WORD*
, "Int", replacementLength ; INT
, "Ptr", destBuf ; WORD** in/out
, "Ptr", destCapacity ; INT* in/out
, "Ptr", status ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●uregex_appendReplacement(regexp, replacementText, replacementLength, destBuf, destCapacity, status) = DLL("icuin.dll", "int uregex_appendReplacement(void*, void*, int, void*, void*, void*)")
# 呼び出し: uregex_appendReplacement(regexp, replacementText, replacementLength, destBuf, destCapacity, status)
# regexp : URegularExpression* in/out -> "void*"
# replacementText : WORD* -> "void*"
# replacementLength : INT -> "int"
# destBuf : WORD** in/out -> "void*"
# destCapacity : INT* 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 uregex_appendReplacement(
regexp: [*c]isize, // URegularExpression* in/out
replacementText: [*c]u16, // WORD*
replacementLength: i32, // INT
destBuf: [*c][*c]u16, // WORD** in/out
destCapacity: [*c]i32, // INT* in/out
status: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;proc uregex_appendReplacement(
regexp: ptr int, # URegularExpression* in/out
replacementText: ptr uint16, # WORD*
replacementLength: int32, # INT
destBuf: ptr uint16, # WORD** in/out
destCapacity: ptr int32, # INT* in/out
status: ptr int32 # UErrorCode* in/out
): int32 {.importc: "uregex_appendReplacement", cdecl, dynlib: "icuin.dll".}pragma(lib, "icuin");
extern(C)
int uregex_appendReplacement(
ptrdiff_t* regexp, // URegularExpression* in/out
ushort* replacementText, // WORD*
int replacementLength, // INT
ushort** destBuf, // WORD** in/out
int* destCapacity, // INT* in/out
int* status // UErrorCode* in/out
);ccall((:uregex_appendReplacement, "icuin.dll"), Int32,
(Ptr{Int}, Ptr{UInt16}, Int32, Ptr{UInt16}, Ptr{Int32}, Ptr{Int32}),
regexp, replacementText, replacementLength, destBuf, destCapacity, status)
# regexp : URegularExpression* in/out -> Ptr{Int}
# replacementText : WORD* -> Ptr{UInt16}
# replacementLength : INT -> Int32
# destBuf : WORD** in/out -> Ptr{UInt16}
# destCapacity : INT* in/out -> Ptr{Int32}
# status : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
int32_t uregex_appendReplacement(
intptr_t* regexp,
uint16_t* replacementText,
int32_t replacementLength,
uint16_t** destBuf,
int32_t* destCapacity,
int32_t* status);
]]
local icuin = ffi.load("icuin")
-- icuin.uregex_appendReplacement(regexp, replacementText, replacementLength, destBuf, destCapacity, status)
-- regexp : URegularExpression* in/out
-- replacementText : WORD*
-- replacementLength : INT
-- destBuf : WORD** in/out
-- destCapacity : INT* in/out
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuin.dll');
const uregex_appendReplacement = lib.func('__cdecl', 'uregex_appendReplacement', 'int32_t', ['intptr_t *', 'uint16_t *', 'int32_t', 'uint16_t *', 'int32_t *', 'int32_t *']);
// uregex_appendReplacement(regexp, replacementText, replacementLength, destBuf, destCapacity, status)
// regexp : URegularExpression* in/out -> 'intptr_t *'
// replacementText : WORD* -> 'uint16_t *'
// replacementLength : INT -> 'int32_t'
// destBuf : WORD** in/out -> 'uint16_t *'
// destCapacity : INT* in/out -> 'int32_t *'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuin.dll", {
uregex_appendReplacement: { parameters: ["pointer", "pointer", "i32", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.uregex_appendReplacement(regexp, replacementText, replacementLength, destBuf, destCapacity, status)
// regexp : URegularExpression* in/out -> "pointer"
// replacementText : WORD* -> "pointer"
// replacementLength : INT -> "i32"
// destBuf : WORD** in/out -> "pointer"
// destCapacity : INT* in/out -> "pointer"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t uregex_appendReplacement(
intptr_t* regexp,
uint16_t* replacementText,
int32_t replacementLength,
uint16_t** destBuf,
int32_t* destCapacity,
int32_t* status);
C, "icuin.dll");
// $ffi->uregex_appendReplacement(regexp, replacementText, replacementLength, destBuf, destCapacity, status);
// regexp : URegularExpression* in/out
// replacementText : WORD*
// replacementLength : INT
// destBuf : WORD** in/out
// destCapacity : INT* 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);
int uregex_appendReplacement(
LongByReference regexp, // URegularExpression* in/out
ShortByReference replacementText, // WORD*
int replacementLength, // INT
Pointer destBuf, // WORD** in/out
IntByReference destCapacity, // INT* in/out
IntByReference status // UErrorCode* in/out
);
}@[Link("icuin")]
lib Libicuin
fun uregex_appendReplacement = uregex_appendReplacement(
regexp : LibC::SSizeT*, # URegularExpression* in/out
replacementText : UInt16*, # WORD*
replacementLength : Int32, # INT
destBuf : UInt16**, # WORD** in/out
destCapacity : Int32*, # INT* in/out
status : Int32* # UErrorCode* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef uregex_appendReplacementNative = Int32 Function(Pointer<IntPtr>, Pointer<Uint16>, Int32, Pointer<Uint16>, Pointer<Int32>, Pointer<Int32>);
typedef uregex_appendReplacementDart = int Function(Pointer<IntPtr>, Pointer<Uint16>, int, Pointer<Uint16>, Pointer<Int32>, Pointer<Int32>);
final uregex_appendReplacement = DynamicLibrary.open('icuin.dll')
.lookupFunction<uregex_appendReplacementNative, uregex_appendReplacementDart>('uregex_appendReplacement');
// regexp : URegularExpression* in/out -> Pointer<IntPtr>
// replacementText : WORD* -> Pointer<Uint16>
// replacementLength : INT -> Int32
// destBuf : WORD** in/out -> Pointer<Uint16>
// destCapacity : INT* in/out -> Pointer<Int32>
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function uregex_appendReplacement(
regexp: Pointer; // URegularExpression* in/out
replacementText: Pointer; // WORD*
replacementLength: Integer; // INT
destBuf: Pointer; // WORD** in/out
destCapacity: Pointer; // INT* in/out
status: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuin.dll' name 'uregex_appendReplacement';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "uregex_appendReplacement"
c_uregex_appendReplacement :: Ptr CIntPtr -> Ptr Word16 -> Int32 -> Ptr Word16 -> Ptr Int32 -> Ptr Int32 -> IO Int32
-- regexp : URegularExpression* in/out -> Ptr CIntPtr
-- replacementText : WORD* -> Ptr Word16
-- replacementLength : INT -> Int32
-- destBuf : WORD** in/out -> Ptr Word16
-- destCapacity : INT* in/out -> Ptr Int32
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let uregex_appendreplacement =
foreign "uregex_appendReplacement"
((ptr intptr_t) @-> (ptr uint16_t) @-> int32_t @-> (ptr uint16_t) @-> (ptr int32_t) @-> (ptr int32_t) @-> returning int32_t)
(* regexp : URegularExpression* in/out -> (ptr intptr_t) *)
(* replacementText : WORD* -> (ptr uint16_t) *)
(* replacementLength : INT -> int32_t *)
(* destBuf : WORD** in/out -> (ptr uint16_t) *)
(* destCapacity : INT* in/out -> (ptr int32_t) *)
(* 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 ("uregex_appendReplacement" uregex-append-replacement :convention :cdecl) :int32
(regexp :pointer) ; URegularExpression* in/out
(replacement-text :pointer) ; WORD*
(replacement-length :int32) ; INT
(dest-buf :pointer) ; WORD** in/out
(dest-capacity :pointer) ; INT* in/out
(status :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $uregex_appendReplacement = Win32::API::More->new('icuin',
'int uregex_appendReplacement(LPVOID regexp, LPVOID replacementText, int replacementLength, LPVOID destBuf, LPVOID destCapacity, LPVOID status)');
# my $ret = $uregex_appendReplacement->Call($regexp, $replacementText, $replacementLength, $destBuf, $destCapacity, $status);
# regexp : URegularExpression* in/out -> LPVOID
# replacementText : WORD* -> LPVOID
# replacementLength : INT -> int
# destBuf : WORD** in/out -> LPVOID
# destCapacity : INT* in/out -> LPVOID
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型