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

ucurr_getName

関数
指定通貨の表示名や記号を取得する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

WORD* ucurr_getName(
    const WORD* currency,
    LPCSTR locale,
    UCurrNameStyle nameStyle,
    CHAR* isChoiceFormat,
    INT* len,
    UErrorCode* ec
);

パラメーター

名前方向説明
currencyWORD*in3文字ISO 4217通貨コード(UTF-16)。
localeLPCSTRin表示名の言語を決めるロケールID。
nameStyleUCurrNameStylein名称の様式を指定するUCurrNameStyle(記号/正式名等)。
isChoiceFormatCHAR*inout結果がchoice形式か示すフラグを返す出力ポインタ。非推奨で常に偽。
lenINT*inout返す名称の長さを格納する出力ポインタ。
ecUErrorCode*inoutICUエラーコードを受け渡すポインタ。U_ZERO_ERRORへ初期化が必要。

戻り値の型: WORD*

各言語での呼び出し定義

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

WORD* ucurr_getName(
    const WORD* currency,
    LPCSTR locale,
    UCurrNameStyle nameStyle,
    CHAR* isChoiceFormat,
    INT* len,
    UErrorCode* ec
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ucurr_getName(
    ref ushort currency,   // WORD*
    [MarshalAs(UnmanagedType.LPStr)] string locale,   // LPCSTR
    int nameStyle,   // UCurrNameStyle
    IntPtr isChoiceFormat,   // CHAR* in/out
    ref int len,   // INT* in/out
    ref int ec   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucurr_getName(
    ByRef currency As UShort,   ' WORD*
    <MarshalAs(UnmanagedType.LPStr)> locale As String,   ' LPCSTR
    nameStyle As Integer,   ' UCurrNameStyle
    isChoiceFormat As IntPtr,   ' CHAR* in/out
    ByRef len As Integer,   ' INT* in/out
    ByRef ec As Integer   ' UErrorCode* in/out
) As IntPtr
End Function
' currency : WORD*
' locale : LPCSTR
' nameStyle : UCurrNameStyle
' isChoiceFormat : CHAR* in/out
' len : INT* in/out
' ec : UErrorCode* in/out
Declare PtrSafe Function ucurr_getName Lib "icuuc" ( _
    ByRef currency As Integer, _
    ByVal locale As String, _
    ByVal nameStyle As Long, _
    ByVal isChoiceFormat As LongPtr, _
    ByRef len As Long, _
    ByRef ec As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ucurr_getName = ctypes.cdll.icuuc.ucurr_getName
ucurr_getName.restype = ctypes.c_void_p
ucurr_getName.argtypes = [
    ctypes.POINTER(ctypes.c_ushort),  # currency : WORD*
    wintypes.LPCSTR,  # locale : LPCSTR
    ctypes.c_int,  # nameStyle : UCurrNameStyle
    ctypes.POINTER(ctypes.c_byte),  # isChoiceFormat : CHAR* in/out
    ctypes.POINTER(ctypes.c_int),  # len : INT* in/out
    ctypes.c_void_p,  # ec : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
ucurr_getName = Fiddle::Function.new(
  lib['ucurr_getName'],
  [
    Fiddle::TYPE_VOIDP,  # currency : WORD*
    Fiddle::TYPE_VOIDP,  # locale : LPCSTR
    Fiddle::TYPE_INT,  # nameStyle : UCurrNameStyle
    Fiddle::TYPE_VOIDP,  # isChoiceFormat : CHAR* in/out
    Fiddle::TYPE_VOIDP,  # len : INT* in/out
    Fiddle::TYPE_VOIDP,  # ec : UErrorCode* in/out
  ],
  Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn ucurr_getName(
        currency: *const u16,  // WORD*
        locale: *const u8,  // LPCSTR
        nameStyle: i32,  // UCurrNameStyle
        isChoiceFormat: *mut i8,  // CHAR* in/out
        len: *mut i32,  // INT* in/out
        ec: *mut i32  // UErrorCode* in/out
    ) -> *mut u16;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ucurr_getName(ref ushort currency, [MarshalAs(UnmanagedType.LPStr)] string locale, int nameStyle, IntPtr isChoiceFormat, ref int len, ref int ec);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucurr_getName' -Namespace Win32 -PassThru
# $api::ucurr_getName(currency, locale, nameStyle, isChoiceFormat, len, ec)
#uselib "icuuc.dll"
#func global ucurr_getName "ucurr_getName" sptr, sptr, sptr, sptr, sptr, sptr
; ucurr_getName varptr(currency), locale, nameStyle, varptr(isChoiceFormat), varptr(len), varptr(ec)   ; 戻り値は stat
; currency : WORD* -> "sptr"
; locale : LPCSTR -> "sptr"
; nameStyle : UCurrNameStyle -> "sptr"
; isChoiceFormat : CHAR* in/out -> "sptr"
; len : INT* in/out -> "sptr"
; ec : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global ucurr_getName "ucurr_getName" var, str, int, var, var, var
; res = ucurr_getName(currency, locale, nameStyle, isChoiceFormat, len, ec)
; currency : WORD* -> "var"
; locale : LPCSTR -> "str"
; nameStyle : UCurrNameStyle -> "int"
; isChoiceFormat : CHAR* in/out -> "var"
; len : INT* in/out -> "var"
; ec : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; WORD* ucurr_getName(WORD* currency, LPCSTR locale, UCurrNameStyle nameStyle, CHAR* isChoiceFormat, INT* len, UErrorCode* ec)
#uselib "icuuc.dll"
#cfunc global ucurr_getName "ucurr_getName" var, str, int, var, var, var
; res = ucurr_getName(currency, locale, nameStyle, isChoiceFormat, len, ec)
; currency : WORD* -> "var"
; locale : LPCSTR -> "str"
; nameStyle : UCurrNameStyle -> "int"
; isChoiceFormat : CHAR* in/out -> "var"
; len : INT* in/out -> "var"
; ec : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procucurr_getName = icuuc.NewProc("ucurr_getName")
)

// currency (WORD*), locale (LPCSTR), nameStyle (UCurrNameStyle), isChoiceFormat (CHAR* in/out), len (INT* in/out), ec (UErrorCode* in/out)
r1, _, err := procucurr_getName.Call(
	uintptr(currency),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(locale))),
	uintptr(nameStyle),
	uintptr(isChoiceFormat),
	uintptr(len),
	uintptr(ec),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WORD*
function ucurr_getName(
  currency: Pointer;   // WORD*
  locale: PAnsiChar;   // LPCSTR
  nameStyle: Integer;   // UCurrNameStyle
  isChoiceFormat: Pointer;   // CHAR* in/out
  len: Pointer;   // INT* in/out
  ec: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icuuc.dll' name 'ucurr_getName';
result := DllCall("icuuc\ucurr_getName"
    , "Ptr", currency   ; WORD*
    , "AStr", locale   ; LPCSTR
    , "Int", nameStyle   ; UCurrNameStyle
    , "Ptr", isChoiceFormat   ; CHAR* in/out
    , "Ptr", len   ; INT* in/out
    , "Ptr", ec   ; UErrorCode* in/out
    , "Cdecl Ptr")   ; return: WORD*
●ucurr_getName(currency, locale, nameStyle, isChoiceFormat, len, ec) = DLL("icuuc.dll", "void* ucurr_getName(void*, char*, int, void*, void*, void*)")
# 呼び出し: ucurr_getName(currency, locale, nameStyle, isChoiceFormat, len, ec)
# currency : WORD* -> "void*"
# locale : LPCSTR -> "char*"
# nameStyle : UCurrNameStyle -> "int"
# isChoiceFormat : CHAR* in/out -> "void*"
# len : INT* in/out -> "void*"
# ec : 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 ucurr_getName(
    currency: [*c]u16, // WORD*
    locale: [*c]const u8, // LPCSTR
    nameStyle: i32, // UCurrNameStyle
    isChoiceFormat: [*c]i8, // CHAR* in/out
    len: [*c]i32, // INT* in/out
    ec: [*c]i32 // UErrorCode* in/out
) callconv(.c) [*c]u16;
proc ucurr_getName(
    currency: ptr uint16,  # WORD*
    locale: cstring,  # LPCSTR
    nameStyle: int32,  # UCurrNameStyle
    isChoiceFormat: ptr int8,  # CHAR* in/out
    len: ptr int32,  # INT* in/out
    ec: ptr int32  # UErrorCode* in/out
): ptr uint16 {.importc: "ucurr_getName", cdecl, dynlib: "icuuc.dll".}
pragma(lib, "icuuc");
extern(C)
ushort* ucurr_getName(
    ushort* currency,   // WORD*
    const(char)* locale,   // LPCSTR
    int nameStyle,   // UCurrNameStyle
    byte* isChoiceFormat,   // CHAR* in/out
    int* len,   // INT* in/out
    int* ec   // UErrorCode* in/out
);
ccall((:ucurr_getName, "icuuc.dll"), Ptr{UInt16},
      (Ptr{UInt16}, Cstring, Int32, Ptr{Int8}, Ptr{Int32}, Ptr{Int32}),
      currency, locale, nameStyle, isChoiceFormat, len, ec)
# currency : WORD* -> Ptr{UInt16}
# locale : LPCSTR -> Cstring
# nameStyle : UCurrNameStyle -> Int32
# isChoiceFormat : CHAR* in/out -> Ptr{Int8}
# len : INT* in/out -> Ptr{Int32}
# ec : UErrorCode* in/out -> Ptr{Int32}
local ffi = require("ffi")
ffi.cdef[[
uint16_t* ucurr_getName(
    uint16_t* currency,
    const char* locale,
    int32_t nameStyle,
    int8_t* isChoiceFormat,
    int32_t* len,
    int32_t* ec);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.ucurr_getName(currency, locale, nameStyle, isChoiceFormat, len, ec)
-- currency : WORD*
-- locale : LPCSTR
-- nameStyle : UCurrNameStyle
-- isChoiceFormat : CHAR* in/out
-- len : INT* in/out
-- ec : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const ucurr_getName = lib.func('__cdecl', 'ucurr_getName', 'uint16_t *', ['uint16_t *', 'str', 'int32_t', 'int8_t *', 'int32_t *', 'int32_t *']);
// ucurr_getName(currency, locale, nameStyle, isChoiceFormat, len, ec)
// currency : WORD* -> 'uint16_t *'
// locale : LPCSTR -> 'str'
// nameStyle : UCurrNameStyle -> 'int32_t'
// isChoiceFormat : CHAR* in/out -> 'int8_t *'
// len : INT* in/out -> 'int32_t *'
// ec : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuuc.dll", {
  ucurr_getName: { parameters: ["pointer", "buffer", "i32", "pointer", "pointer", "pointer"], result: "pointer" },
});
// lib.symbols.ucurr_getName(currency, locale, nameStyle, isChoiceFormat, len, ec)
// currency : WORD* -> "pointer"
// locale : LPCSTR -> "buffer"
// nameStyle : UCurrNameStyle -> "i32"
// isChoiceFormat : CHAR* in/out -> "pointer"
// len : INT* in/out -> "pointer"
// ec : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint16_t* ucurr_getName(
    uint16_t* currency,
    const char* locale,
    int32_t nameStyle,
    int8_t* isChoiceFormat,
    int32_t* len,
    int32_t* ec);
C, "icuuc.dll");
// $ffi->ucurr_getName(currency, locale, nameStyle, isChoiceFormat, len, ec);
// currency : WORD*
// locale : LPCSTR
// nameStyle : UCurrNameStyle
// isChoiceFormat : CHAR* in/out
// len : INT* in/out
// ec : 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);
    Pointer ucurr_getName(
        ShortByReference currency,   // WORD*
        String locale,   // LPCSTR
        int nameStyle,   // UCurrNameStyle
        byte[] isChoiceFormat,   // CHAR* in/out
        IntByReference len,   // INT* in/out
        IntByReference ec   // UErrorCode* in/out
    );
}
@[Link("icuuc")]
lib Libicuuc
  fun ucurr_getName = ucurr_getName(
    currency : UInt16*,   # WORD*
    locale : UInt8*,   # LPCSTR
    nameStyle : Int32,   # UCurrNameStyle
    isChoiceFormat : Int8*,   # CHAR* in/out
    len : Int32*,   # INT* in/out
    ec : Int32*   # UErrorCode* in/out
  ) : UInt16*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ucurr_getNameNative = Pointer<Uint16> Function(Pointer<Uint16>, Pointer<Utf8>, Int32, Pointer<Int8>, Pointer<Int32>, Pointer<Int32>);
