ホーム › Globalization › uregex_replaceFirst
uregex_replaceFirst
関数最初の一致箇所を置換文字列に置き換える。
シグネチャ
// icuin.dll
#include <windows.h>
INT uregex_replaceFirst(
URegularExpression* regexp,
const WORD* replacementText,
INT replacementLength,
WORD* destBuf,
INT destCapacity,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| regexp | URegularExpression* | inout |
| replacementText | WORD* | in |
| replacementLength | INT | in |
| destBuf | WORD* | inout |
| destCapacity | INT | in |
| status | UErrorCode* | inout |
戻り値の型: INT
各言語での呼び出し定義
// icuin.dll
#include <windows.h>
INT uregex_replaceFirst(
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_replaceFirst(
ref IntPtr regexp, // URegularExpression* in/out
ref ushort replacementText, // WORD*
int replacementLength, // INT
ref ushort destBuf, // WORD* in/out
int destCapacity, // INT
ref int status // UErrorCode* in/out
);<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function uregex_replaceFirst(
ByRef regexp As IntPtr, ' URegularExpression* in/out
ByRef replacementText As UShort, ' WORD*
replacementLength As Integer, ' INT
ByRef destBuf As UShort, ' WORD* in/out
destCapacity As Integer, ' INT
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
' status : UErrorCode* in/out
Declare PtrSafe Function uregex_replaceFirst Lib "icuin" ( _
ByRef regexp As LongPtr, _
ByRef replacementText As Integer, _
ByVal replacementLength As Long, _
ByRef destBuf As Integer, _
ByVal 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_replaceFirst = ctypes.cdll.icuin.uregex_replaceFirst
uregex_replaceFirst.restype = ctypes.c_int
uregex_replaceFirst.argtypes = [
ctypes.c_void_p, # regexp : URegularExpression* in/out
ctypes.POINTER(ctypes.c_ushort), # replacementText : WORD*
ctypes.c_int, # replacementLength : INT
ctypes.POINTER(ctypes.c_ushort), # destBuf : WORD* in/out
ctypes.c_int, # destCapacity : INT
ctypes.c_void_p, # status : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuin.dll')
uregex_replaceFirst = Fiddle::Function.new(
lib['uregex_replaceFirst'],
[
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_INT, # destCapacity : INT
Fiddle::TYPE_VOIDP, # status : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuin")]
extern "C" {
fn uregex_replaceFirst(
regexp: *mut isize, // URegularExpression* in/out
replacementText: *const u16, // WORD*
replacementLength: i32, // INT
destBuf: *mut u16, // WORD* in/out
destCapacity: i32, // INT
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_replaceFirst(ref IntPtr regexp, ref ushort replacementText, int replacementLength, ref ushort destBuf, int destCapacity, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_uregex_replaceFirst' -Namespace Win32 -PassThru
# $api::uregex_replaceFirst(regexp, replacementText, replacementLength, destBuf, destCapacity, status)#uselib "icuin.dll"
#func global uregex_replaceFirst "uregex_replaceFirst" sptr, sptr, sptr, sptr, sptr, sptr
; uregex_replaceFirst regexp, varptr(replacementText), replacementLength, varptr(destBuf), destCapacity, status ; 戻り値は stat
; regexp : URegularExpression* in/out -> "sptr"
; replacementText : WORD* -> "sptr"
; replacementLength : INT -> "sptr"
; destBuf : WORD* in/out -> "sptr"
; destCapacity : INT -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuin.dll" #cfunc global uregex_replaceFirst "uregex_replaceFirst" int, var, int, var, int, int ; res = uregex_replaceFirst(regexp, replacementText, replacementLength, destBuf, destCapacity, status) ; regexp : URegularExpression* in/out -> "int" ; replacementText : WORD* -> "var" ; replacementLength : INT -> "int" ; destBuf : WORD* in/out -> "var" ; destCapacity : INT -> "int" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuin.dll" #cfunc global uregex_replaceFirst "uregex_replaceFirst" int, sptr, int, sptr, int, int ; res = uregex_replaceFirst(regexp, varptr(replacementText), replacementLength, varptr(destBuf), destCapacity, status) ; regexp : URegularExpression* in/out -> "int" ; replacementText : WORD* -> "sptr" ; replacementLength : INT -> "int" ; destBuf : WORD* in/out -> "sptr" ; destCapacity : INT -> "int" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT uregex_replaceFirst(URegularExpression* regexp, WORD* replacementText, INT replacementLength, WORD* destBuf, INT destCapacity, UErrorCode* status) #uselib "icuin.dll" #cfunc global uregex_replaceFirst "uregex_replaceFirst" int, var, int, var, int, int ; res = uregex_replaceFirst(regexp, replacementText, replacementLength, destBuf, destCapacity, status) ; regexp : URegularExpression* in/out -> "int" ; replacementText : WORD* -> "var" ; replacementLength : INT -> "int" ; destBuf : WORD* in/out -> "var" ; destCapacity : INT -> "int" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT uregex_replaceFirst(URegularExpression* regexp, WORD* replacementText, INT replacementLength, WORD* destBuf, INT destCapacity, UErrorCode* status) #uselib "icuin.dll" #cfunc global uregex_replaceFirst "uregex_replaceFirst" int, intptr, int, intptr, int, int ; res = uregex_replaceFirst(regexp, varptr(replacementText), replacementLength, varptr(destBuf), destCapacity, status) ; regexp : URegularExpression* in/out -> "int" ; replacementText : WORD* -> "intptr" ; replacementLength : INT -> "int" ; destBuf : WORD* in/out -> "intptr" ; destCapacity : INT -> "int" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuin = windows.NewLazySystemDLL("icuin.dll")
procuregex_replaceFirst = icuin.NewProc("uregex_replaceFirst")
)
// regexp (URegularExpression* in/out), replacementText (WORD*), replacementLength (INT), destBuf (WORD* in/out), destCapacity (INT), status (UErrorCode* in/out)
r1, _, err := procuregex_replaceFirst.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_replaceFirst(
regexp: Pointer; // URegularExpression* in/out
replacementText: Pointer; // WORD*
replacementLength: Integer; // INT
destBuf: Pointer; // WORD* in/out
destCapacity: Integer; // INT
status: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuin.dll' name 'uregex_replaceFirst';result := DllCall("icuin\uregex_replaceFirst"
, "Ptr", regexp ; URegularExpression* in/out
, "Ptr", replacementText ; WORD*
, "Int", replacementLength ; INT
, "Ptr", destBuf ; WORD* in/out
, "Int", destCapacity ; INT
, "Ptr", status ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●uregex_replaceFirst(regexp, replacementText, replacementLength, destBuf, destCapacity, status) = DLL("icuin.dll", "int uregex_replaceFirst(void*, void*, int, void*, int, void*)")
# 呼び出し: uregex_replaceFirst(regexp, replacementText, replacementLength, destBuf, destCapacity, status)
# regexp : URegularExpression* in/out -> "void*"
# replacementText : WORD* -> "void*"
# replacementLength : INT -> "int"
# destBuf : WORD* in/out -> "void*"
# destCapacity : INT -> "int"
# status : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。