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