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

unum_formatDecimal

関数
十進数文字列を整形する。
DLLicuin.dll呼出規約cdecl

シグネチャ

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

INT unum_formatDecimal(
    const void** fmt,
    LPCSTR number,
    INT length,
    WORD* result,
    INT resultLength,
    UFieldPosition* pos,
    UErrorCode* status
);

パラメーター

名前方向説明
fmtvoid**in整形に用いるUNumberFormatハンドル。
numberLPCSTRin整形対象の十進数文字列。NUL終端のASCII数字で指定する。
lengthINTin数値文字列の長さ。-1でNUL終端として扱う。
resultWORD*inout整形結果を受け取る出力バッファ。UTF-16のWORD配列。
resultLengthINTin結果バッファの容量(UTF-16単位)。0で必要長の照会も可能。
posUFieldPosition*inout整形位置情報を受け取るUFieldPosition構造体。NULL可。
statusUErrorCode*inoutICUのエラーコード。呼び出し前に成功値で初期化する。

戻り値の型: INT

各言語での呼び出し定義

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

INT unum_formatDecimal(
    const void** fmt,
    LPCSTR number,
    INT length,
    WORD* result,
    INT resultLength,
    UFieldPosition* pos,
    UErrorCode* status
);
[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int unum_formatDecimal(
    IntPtr fmt,   // void**
    [MarshalAs(UnmanagedType.LPStr)] string number,   // LPCSTR
    int length,   // INT
    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_formatDecimal(
    fmt As IntPtr,   ' void**
    <MarshalAs(UnmanagedType.LPStr)> number As String,   ' LPCSTR
    length As Integer,   ' INT
    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 : LPCSTR
' length : INT
' result : WORD* in/out
' resultLength : INT
' pos : UFieldPosition* in/out
' status : UErrorCode* in/out
Declare PtrSafe Function unum_formatDecimal Lib "icuin" ( _
    ByVal fmt As LongPtr, _
    ByVal number As String, _
    ByVal length As Long, _
    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_formatDecimal = ctypes.cdll.icuin.unum_formatDecimal
unum_formatDecimal.restype = ctypes.c_int
unum_formatDecimal.argtypes = [
    ctypes.c_void_p,  # fmt : void**
    wintypes.LPCSTR,  # number : LPCSTR
    ctypes.c_int,  # length : INT
    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_formatDecimal = Fiddle::Function.new(
  lib['unum_formatDecimal'],
  [
    Fiddle::TYPE_VOIDP,  # fmt : void**
    Fiddle::TYPE_VOIDP,  # number : LPCSTR
    Fiddle::TYPE_INT,  # length : INT
    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_formatDecimal(
        fmt: *const *const (),  // void**
        number: *const u8,  // LPCSTR
        length: i32,  // INT
        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_formatDecimal(IntPtr fmt, [MarshalAs(UnmanagedType.LPStr)] string number, int length, ref ushort result, int resultLength, IntPtr pos, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_unum_formatDecimal' -Namespace Win32 -PassThru
# $api::unum_formatDecimal(fmt, number, length, result, resultLength, pos, status)
#uselib "icuin.dll"
#func global unum_formatDecimal "unum_formatDecimal" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; unum_formatDecimal fmt, number, length, varptr(result), resultLength, varptr(pos), varptr(status)   ; 戻り値は stat
; fmt : void** -> "sptr"
; number : LPCSTR -> "sptr"
; length : INT -> "sptr"
; 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_formatDecimal "unum_formatDecimal" sptr, str, int, var, int, var, var
; res = unum_formatDecimal(fmt, number, length, result, resultLength, pos, status)
; fmt : void** -> "sptr"
; number : LPCSTR -> "str"
; length : INT -> "int"
; result : WORD* in/out -> "var"
; resultLength : INT -> "int"
; pos : UFieldPosition* in/out -> "var"
; status : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT unum_formatDecimal(void** fmt, LPCSTR number, INT length, WORD* result, INT resultLength, UFieldPosition* pos, UErrorCode* status)
#uselib "icuin.dll"
#cfunc global unum_formatDecimal "unum_formatDecimal" intptr, str, int, var, int, var, var
; res = unum_formatDecimal(fmt, number, length, result, resultLength, pos, status)
; fmt : void** -> "intptr"
; number : LPCSTR -> "str"
; length : INT -> "int"
; result : WORD* in/out -> "var"
; resultLength : INT -> "int"
; pos : UFieldPosition* in/out -> "var"
; status : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuin = windows.NewLazySystemDLL("icuin.dll")
	procunum_formatDecimal = icuin.NewProc("unum_formatDecimal")
)

// fmt (void**), number (LPCSTR), length (INT), result (WORD* in/out), resultLength (INT), pos (UFieldPosition* in/out), status (UErrorCode* in/out)
r1, _, err := procunum_formatDecimal.Call(
	uintptr(fmt),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(number))),
	uintptr(length),
	uintptr(result),
	uintptr(resultLength),
	uintptr(pos),
	uintptr(status),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function unum_formatDecimal(
  fmt: Pointer;   // void**
  number: PAnsiChar;   // LPCSTR
  length: Integer;   // INT
  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_formatDecimal';
result := DllCall("icuin\unum_formatDecimal"
    , "Ptr", fmt   ; void**
    , "AStr", number   ; LPCSTR
    , "Int", length   ; INT
    , "Ptr", result   ; WORD* in/out
    , "Int", resultLength   ; INT
    , "Ptr", pos   ; UFieldPosition* in/out
    , "Ptr", status   ; UErrorCode* in/out
    , "Cdecl Int")   ; return: INT
●unum_formatDecimal(fmt, number, length, result, resultLength, pos, status) = DLL("icuin.dll", "int unum_formatDecimal(void*, char*, int, void*, int, void*, void*)")
# 呼び出し: unum_formatDecimal(fmt, number, length, result, resultLength, pos, status)
# fmt : void** -> "void*"
# number : LPCSTR -> "char*"
# length : INT -> "int"
# 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`,…) を使用。
const std = @import("std");

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

typedef unum_formatDecimalNative = Int32 Function(Pointer<Void>, Pointer<Utf8>, Int32, Pointer<Uint16>, Int32, Pointer<Void>, Pointer<Int32>);
typedef unum_formatDecimalDart = int Function(Pointer<Void>, Pointer<Utf8>, int, Pointer<Uint16>, int, Pointer<Void>, Pointer<Int32>);
final unum_formatDecimal = DynamicLibrary.open('icuin.dll')
    .lookupFunction<unum_formatDecimalNative, unum_formatDecimalDart>('unum_formatDecimal');
// fmt : void** -> Pointer<Void>
// number : LPCSTR -> Pointer<Utf8>
// length : INT -> Int32
// result : WORD* in/out -> Pointer<Uint16>
// resultLength : INT -> Int32
// pos : UFieldPosition* in/out -> Pointer<Void>
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function unum_formatDecimal(
  fmt: Pointer;   // void**
  number: PAnsiChar;   // LPCSTR
  length: Integer;   // INT
  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_formatDecimal';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "unum_formatDecimal"
  c_unum_formatDecimal :: Ptr () -> CString -> Int32 -> Ptr Word16 -> Int32 -> Ptr () -> Ptr Int32 -> IO Int32
-- fmt : void** -> Ptr ()
-- number : LPCSTR -> CString
-- length : INT -> Int32
-- result : WORD* in/out -> Ptr Word16
-- resultLength : INT -> Int32
-- pos : UFieldPosition* in/out -> Ptr ()
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let unum_formatdecimal =
  foreign "unum_formatDecimal"
    ((ptr void) @-> string @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> (ptr void) @-> (ptr int32_t) @-> returning int32_t)
(* fmt : void** -> (ptr void) *)
(* number : LPCSTR -> string *)
(* length : INT -> int32_t *)
(* result : WORD* in/out -> (ptr uint16_t) *)
(* resultLength : INT -> int32_t *)
(* pos : UFieldPosition* in/out -> (ptr void) *)
(* status : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library icuin (t "icuin.dll"))
(cffi:use-foreign-library icuin)

(cffi:defcfun ("unum_formatDecimal" unum-format-decimal :convention :cdecl) :int32
  (fmt :pointer)   ; void**
  (number :string)   ; LPCSTR
  (length :int32)   ; INT
  (result :pointer)   ; WORD* in/out
  (result-length :int32)   ; INT
  (pos :pointer)   ; UFieldPosition* in/out
  (status :pointer))   ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $unum_formatDecimal = Win32::API::More->new('icuin',
    'int unum_formatDecimal(LPVOID fmt, LPCSTR number, int length, LPVOID result, int resultLength, LPVOID pos, LPVOID status)');
# my $ret = $unum_formatDecimal->Call($fmt, $number, $length, $result, $resultLength, $pos, $status);
# fmt : void** -> LPVOID
# number : LPCSTR -> LPCSTR
# length : INT -> int
# result : WORD* in/out -> LPVOID
# resultLength : INT -> int
# pos : UFieldPosition* in/out -> LPVOID
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型