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

uloc_getDisplayName

関数
ロケール全体の表示名を表示用ロケールで取得する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

INT uloc_getDisplayName(
    LPCSTR localeID,
    LPCSTR inLocaleID,
    WORD* result,
    INT maxResultSize,
    UErrorCode* err
);

パラメーター

名前方向
localeIDLPCSTRin
inLocaleIDLPCSTRin
resultWORD*inout
maxResultSizeINTin
errUErrorCode*inout

戻り値の型: INT

各言語での呼び出し定義

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

INT uloc_getDisplayName(
    LPCSTR localeID,
    LPCSTR inLocaleID,
    WORD* result,
    INT maxResultSize,
    UErrorCode* err
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int uloc_getDisplayName(
    [MarshalAs(UnmanagedType.LPStr)] string localeID,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string inLocaleID,   // LPCSTR
    ref ushort result,   // WORD* in/out
    int maxResultSize,   // INT
    ref int err   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function uloc_getDisplayName(
    <MarshalAs(UnmanagedType.LPStr)> localeID As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> inLocaleID As String,   ' LPCSTR
    ByRef result As UShort,   ' WORD* in/out
    maxResultSize As Integer,   ' INT
    ByRef err As Integer   ' UErrorCode* in/out
) As Integer
End Function
' localeID : LPCSTR
' inLocaleID : LPCSTR
' result : WORD* in/out
' maxResultSize : INT
' err : UErrorCode* in/out
Declare PtrSafe Function uloc_getDisplayName Lib "icuuc" ( _
    ByVal localeID As String, _
    ByVal inLocaleID As String, _
    ByRef result As Integer, _
    ByVal maxResultSize 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

uloc_getDisplayName = ctypes.cdll.icuuc.uloc_getDisplayName
uloc_getDisplayName.restype = ctypes.c_int
uloc_getDisplayName.argtypes = [
    wintypes.LPCSTR,  # localeID : LPCSTR
    wintypes.LPCSTR,  # inLocaleID : LPCSTR
    ctypes.POINTER(ctypes.c_ushort),  # result : WORD* in/out
    ctypes.c_int,  # maxResultSize : INT
    ctypes.c_void_p,  # err : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
uloc_getDisplayName = Fiddle::Function.new(
  lib['uloc_getDisplayName'],
  [
    Fiddle::TYPE_VOIDP,  # localeID : LPCSTR
    Fiddle::TYPE_VOIDP,  # inLocaleID : LPCSTR
    Fiddle::TYPE_VOIDP,  # result : WORD* in/out
    Fiddle::TYPE_INT,  # maxResultSize : INT
    Fiddle::TYPE_VOIDP,  # err : UErrorCode* in/out
  ],
  Fiddle::TYPE_INT, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn uloc_getDisplayName(
        localeID: *const u8,  // LPCSTR
        inLocaleID: *const u8,  // LPCSTR
        result: *mut u16,  // WORD* in/out
        maxResultSize: 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 uloc_getDisplayName([MarshalAs(UnmanagedType.LPStr)] string localeID, [MarshalAs(UnmanagedType.LPStr)] string inLocaleID, ref ushort result, int maxResultSize, ref int err);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_uloc_getDisplayName' -Namespace Win32 -PassThru
# $api::uloc_getDisplayName(localeID, inLocaleID, result, maxResultSize, err)
#uselib "icuuc.dll"
#func global uloc_getDisplayName "uloc_getDisplayName" sptr, sptr, sptr, sptr, sptr
; uloc_getDisplayName localeID, inLocaleID, varptr(result), maxResultSize, err   ; 戻り値は stat
; localeID : LPCSTR -> "sptr"
; inLocaleID : LPCSTR -> "sptr"
; result : WORD* in/out -> "sptr"
; maxResultSize : INT -> "sptr"
; err : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global uloc_getDisplayName "uloc_getDisplayName" str, str, var, int, int
; res = uloc_getDisplayName(localeID, inLocaleID, result, maxResultSize, err)
; localeID : LPCSTR -> "str"
; inLocaleID : LPCSTR -> "str"
; result : WORD* in/out -> "var"
; maxResultSize : INT -> "int"
; err : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT uloc_getDisplayName(LPCSTR localeID, LPCSTR inLocaleID, WORD* result, INT maxResultSize, UErrorCode* err)
#uselib "icuuc.dll"
#cfunc global uloc_getDisplayName "uloc_getDisplayName" str, str, var, int, int
; res = uloc_getDisplayName(localeID, inLocaleID, result, maxResultSize, err)
; localeID : LPCSTR -> "str"
; inLocaleID : LPCSTR -> "str"
; result : WORD* in/out -> "var"
; maxResultSize : INT -> "int"
; err : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	proculoc_getDisplayName = icuuc.NewProc("uloc_getDisplayName")
)

// localeID (LPCSTR), inLocaleID (LPCSTR), result (WORD* in/out), maxResultSize (INT), err (UErrorCode* in/out)
r1, _, err := proculoc_getDisplayName.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(localeID))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(inLocaleID))),
	uintptr(result),
	uintptr(maxResultSize),
	uintptr(err),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function uloc_getDisplayName(
  localeID: PAnsiChar;   // LPCSTR
  inLocaleID: PAnsiChar;   // LPCSTR
  result: Pointer;   // WORD* in/out
  maxResultSize: Integer;   // INT
  err: Pointer   // UErrorCode* in/out
): Integer; cdecl;
  external 'icuuc.dll' name 'uloc_getDisplayName';
result := DllCall("icuuc\uloc_getDisplayName"
    , "AStr", localeID   ; LPCSTR
    , "AStr", inLocaleID   ; LPCSTR
    , "Ptr", result   ; WORD* in/out
    , "Int", maxResultSize   ; INT
    , "Ptr", err   ; UErrorCode* in/out
    , "Cdecl Int")   ; return: INT
●uloc_getDisplayName(localeID, inLocaleID, result, maxResultSize, err) = DLL("icuuc.dll", "int uloc_getDisplayName(char*, char*, void*, int, void*)")
# 呼び出し: uloc_getDisplayName(localeID, inLocaleID, result, maxResultSize, err)
# localeID : LPCSTR -> "char*"
# inLocaleID : LPCSTR -> "char*"
# result : WORD* in/out -> "void*"
# maxResultSize : INT -> "int"
# err : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。