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