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