typedef ucurr_getNameDart = Pointer<Uint16> Function(Pointer<Uint16>, Pointer<Utf8>, int, Pointer<Int8>, Pointer<Int32>, Pointer<Int32>);
final ucurr_getName = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<ucurr_getNameNative, ucurr_getNameDart>('ucurr_getName');
// currency : WORD* -> Pointer<Uint16>
// locale : LPCSTR -> Pointer<Utf8>
// nameStyle : UCurrNameStyle -> Int32
// isChoiceFormat : CHAR* in/out -> Pointer<Int8>
// len : INT* in/out -> Pointer<Int32>
// ec : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ucurr_getName(
  currency: Pointer;   // WORD*
  locale: PAnsiChar;   // LPCSTR
  nameStyle: Integer;   // UCurrNameStyle
  isChoiceFormat: Pointer;   // CHAR* in/out
  len: Pointer;   // INT* in/out
  ec: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icuuc.dll' name 'ucurr_getName';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "ucurr_getName"
  c_ucurr_getName :: Ptr Word16 -> CString -> Int32 -> Ptr Int8 -> Ptr Int32 -> Ptr Int32 -> IO (Ptr Word16)
-- currency : WORD* -> Ptr Word16
-- locale : LPCSTR -> CString
-- nameStyle : UCurrNameStyle -> Int32
-- isChoiceFormat : CHAR* in/out -> Ptr Int8
-- len : INT* in/out -> Ptr Int32
-- ec : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ucurr_getname =
  foreign "ucurr_getName"
    ((ptr uint16_t) @-> string @-> int32_t @-> (ptr int8_t) @-> (ptr int32_t) @-> (ptr int32_t) @-> returning (ptr uint16_t))
