Win32 API 日本語リファレンス
ホームGlobalization › u_charName

u_charName

関数
コードポイントから文字名を取得する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

// icuuc.dll
#include <windows.h>

INT u_charName(
    INT code,
    UCharNameChoice nameChoice,
    LPSTR buffer,
    INT bufferLength,
    UErrorCode* pErrorCode
);

パラメーター

名前方向説明
codeINTin名称を取得する対象のコードポイント。UTF-32形式で指定する。
nameChoiceUCharNameChoicein取得する名称の種類を指定する列挙値。正式名称や別名などを選択する。
bufferLPSTRin取得した文字名を格納する出力バッファ(LPSTR)。呼び出し側が確保する。
bufferLengthINTinbufferの容量(バイト数)。書き込み可能な最大長を指定する。
pErrorCodeUErrorCode*inoutICUのエラーコードを受け渡すポインタ。呼び出し前にU_ZERO_ERRORで初期化する。

戻り値の型: 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, varptr(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, var
; res = u_charName(code, nameChoice, buffer, bufferLength, pErrorCode)
; code : INT -> "int"
; nameChoice : UCharNameChoice -> "int"
; buffer : LPSTR -> "str"
; bufferLength : INT -> "int"
; pErrorCode : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; 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, var
; res = u_charName(code, nameChoice, buffer, bufferLength, pErrorCode)
; code : INT -> "int"
; nameChoice : UCharNameChoice -> "int"
; buffer : LPSTR -> "str"
; bufferLength : INT -> "int"
; pErrorCode : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
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   // INT
function 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`,…) を使用。
const std = @import("std");

extern "icuuc" fn u_charName(
    code: i32, // INT
    nameChoice: i32, // UCharNameChoice
    buffer: [*c]const u8, // LPSTR
    bufferLength: i32, // INT
    pErrorCode: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;
proc u_charName(
    code: int32,  # INT
    nameChoice: int32,  # UCharNameChoice
    buffer: cstring,  # LPSTR
    bufferLength: int32,  # INT
    pErrorCode: ptr int32  # UErrorCode* in/out
): int32 {.importc: "u_charName", cdecl, dynlib: "icuuc.dll".}
pragma(lib, "icuuc");
extern(C)
int u_charName(
    int code,   // INT
    int nameChoice,   // UCharNameChoice
    const(char)* buffer,   // LPSTR
    int bufferLength,   // INT
    int* pErrorCode   // UErrorCode* in/out
);
ccall((:u_charName, "icuuc.dll"), Int32,
      (Int32, Int32, Cstring, Int32, Ptr{Int32}),
      code, nameChoice, buffer, bufferLength, pErrorCode)
# code : INT -> Int32
# nameChoice : UCharNameChoice -> Int32
# buffer : LPSTR -> Cstring
# bufferLength : INT -> Int32
# pErrorCode : UErrorCode* in/out -> Ptr{Int32}
local ffi = require("ffi")
ffi.cdef[[
int32_t u_charName(
    int32_t code,
    int32_t nameChoice,
    const char* buffer,
    int32_t bufferLength,
    int32_t* pErrorCode);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.u_charName(code, nameChoice, buffer, bufferLength, pErrorCode)
-- code : INT
-- nameChoice : UCharNameChoice
-- buffer : LPSTR
-- bufferLength : INT
-- pErrorCode : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const u_charName = lib.func('__cdecl', 'u_charName', 'int32_t', ['int32_t', 'int32_t', 'str', 'int32_t', 'int32_t *']);
// u_charName(code, nameChoice, buffer, bufferLength, pErrorCode)
// code : INT -> 'int32_t'
// nameChoice : UCharNameChoice -> 'int32_t'
// buffer : LPSTR -> 'str'
// bufferLength : INT -> 'int32_t'
// pErrorCode : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuuc.dll", {
  u_charName: { parameters: ["i32", "i32", "buffer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.u_charName(code, nameChoice, buffer, bufferLength, pErrorCode)
// code : INT -> "i32"
// nameChoice : UCharNameChoice -> "i32"
// buffer : LPSTR -> "buffer"
// bufferLength : INT -> "i32"
// pErrorCode : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t u_charName(
    int32_t code,
    int32_t nameChoice,
    const char* buffer,
    int32_t bufferLength,
    int32_t* pErrorCode);
C, "icuuc.dll");
// $ffi->u_charName(code, nameChoice, buffer, bufferLength, pErrorCode);
// code : INT
// nameChoice : UCharNameChoice
// buffer : LPSTR
// bufferLength : INT
// pErrorCode : 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 Icuuc extends Library {
    Icuuc INSTANCE = Native.load("icuuc", Icuuc.class);
    int u_charName(
        int code,   // INT
        int nameChoice,   // UCharNameChoice
        String buffer,   // LPSTR
        int bufferLength,   // INT
        IntByReference pErrorCode   // UErrorCode* in/out
    );
}
@[Link("icuuc")]
lib Libicuuc
  fun u_charName = u_charName(
    code : Int32,   # INT
    nameChoice : Int32,   # UCharNameChoice
    buffer : UInt8*,   # LPSTR
    bufferLength : Int32,   # INT
    pErrorCode : Int32*   # UErrorCode* in/out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef u_charNameNative = Int32 Function(Int32, Int32, Pointer<Utf8>, Int32, Pointer<Int32>);
typedef u_charNameDart = int Function(int, int, Pointer<Utf8>, int, Pointer<Int32>);
final u_charName = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<u_charNameNative, u_charNameDart>('u_charName');
// code : INT -> Int32
// nameChoice : UCharNameChoice -> Int32
// buffer : LPSTR -> Pointer<Utf8>
// bufferLength : INT -> Int32
// pErrorCode : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function 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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "u_charName"
  c_u_charName :: Int32 -> Int32 -> CString -> Int32 -> Ptr Int32 -> IO Int32
-- code : INT -> Int32
-- nameChoice : UCharNameChoice -> Int32
-- buffer : LPSTR -> CString
-- bufferLength : INT -> Int32
-- pErrorCode : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let u_charname =
  foreign "u_charName"
    (int32_t @-> int32_t @-> string @-> int32_t @-> (ptr int32_t) @-> returning int32_t)
(* code : INT -> int32_t *)
(* nameChoice : UCharNameChoice -> int32_t *)
(* buffer : LPSTR -> string *)
(* bufferLength : INT -> int32_t *)
(* pErrorCode : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)

(cffi:defcfun ("u_charName" u-char-name :convention :cdecl) :int32
  (code :int32)   ; INT
  (name-choice :int32)   ; UCharNameChoice
  (buffer :string)   ; LPSTR
  (buffer-length :int32)   ; INT
  (p-error-code :pointer))   ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $u_charName = Win32::API::More->new('icuuc',
    'int u_charName(int code, int nameChoice, LPCSTR buffer, int bufferLength, LPVOID pErrorCode)');
# my $ret = $u_charName->Call($code, $nameChoice, $buffer, $bufferLength, $pErrorCode);
# code : INT -> int
# nameChoice : UCharNameChoice -> int
# buffer : LPSTR -> LPCSTR
# bufferLength : INT -> int
# pErrorCode : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型