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表示名を取得する対象のロケールID。
inLocaleIDLPCSTRin表示に使う言語のロケールID。NULLで既定ロケール。
resultWORD*inoutロケール全体の表示名(UTF-16)を格納する出力バッファ。
maxResultSizeINTinresult バッファの容量(UChar単位)。
errUErrorCode*inoutICUエラーコードを受け渡すポインタ。U_ZERO_ERRORへ初期化が必要。

戻り値の型: 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, varptr(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, var
; 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 -> "var"
; ※出力/バッファ引数は 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, var
; 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 -> "var"
; ※出力/バッファ引数は 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`,…) を使用。
const std = @import("std");

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

typedef uloc_getDisplayNameNative = Int32 Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Uint16>, Int32, Pointer<Int32>);
typedef uloc_getDisplayNameDart = int Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Uint16>, int, Pointer<Int32>);
final uloc_getDisplayName = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<uloc_getDisplayNameNative, uloc_getDisplayNameDart>('uloc_getDisplayName');
// localeID : LPCSTR -> Pointer<Utf8>
// inLocaleID : LPCSTR -> Pointer<Utf8>
// result : WORD* in/out -> Pointer<Uint16>
// maxResultSize : INT -> Int32
// err : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "uloc_getDisplayName"
  c_uloc_getDisplayName :: CString -> CString -> Ptr Word16 -> Int32 -> Ptr Int32 -> IO Int32
-- localeID : LPCSTR -> CString
-- inLocaleID : LPCSTR -> CString
-- result : WORD* in/out -> Ptr Word16
-- maxResultSize : INT -> Int32
-- err : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let uloc_getdisplayname =
  foreign "uloc_getDisplayName"
    (string @-> string @-> (ptr uint16_t) @-> int32_t @-> (ptr int32_t) @-> returning int32_t)
(* localeID : LPCSTR -> string *)
(* inLocaleID : LPCSTR -> string *)
(* result : WORD* in/out -> (ptr uint16_t) *)
(* maxResultSize : 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 ("uloc_getDisplayName" uloc-get-display-name :convention :cdecl) :int32
  (locale-id :string)   ; LPCSTR
  (in-locale-id :string)   ; LPCSTR
  (result :pointer)   ; WORD* in/out
  (max-result-size :int32)   ; INT
  (err :pointer))   ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $uloc_getDisplayName = Win32::API::More->new('icuuc',
    'int uloc_getDisplayName(LPCSTR localeID, LPCSTR inLocaleID, LPVOID result, int maxResultSize, LPVOID err)');
# my $ret = $uloc_getDisplayName->Call($localeID, $inLocaleID, $result, $maxResultSize, $err);
# localeID : LPCSTR -> LPCSTR
# inLocaleID : LPCSTR -> LPCSTR
# result : WORD* in/out -> LPVOID
# maxResultSize : INT -> int
# err : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型