ホーム › Globalization › unum_formatDouble
unum_formatDouble
関数倍精度浮動小数点数を文字列に整形する。
シグネチャ
// icuin.dll
#include <windows.h>
INT unum_formatDouble(
const void** fmt,
DOUBLE number,
WORD* result,
INT resultLength,
UFieldPosition* pos,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| fmt | void** | in |
| number | DOUBLE | in |
| result | WORD* | inout |
| resultLength | INT | in |
| pos | UFieldPosition* | inout |
| status | UErrorCode* | inout |
戻り値の型: INT
各言語での呼び出し定義
// icuin.dll
#include <windows.h>
INT unum_formatDouble(
const void** fmt,
DOUBLE number,
WORD* result,
INT resultLength,
UFieldPosition* pos,
UErrorCode* status
);[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int unum_formatDouble(
IntPtr fmt, // void**
double number, // DOUBLE
ref ushort result, // WORD* in/out
int resultLength, // INT
IntPtr pos, // UFieldPosition* in/out
ref int status // UErrorCode* in/out
);<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function unum_formatDouble(
fmt As IntPtr, ' void**
number As Double, ' DOUBLE
ByRef result As UShort, ' WORD* in/out
resultLength As Integer, ' INT
pos As IntPtr, ' UFieldPosition* in/out
ByRef status As Integer ' UErrorCode* in/out
) As Integer
End Function' fmt : void**
' number : DOUBLE
' result : WORD* in/out
' resultLength : INT
' pos : UFieldPosition* in/out
' status : UErrorCode* in/out
Declare PtrSafe Function unum_formatDouble Lib "icuin" ( _
ByVal fmt As LongPtr, _
ByVal number As Double, _
ByRef result As Integer, _
ByVal resultLength As Long, _
ByVal pos As LongPtr, _
ByRef status As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
unum_formatDouble = ctypes.cdll.icuin.unum_formatDouble
unum_formatDouble.restype = ctypes.c_int
unum_formatDouble.argtypes = [
ctypes.c_void_p, # fmt : void**
ctypes.c_double, # number : DOUBLE
ctypes.POINTER(ctypes.c_ushort), # result : WORD* in/out
ctypes.c_int, # resultLength : INT
ctypes.c_void_p, # pos : UFieldPosition* in/out
ctypes.c_void_p, # status : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuin.dll')
unum_formatDouble = Fiddle::Function.new(
lib['unum_formatDouble'],
[
Fiddle::TYPE_VOIDP, # fmt : void**
Fiddle::TYPE_DOUBLE, # number : DOUBLE
Fiddle::TYPE_VOIDP, # result : WORD* in/out
Fiddle::TYPE_INT, # resultLength : INT
Fiddle::TYPE_VOIDP, # pos : UFieldPosition* in/out
Fiddle::TYPE_VOIDP, # status : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuin")]
extern "C" {
fn unum_formatDouble(
fmt: *const *const (), // void**
number: f64, // DOUBLE
result: *mut u16, // WORD* in/out
resultLength: i32, // INT
pos: *mut UFieldPosition, // UFieldPosition* in/out
status: *mut i32 // UErrorCode* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuin.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int unum_formatDouble(IntPtr fmt, double number, ref ushort result, int resultLength, IntPtr pos, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_unum_formatDouble' -Namespace Win32 -PassThru
# $api::unum_formatDouble(fmt, number, result, resultLength, pos, status)#uselib "icuin.dll"
#func global unum_formatDouble "unum_formatDouble" sptr, double, sptr, sptr, sptr, sptr
; unum_formatDouble fmt, number, varptr(result), resultLength, varptr(pos), status ; 戻り値は stat
; fmt : void** -> "sptr"
; number : DOUBLE -> "double"
; result : WORD* in/out -> "sptr"
; resultLength : INT -> "sptr"
; pos : UFieldPosition* in/out -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuin.dll" #cfunc global unum_formatDouble "unum_formatDouble" sptr, double, var, int, var, int ; res = unum_formatDouble(fmt, number, result, resultLength, pos, status) ; fmt : void** -> "sptr" ; number : DOUBLE -> "double" ; result : WORD* in/out -> "var" ; resultLength : INT -> "int" ; pos : UFieldPosition* in/out -> "var" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuin.dll" #cfunc global unum_formatDouble "unum_formatDouble" sptr, double, sptr, int, sptr, int ; res = unum_formatDouble(fmt, number, varptr(result), resultLength, varptr(pos), status) ; fmt : void** -> "sptr" ; number : DOUBLE -> "double" ; result : WORD* in/out -> "sptr" ; resultLength : INT -> "int" ; pos : UFieldPosition* in/out -> "sptr" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT unum_formatDouble(void** fmt, DOUBLE number, WORD* result, INT resultLength, UFieldPosition* pos, UErrorCode* status) #uselib "icuin.dll" #cfunc global unum_formatDouble "unum_formatDouble" intptr, double, var, int, var, int ; res = unum_formatDouble(fmt, number, result, resultLength, pos, status) ; fmt : void** -> "intptr" ; number : DOUBLE -> "double" ; result : WORD* in/out -> "var" ; resultLength : INT -> "int" ; pos : UFieldPosition* in/out -> "var" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT unum_formatDouble(void** fmt, DOUBLE number, WORD* result, INT resultLength, UFieldPosition* pos, UErrorCode* status) #uselib "icuin.dll" #cfunc global unum_formatDouble "unum_formatDouble" intptr, double, intptr, int, intptr, int ; res = unum_formatDouble(fmt, number, varptr(result), resultLength, varptr(pos), status) ; fmt : void** -> "intptr" ; number : DOUBLE -> "double" ; result : WORD* in/out -> "intptr" ; resultLength : INT -> "int" ; pos : UFieldPosition* in/out -> "intptr" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"math"
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuin = windows.NewLazySystemDLL("icuin.dll")
procunum_formatDouble = icuin.NewProc("unum_formatDouble")
)
// fmt (void**), number (DOUBLE), result (WORD* in/out), resultLength (INT), pos (UFieldPosition* in/out), status (UErrorCode* in/out)
r1, _, err := procunum_formatDouble.Call(
uintptr(fmt),
uintptr(math.Float64bits(number)),
uintptr(result),
uintptr(resultLength),
uintptr(pos),
uintptr(status),
)
_ = 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 unum_formatDouble(
fmt: Pointer; // void**
number: Double; // DOUBLE
result: Pointer; // WORD* in/out
resultLength: Integer; // INT
pos: Pointer; // UFieldPosition* in/out
status: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuin.dll' name 'unum_formatDouble';result := DllCall("icuin\unum_formatDouble"
, "Ptr", fmt ; void**
, "Double", number ; DOUBLE
, "Ptr", result ; WORD* in/out
, "Int", resultLength ; INT
, "Ptr", pos ; UFieldPosition* in/out
, "Ptr", status ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●unum_formatDouble(fmt, number, result, resultLength, pos, status) = DLL("icuin.dll", "int unum_formatDouble(void*, double, void*, int, void*, void*)")
# 呼び出し: unum_formatDouble(fmt, number, result, resultLength, pos, status)
# fmt : void** -> "void*"
# number : DOUBLE -> "double"
# result : WORD* in/out -> "void*"
# resultLength : INT -> "int"
# pos : UFieldPosition* in/out -> "void*"
# status : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。