ホーム › Globalization › ucurr_forLocaleAndDate
ucurr_forLocaleAndDate
関数指定ロケールと日付で有効な通貨コードを取得する。
シグネチャ
// icuuc.dll
#include <windows.h>
INT ucurr_forLocaleAndDate(
LPCSTR locale,
DOUBLE date,
INT index,
WORD* buff,
INT buffCapacity,
UErrorCode* ec
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| locale | LPCSTR | in | 通貨を求める対象のロケールID。 |
| date | DOUBLE | in | 通貨を求める対象日時(UDate, 1970年起点ミリ秒)。 |
| index | INT | in | 同日時に複数通貨がある場合の0始まり選択インデックス。 |
| 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_forLocaleAndDate(
LPCSTR locale,
DOUBLE date,
INT index,
WORD* buff,
INT buffCapacity,
UErrorCode* ec
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int ucurr_forLocaleAndDate(
[MarshalAs(UnmanagedType.LPStr)] string locale, // LPCSTR
double date, // DOUBLE
int index, // INT
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_forLocaleAndDate(
<MarshalAs(UnmanagedType.LPStr)> locale As String, ' LPCSTR
[date] As Double, ' DOUBLE
index As Integer, ' INT
ByRef buff As UShort, ' WORD* in/out
buffCapacity As Integer, ' INT
ByRef ec As Integer ' UErrorCode* in/out
) As Integer
End Function' locale : LPCSTR
' date : DOUBLE
' index : INT
' buff : WORD* in/out
' buffCapacity : INT
' ec : UErrorCode* in/out
Declare PtrSafe Function ucurr_forLocaleAndDate Lib "icuuc" ( _
ByVal locale As String, _
ByVal date As Double, _
ByVal index As Long, _
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_forLocaleAndDate = ctypes.cdll.icuuc.ucurr_forLocaleAndDate
ucurr_forLocaleAndDate.restype = ctypes.c_int
ucurr_forLocaleAndDate.argtypes = [
wintypes.LPCSTR, # locale : LPCSTR
ctypes.c_double, # date : DOUBLE
ctypes.c_int, # index : INT
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_forLocaleAndDate = Fiddle::Function.new(
lib['ucurr_forLocaleAndDate'],
[
Fiddle::TYPE_VOIDP, # locale : LPCSTR
Fiddle::TYPE_DOUBLE, # date : DOUBLE
Fiddle::TYPE_INT, # index : INT
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_forLocaleAndDate(
locale: *const u8, // LPCSTR
date: f64, // DOUBLE
index: i32, // INT
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_forLocaleAndDate([MarshalAs(UnmanagedType.LPStr)] string locale, double date, int index, ref ushort buff, int buffCapacity, ref int ec);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucurr_forLocaleAndDate' -Namespace Win32 -PassThru
# $api::ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec)#uselib "icuuc.dll"
#func global ucurr_forLocaleAndDate "ucurr_forLocaleAndDate" sptr, double, sptr, sptr, sptr, sptr
; ucurr_forLocaleAndDate locale, date, index, varptr(buff), buffCapacity, varptr(ec) ; 戻り値は stat
; locale : LPCSTR -> "sptr"
; date : DOUBLE -> "double"
; index : INT -> "sptr"
; buff : WORD* in/out -> "sptr"
; buffCapacity : INT -> "sptr"
; ec : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global ucurr_forLocaleAndDate "ucurr_forLocaleAndDate" str, double, int, var, int, var ; res = ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec) ; locale : LPCSTR -> "str" ; date : DOUBLE -> "double" ; index : INT -> "int" ; buff : WORD* in/out -> "var" ; buffCapacity : INT -> "int" ; ec : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global ucurr_forLocaleAndDate "ucurr_forLocaleAndDate" str, double, int, sptr, int, sptr ; res = ucurr_forLocaleAndDate(locale, date, index, varptr(buff), buffCapacity, varptr(ec)) ; locale : LPCSTR -> "str" ; date : DOUBLE -> "double" ; index : INT -> "int" ; buff : WORD* in/out -> "sptr" ; buffCapacity : INT -> "int" ; ec : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT ucurr_forLocaleAndDate(LPCSTR locale, DOUBLE date, INT index, WORD* buff, INT buffCapacity, UErrorCode* ec) #uselib "icuuc.dll" #cfunc global ucurr_forLocaleAndDate "ucurr_forLocaleAndDate" str, double, int, var, int, var ; res = ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec) ; locale : LPCSTR -> "str" ; date : DOUBLE -> "double" ; index : INT -> "int" ; buff : WORD* in/out -> "var" ; buffCapacity : INT -> "int" ; ec : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT ucurr_forLocaleAndDate(LPCSTR locale, DOUBLE date, INT index, WORD* buff, INT buffCapacity, UErrorCode* ec) #uselib "icuuc.dll" #cfunc global ucurr_forLocaleAndDate "ucurr_forLocaleAndDate" str, double, int, intptr, int, intptr ; res = ucurr_forLocaleAndDate(locale, date, index, varptr(buff), buffCapacity, varptr(ec)) ; locale : LPCSTR -> "str" ; date : DOUBLE -> "double" ; index : INT -> "int" ; buff : WORD* in/out -> "intptr" ; buffCapacity : INT -> "int" ; ec : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"math"
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procucurr_forLocaleAndDate = icuuc.NewProc("ucurr_forLocaleAndDate")
)
// locale (LPCSTR), date (DOUBLE), index (INT), buff (WORD* in/out), buffCapacity (INT), ec (UErrorCode* in/out)
r1, _, err := procucurr_forLocaleAndDate.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(locale))),
uintptr(math.Float64bits(date)),
uintptr(index),
uintptr(buff),
uintptr(buffCapacity),
uintptr(ec),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INT
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。function ucurr_forLocaleAndDate(
locale: PAnsiChar; // LPCSTR
date: Double; // DOUBLE
index: Integer; // INT
buff: Pointer; // WORD* in/out
buffCapacity: Integer; // INT
ec: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'ucurr_forLocaleAndDate';result := DllCall("icuuc\ucurr_forLocaleAndDate"
, "AStr", locale ; LPCSTR
, "Double", date ; DOUBLE
, "Int", index ; INT
, "Ptr", buff ; WORD* in/out
, "Int", buffCapacity ; INT
, "Ptr", ec ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec) = DLL("icuuc.dll", "int ucurr_forLocaleAndDate(char*, double, int, void*, int, void*)")
# 呼び出し: ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec)
# locale : LPCSTR -> "char*"
# date : DOUBLE -> "double"
# index : INT -> "int"
# 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_forLocaleAndDate(
locale: [*c]const u8, // LPCSTR
date: f64, // DOUBLE
index: i32, // INT
buff: [*c]u16, // WORD* in/out
buffCapacity: i32, // INT
ec: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;proc ucurr_forLocaleAndDate(
locale: cstring, # LPCSTR
date: float64, # DOUBLE
index: int32, # INT
buff: ptr uint16, # WORD* in/out
buffCapacity: int32, # INT
ec: ptr int32 # UErrorCode* in/out
): int32 {.importc: "ucurr_forLocaleAndDate", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
int ucurr_forLocaleAndDate(
const(char)* locale, // LPCSTR
double date, // DOUBLE
int index, // INT
ushort* buff, // WORD* in/out
int buffCapacity, // INT
int* ec // UErrorCode* in/out
);ccall((:ucurr_forLocaleAndDate, "icuuc.dll"), Int32,
(Cstring, Float64, Int32, Ptr{UInt16}, Int32, Ptr{Int32}),
locale, date, index, buff, buffCapacity, ec)
# locale : LPCSTR -> Cstring
# date : DOUBLE -> Float64
# index : INT -> Int32
# buff : WORD* in/out -> Ptr{UInt16}
# buffCapacity : INT -> Int32
# ec : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
int32_t ucurr_forLocaleAndDate(
const char* locale,
double date,
int32_t index,
uint16_t* buff,
int32_t buffCapacity,
int32_t* ec);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec)
-- locale : LPCSTR
-- date : DOUBLE
-- index : INT
-- 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_forLocaleAndDate = lib.func('__cdecl', 'ucurr_forLocaleAndDate', 'int32_t', ['str', 'double', 'int32_t', 'uint16_t *', 'int32_t', 'int32_t *']);
// ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec)
// locale : LPCSTR -> 'str'
// date : DOUBLE -> 'double'
// index : INT -> 'int32_t'
// 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_forLocaleAndDate: { parameters: ["buffer", "f64", "i32", "pointer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec)
// locale : LPCSTR -> "buffer"
// date : DOUBLE -> "f64"
// index : INT -> "i32"
// 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_forLocaleAndDate(
const char* locale,
double date,
int32_t index,
uint16_t* buff,
int32_t buffCapacity,
int32_t* ec);
C, "icuuc.dll");
// $ffi->ucurr_forLocaleAndDate(locale, date, index, buff, buffCapacity, ec);
// locale : LPCSTR
// date : DOUBLE
// index : INT
// 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_forLocaleAndDate(
String locale, // LPCSTR
double date, // DOUBLE
int index, // INT
ShortByReference buff, // WORD* in/out
int buffCapacity, // INT
IntByReference ec // UErrorCode* in/out
);
}@[Link("icuuc")]
lib Libicuuc
fun ucurr_forLocaleAndDate = ucurr_forLocaleAndDate(
locale : UInt8*, # LPCSTR
date : Float64, # DOUBLE
index : Int32, # INT
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_forLocaleAndDateNative = Int32 Function(Pointer<Utf8>, Double, Int32, Pointer<Uint16>, Int32, Pointer<Int32>);
typedef ucurr_forLocaleAndDateDart = int Function(Pointer<Utf8>, double, int, Pointer<Uint16>, int, Pointer<Int32>);
final ucurr_forLocaleAndDate = DynamicLibrary.open('icuuc.dll')
.lookupFunction<ucurr_forLocaleAndDateNative, ucurr_forLocaleAndDateDart>('ucurr_forLocaleAndDate');
// locale : LPCSTR -> Pointer<Utf8>
// date : DOUBLE -> Double
// index : INT -> Int32
// buff : WORD* in/out -> Pointer<Uint16>
// buffCapacity : INT -> Int32
// ec : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ucurr_forLocaleAndDate(
locale: PAnsiChar; // LPCSTR
date: Double; // DOUBLE
index: Integer; // INT
buff: Pointer; // WORD* in/out
buffCapacity: Integer; // INT
ec: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'ucurr_forLocaleAndDate';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ucurr_forLocaleAndDate"
c_ucurr_forLocaleAndDate :: CString -> CDouble -> Int32 -> Ptr Word16 -> Int32 -> Ptr Int32 -> IO Int32
-- locale : LPCSTR -> CString
-- date : DOUBLE -> CDouble
-- index : INT -> Int32
-- 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_forlocaleanddate =
foreign "ucurr_forLocaleAndDate"
(string @-> double @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> (ptr int32_t) @-> returning int32_t)
(* locale : LPCSTR -> string *)
(* date : DOUBLE -> double *)
(* index : INT -> int32_t *)
(* 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_forLocaleAndDate" ucurr-for-locale-and-date :convention :cdecl) :int32
(locale :string) ; LPCSTR
(date :double) ; DOUBLE
(index :int32) ; INT
(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_forLocaleAndDate = Win32::API::More->new('icuuc',
'int ucurr_forLocaleAndDate(LPCSTR locale, double date, int index, LPVOID buff, int buffCapacity, LPVOID ec)');
# my $ret = $ucurr_forLocaleAndDate->Call($locale, $date, $index, $buff, $buffCapacity, $ec);
# locale : LPCSTR -> LPCSTR
# date : DOUBLE -> double
# index : INT -> int
# buff : WORD* in/out -> LPVOID
# buffCapacity : INT -> int
# ec : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型