(* currency : WORD* -> (ptr uint16_t) *)
(* locale : LPCSTR -> string *)
(* nameStyle : UCurrNameStyle -> int32_t *)
(* isChoiceFormat : CHAR* in/out -> (ptr int8_t) *)
(* len : INT* in/out -> (ptr int32_t) *)
(* ec : 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 ("ucurr_getName" ucurr-get-name :convention :cdecl) :pointer
  (currency :pointer)   ; WORD*
  (locale :string)   ; LPCSTR
  (name-style :int32)   ; UCurrNameStyle
  (is-choice-format :pointer)   ; CHAR* in/out
  (len :pointer)   ; INT* in/out
  (ec :pointer))   ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ucurr_getName = Win32::API::More->new('icuuc',
    'LPVOID ucurr_getName(LPVOID currency, LPCSTR locale, int nameStyle, LPVOID isChoiceFormat, LPVOID len, LPVOID ec)');
# my $ret = $ucurr_getName->Call($currency, $locale, $nameStyle, $isChoiceFormat, $len, $ec);
# currency : WORD* -> LPVOID
# locale : LPCSTR -> LPCSTR
# nameStyle : UCurrNameStyle -> int
# isChoiceFormat : CHAR* in/out -> LPVOID
# len : INT* in/out -> LPVOID
# ec : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型