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