ホーム › Globalization › ucnv_getDisplayName
ucnv_getDisplayName
関数変換器の表示用名称を指定ロケールで取得する。
シグネチャ
// icuuc.dll
#include <windows.h>
INT ucnv_getDisplayName(
const UConverter* converter,
LPCSTR displayLocale,
WORD* displayName,
INT displayNameCapacity,
UErrorCode* err
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| converter | UConverter* | in | 表示名を取得する対象のコンバーターへのポインタ。 |
| displayLocale | LPCSTR | in | 表示名の言語ロケール(NUL終端)。NULLで既定ロケール。 |
| displayName | WORD* | inout | 表示名(UTF-16)を受け取る出力バッファへのポインタ。 |
| displayNameCapacity | INT | in | displayNameバッファの要素数。 |
| err | UErrorCode* | inout | エラーコードを入出力するポインタ。事前にU_ZERO_ERRORで初期化する。 |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT ucnv_getDisplayName(
const UConverter* converter,
LPCSTR displayLocale,
WORD* displayName,
INT displayNameCapacity,
UErrorCode* err
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int ucnv_getDisplayName(
ref IntPtr converter, // UConverter*
[MarshalAs(UnmanagedType.LPStr)] string displayLocale, // LPCSTR
ref ushort displayName, // WORD* in/out
int displayNameCapacity, // INT
ref int err // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucnv_getDisplayName(
ByRef converter As IntPtr, ' UConverter*
<MarshalAs(UnmanagedType.LPStr)> displayLocale As String, ' LPCSTR
ByRef displayName As UShort, ' WORD* in/out
displayNameCapacity As Integer, ' INT
ByRef err As Integer ' UErrorCode* in/out
) As Integer
End Function' converter : UConverter*
' displayLocale : LPCSTR
' displayName : WORD* in/out
' displayNameCapacity : INT
' err : UErrorCode* in/out
Declare PtrSafe Function ucnv_getDisplayName Lib "icuuc" ( _
ByRef converter As LongPtr, _
ByVal displayLocale As String, _
ByRef displayName As Integer, _
ByVal displayNameCapacity As Long, _
ByRef err As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ucnv_getDisplayName = ctypes.cdll.icuuc.ucnv_getDisplayName
ucnv_getDisplayName.restype = ctypes.c_int
ucnv_getDisplayName.argtypes = [
ctypes.c_void_p, # converter : UConverter*
wintypes.LPCSTR, # displayLocale : LPCSTR
ctypes.POINTER(ctypes.c_ushort), # displayName : WORD* in/out
ctypes.c_int, # displayNameCapacity : INT
ctypes.c_void_p, # err : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
ucnv_getDisplayName = Fiddle::Function.new(
lib['ucnv_getDisplayName'],
[
Fiddle::TYPE_VOIDP, # converter : UConverter*
Fiddle::TYPE_VOIDP, # displayLocale : LPCSTR
Fiddle::TYPE_VOIDP, # displayName : WORD* in/out
Fiddle::TYPE_INT, # displayNameCapacity : INT
Fiddle::TYPE_VOIDP, # err : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn ucnv_getDisplayName(
converter: *const isize, // UConverter*
displayLocale: *const u8, // LPCSTR
displayName: *mut u16, // WORD* in/out
displayNameCapacity: i32, // INT
err: *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 ucnv_getDisplayName(ref IntPtr converter, [MarshalAs(UnmanagedType.LPStr)] string displayLocale, ref ushort displayName, int displayNameCapacity, ref int err);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucnv_getDisplayName' -Namespace Win32 -PassThru
# $api::ucnv_getDisplayName(converter, displayLocale, displayName, displayNameCapacity, err)#uselib "icuuc.dll"
#func global ucnv_getDisplayName "ucnv_getDisplayName" sptr, sptr, sptr, sptr, sptr
; ucnv_getDisplayName varptr(converter), displayLocale, varptr(displayName), displayNameCapacity, varptr(err) ; 戻り値は stat
; converter : UConverter* -> "sptr"
; displayLocale : LPCSTR -> "sptr"
; displayName : WORD* in/out -> "sptr"
; displayNameCapacity : INT -> "sptr"
; err : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global ucnv_getDisplayName "ucnv_getDisplayName" var, str, var, int, var ; res = ucnv_getDisplayName(converter, displayLocale, displayName, displayNameCapacity, err) ; converter : UConverter* -> "var" ; displayLocale : LPCSTR -> "str" ; displayName : WORD* in/out -> "var" ; displayNameCapacity : INT -> "int" ; err : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global ucnv_getDisplayName "ucnv_getDisplayName" sptr, str, sptr, int, sptr ; res = ucnv_getDisplayName(varptr(converter), displayLocale, varptr(displayName), displayNameCapacity, varptr(err)) ; converter : UConverter* -> "sptr" ; displayLocale : LPCSTR -> "str" ; displayName : WORD* in/out -> "sptr" ; displayNameCapacity : INT -> "int" ; err : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT ucnv_getDisplayName(UConverter* converter, LPCSTR displayLocale, WORD* displayName, INT displayNameCapacity, UErrorCode* err) #uselib "icuuc.dll" #cfunc global ucnv_getDisplayName "ucnv_getDisplayName" var, str, var, int, var ; res = ucnv_getDisplayName(converter, displayLocale, displayName, displayNameCapacity, err) ; converter : UConverter* -> "var" ; displayLocale : LPCSTR -> "str" ; displayName : WORD* in/out -> "var" ; displayNameCapacity : INT -> "int" ; err : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT ucnv_getDisplayName(UConverter* converter, LPCSTR displayLocale, WORD* displayName, INT displayNameCapacity, UErrorCode* err) #uselib "icuuc.dll" #cfunc global ucnv_getDisplayName "ucnv_getDisplayName" intptr, str, intptr, int, intptr ; res = ucnv_getDisplayName(varptr(converter), displayLocale, varptr(displayName), displayNameCapacity, varptr(err)) ; converter : UConverter* -> "intptr" ; displayLocale : LPCSTR -> "str" ; displayName : WORD* in/out -> "intptr" ; displayNameCapacity : INT -> "int" ; err : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procucnv_getDisplayName = icuuc.NewProc("ucnv_getDisplayName")
)
// converter (UConverter*), displayLocale (LPCSTR), displayName (WORD* in/out), displayNameCapacity (INT), err (UErrorCode* in/out)
r1, _, err := procucnv_getDisplayName.Call(
uintptr(converter),
uintptr(unsafe.Pointer(windows.BytePtrFromString(displayLocale))),
uintptr(displayName),
uintptr(displayNameCapacity),
uintptr(err),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction ucnv_getDisplayName(
converter: Pointer; // UConverter*
displayLocale: PAnsiChar; // LPCSTR
displayName: Pointer; // WORD* in/out
displayNameCapacity: Integer; // INT
err: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'ucnv_getDisplayName';result := DllCall("icuuc\ucnv_getDisplayName"
, "Ptr", converter ; UConverter*
, "AStr", displayLocale ; LPCSTR
, "Ptr", displayName ; WORD* in/out
, "Int", displayNameCapacity ; INT
, "Ptr", err ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●ucnv_getDisplayName(converter, displayLocale, displayName, displayNameCapacity, err) = DLL("icuuc.dll", "int ucnv_getDisplayName(void*, char*, void*, int, void*)")
# 呼び出し: ucnv_getDisplayName(converter, displayLocale, displayName, displayNameCapacity, err)
# converter : UConverter* -> "void*"
# displayLocale : LPCSTR -> "char*"
# displayName : WORD* in/out -> "void*"
# displayNameCapacity : INT -> "int"
# err : 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 ucnv_getDisplayName(
converter: [*c]isize, // UConverter*
displayLocale: [*c]const u8, // LPCSTR
displayName: [*c]u16, // WORD* in/out
displayNameCapacity: i32, // INT
err: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;proc ucnv_getDisplayName(
`converter`: ptr int, # UConverter*
displayLocale: cstring, # LPCSTR
displayName: ptr uint16, # WORD* in/out
displayNameCapacity: int32, # INT
err: ptr int32 # UErrorCode* in/out
): int32 {.importc: "ucnv_getDisplayName", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
int ucnv_getDisplayName(
ptrdiff_t* converter, // UConverter*
const(char)* displayLocale, // LPCSTR
ushort* displayName, // WORD* in/out
int displayNameCapacity, // INT
int* err // UErrorCode* in/out
);ccall((:ucnv_getDisplayName, "icuuc.dll"), Int32,
(Ptr{Int}, Cstring, Ptr{UInt16}, Int32, Ptr{Int32}),
converter, displayLocale, displayName, displayNameCapacity, err)
# converter : UConverter* -> Ptr{Int}
# displayLocale : LPCSTR -> Cstring
# displayName : WORD* in/out -> Ptr{UInt16}
# displayNameCapacity : INT -> Int32
# err : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
int32_t ucnv_getDisplayName(
intptr_t* converter,
const char* displayLocale,
uint16_t* displayName,
int32_t displayNameCapacity,
int32_t* err);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.ucnv_getDisplayName(converter, displayLocale, displayName, displayNameCapacity, err)
-- converter : UConverter*
-- displayLocale : LPCSTR
-- displayName : WORD* in/out
-- displayNameCapacity : INT
-- err : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const ucnv_getDisplayName = lib.func('__cdecl', 'ucnv_getDisplayName', 'int32_t', ['intptr_t *', 'str', 'uint16_t *', 'int32_t', 'int32_t *']);
// ucnv_getDisplayName(converter, displayLocale, displayName, displayNameCapacity, err)
// converter : UConverter* -> 'intptr_t *'
// displayLocale : LPCSTR -> 'str'
// displayName : WORD* in/out -> 'uint16_t *'
// displayNameCapacity : INT -> 'int32_t'
// err : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
ucnv_getDisplayName: { parameters: ["pointer", "buffer", "pointer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.ucnv_getDisplayName(converter, displayLocale, displayName, displayNameCapacity, err)
// converter : UConverter* -> "pointer"
// displayLocale : LPCSTR -> "buffer"
// displayName : WORD* in/out -> "pointer"
// displayNameCapacity : INT -> "i32"
// err : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ucnv_getDisplayName(
intptr_t* converter,
const char* displayLocale,
uint16_t* displayName,
int32_t displayNameCapacity,
int32_t* err);
C, "icuuc.dll");
// $ffi->ucnv_getDisplayName(converter, displayLocale, displayName, displayNameCapacity, err);
// converter : UConverter*
// displayLocale : LPCSTR
// displayName : WORD* in/out
// displayNameCapacity : INT
// err : 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 ucnv_getDisplayName(
LongByReference converter, // UConverter*
String displayLocale, // LPCSTR
ShortByReference displayName, // WORD* in/out
int displayNameCapacity, // INT
IntByReference err // UErrorCode* in/out
);
}@[Link("icuuc")]
lib Libicuuc
fun ucnv_getDisplayName = ucnv_getDisplayName(
converter : LibC::SSizeT*, # UConverter*
displayLocale : UInt8*, # LPCSTR
displayName : UInt16*, # WORD* in/out
displayNameCapacity : Int32, # INT
err : Int32* # UErrorCode* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ucnv_getDisplayNameNative = Int32 Function(Pointer<IntPtr>, Pointer<Utf8>, Pointer<Uint16>, Int32, Pointer<Int32>);
typedef ucnv_getDisplayNameDart = int Function(Pointer<IntPtr>, Pointer<Utf8>, Pointer<Uint16>, int, Pointer<Int32>);
final ucnv_getDisplayName = DynamicLibrary.open('icuuc.dll')
.lookupFunction<ucnv_getDisplayNameNative, ucnv_getDisplayNameDart>('ucnv_getDisplayName');
// converter : UConverter* -> Pointer<IntPtr>
// displayLocale : LPCSTR -> Pointer<Utf8>
// displayName : WORD* in/out -> Pointer<Uint16>
// displayNameCapacity : INT -> Int32
// err : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ucnv_getDisplayName(
converter: Pointer; // UConverter*
displayLocale: PAnsiChar; // LPCSTR
displayName: Pointer; // WORD* in/out
displayNameCapacity: Integer; // INT
err: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'ucnv_getDisplayName';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ucnv_getDisplayName"
c_ucnv_getDisplayName :: Ptr CIntPtr -> CString -> Ptr Word16 -> Int32 -> Ptr Int32 -> IO Int32
-- converter : UConverter* -> Ptr CIntPtr
-- displayLocale : LPCSTR -> CString
-- displayName : WORD* in/out -> Ptr Word16
-- displayNameCapacity : INT -> Int32
-- err : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ucnv_getdisplayname =
foreign "ucnv_getDisplayName"
((ptr intptr_t) @-> string @-> (ptr uint16_t) @-> int32_t @-> (ptr int32_t) @-> returning int32_t)
(* converter : UConverter* -> (ptr intptr_t) *)
(* displayLocale : LPCSTR -> string *)
(* displayName : WORD* in/out -> (ptr uint16_t) *)
(* displayNameCapacity : INT -> int32_t *)
(* err : 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 ("ucnv_getDisplayName" ucnv-get-display-name :convention :cdecl) :int32
(converter :pointer) ; UConverter*
(display-locale :string) ; LPCSTR
(display-name :pointer) ; WORD* in/out
(display-name-capacity :int32) ; INT
(err :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ucnv_getDisplayName = Win32::API::More->new('icuuc',
'int ucnv_getDisplayName(LPVOID converter, LPCSTR displayLocale, LPVOID displayName, int displayNameCapacity, LPVOID err)');
# my $ret = $ucnv_getDisplayName->Call($converter, $displayLocale, $displayName, $displayNameCapacity, $err);
# converter : UConverter* -> LPVOID
# displayLocale : LPCSTR -> LPCSTR
# displayName : WORD* in/out -> LPVOID
# displayNameCapacity : INT -> int
# err : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型