ホーム › Globalization › u_charName
u_charName
関数コードポイントから文字名を取得する。
シグネチャ
// icuuc.dll
#include <windows.h>
INT u_charName(
INT code,
UCharNameChoice nameChoice,
LPSTR buffer,
INT bufferLength,
UErrorCode* pErrorCode
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| code | INT | in |
| nameChoice | UCharNameChoice | in |
| buffer | LPSTR | in |
| bufferLength | INT | in |
| pErrorCode | UErrorCode* | inout |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT u_charName(
INT code,
UCharNameChoice nameChoice,
LPSTR buffer,
INT bufferLength,
UErrorCode* pErrorCode
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int u_charName(
int code, // INT
int nameChoice, // UCharNameChoice
[MarshalAs(UnmanagedType.LPStr)] string buffer, // LPSTR
int bufferLength, // INT
ref int pErrorCode // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function u_charName(
code As Integer, ' INT
nameChoice As Integer, ' UCharNameChoice
<MarshalAs(UnmanagedType.LPStr)> buffer As String, ' LPSTR
bufferLength As Integer, ' INT
ByRef pErrorCode As Integer ' UErrorCode* in/out
) As Integer
End Function' code : INT
' nameChoice : UCharNameChoice
' buffer : LPSTR
' bufferLength : INT
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function u_charName Lib "icuuc" ( _
ByVal code As Long, _
ByVal nameChoice As Long, _
ByVal buffer As String, _
ByVal bufferLength As Long, _
ByRef pErrorCode As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
u_charName = ctypes.cdll.icuuc.u_charName
u_charName.restype = ctypes.c_int
u_charName.argtypes = [
ctypes.c_int, # code : INT
ctypes.c_int, # nameChoice : UCharNameChoice
wintypes.LPCSTR, # buffer : LPSTR
ctypes.c_int, # bufferLength : INT
ctypes.c_void_p, # pErrorCode : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
u_charName = Fiddle::Function.new(
lib['u_charName'],
[
Fiddle::TYPE_INT, # code : INT
Fiddle::TYPE_INT, # nameChoice : UCharNameChoice
Fiddle::TYPE_VOIDP, # buffer : LPSTR
Fiddle::TYPE_INT, # bufferLength : INT
Fiddle::TYPE_VOIDP, # pErrorCode : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn u_charName(
code: i32, // INT
nameChoice: i32, // UCharNameChoice
buffer: *mut u8, // LPSTR
bufferLength: i32, // INT
pErrorCode: *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 u_charName(int code, int nameChoice, [MarshalAs(UnmanagedType.LPStr)] string buffer, int bufferLength, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_charName' -Namespace Win32 -PassThru
# $api::u_charName(code, nameChoice, buffer, bufferLength, pErrorCode)#uselib "icuuc.dll"
#func global u_charName "u_charName" sptr, sptr, sptr, sptr, sptr
; u_charName code, nameChoice, buffer, bufferLength, pErrorCode ; 戻り値は stat
; code : INT -> "sptr"
; nameChoice : UCharNameChoice -> "sptr"
; buffer : LPSTR -> "sptr"
; bufferLength : INT -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "icuuc.dll"
#cfunc global u_charName "u_charName" int, int, str, int, int
; res = u_charName(code, nameChoice, buffer, bufferLength, pErrorCode)
; code : INT -> "int"
; nameChoice : UCharNameChoice -> "int"
; buffer : LPSTR -> "str"
; bufferLength : INT -> "int"
; pErrorCode : UErrorCode* in/out -> "int"; INT u_charName(INT code, UCharNameChoice nameChoice, LPSTR buffer, INT bufferLength, UErrorCode* pErrorCode)
#uselib "icuuc.dll"
#cfunc global u_charName "u_charName" int, int, str, int, int
; res = u_charName(code, nameChoice, buffer, bufferLength, pErrorCode)
; code : INT -> "int"
; nameChoice : UCharNameChoice -> "int"
; buffer : LPSTR -> "str"
; bufferLength : INT -> "int"
; pErrorCode : UErrorCode* in/out -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procu_charName = icuuc.NewProc("u_charName")
)
// code (INT), nameChoice (UCharNameChoice), buffer (LPSTR), bufferLength (INT), pErrorCode (UErrorCode* in/out)
r1, _, err := procu_charName.Call(
uintptr(code),
uintptr(nameChoice),
uintptr(unsafe.Pointer(windows.BytePtrFromString(buffer))),
uintptr(bufferLength),
uintptr(pErrorCode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction u_charName(
code: Integer; // INT
nameChoice: Integer; // UCharNameChoice
buffer: PAnsiChar; // LPSTR
bufferLength: Integer; // INT
pErrorCode: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'u_charName';result := DllCall("icuuc\u_charName"
, "Int", code ; INT
, "Int", nameChoice ; UCharNameChoice
, "AStr", buffer ; LPSTR
, "Int", bufferLength ; INT
, "Ptr", pErrorCode ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●u_charName(code, nameChoice, buffer, bufferLength, pErrorCode) = DLL("icuuc.dll", "int u_charName(int, int, char*, int, void*)")
# 呼び出し: u_charName(code, nameChoice, buffer, bufferLength, pErrorCode)
# code : INT -> "int"
# nameChoice : UCharNameChoice -> "int"
# buffer : LPSTR -> "char*"
# bufferLength : INT -> "int"
# pErrorCode : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。