ホーム › Globalization › ulistfmt_openForType
ulistfmt_openForType
関数種類と幅を指定してリストフォーマッタを開く。
シグネチャ
// icu.dll
#include <windows.h>
UListFormatter* ulistfmt_openForType(
LPCSTR locale,
UListFormatterType type,
UListFormatterWidth width,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| locale | LPCSTR | in | リスト書式化に用いるロケールの識別子文字列。 |
| type | UListFormatterType | in | リストの種類(and結合、or選択、単位列挙など)を指定する。 |
| width | UListFormatterWidth | in | 書式の幅(WIDE/SHORT/NARROW)を指定する。 |
| status | UErrorCode* | inout | エラーコードへのポインタ。書式化器生成の成否が反映される。 |
戻り値の型: UListFormatter*
各言語での呼び出し定義
// icu.dll
#include <windows.h>
UListFormatter* ulistfmt_openForType(
LPCSTR locale,
UListFormatterType type,
UListFormatterWidth width,
UErrorCode* status
);[DllImport("icu.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ulistfmt_openForType(
[MarshalAs(UnmanagedType.LPStr)] string locale, // LPCSTR
int type, // UListFormatterType
int width, // UListFormatterWidth
ref int status // UErrorCode* in/out
);<DllImport("icu.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ulistfmt_openForType(
<MarshalAs(UnmanagedType.LPStr)> locale As String, ' LPCSTR
type As Integer, ' UListFormatterType
width As Integer, ' UListFormatterWidth
ByRef status As Integer ' UErrorCode* in/out
) As IntPtr
End Function' locale : LPCSTR
' type : UListFormatterType
' width : UListFormatterWidth
' status : UErrorCode* in/out
Declare PtrSafe Function ulistfmt_openForType Lib "icu" ( _
ByVal locale As String, _
ByVal type As Long, _
ByVal width As Long, _
ByRef status As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ulistfmt_openForType = ctypes.cdll.icu.ulistfmt_openForType
ulistfmt_openForType.restype = ctypes.c_void_p
ulistfmt_openForType.argtypes = [
wintypes.LPCSTR, # locale : LPCSTR
ctypes.c_int, # type : UListFormatterType
ctypes.c_int, # width : UListFormatterWidth
ctypes.c_void_p, # status : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icu.dll')
ulistfmt_openForType = Fiddle::Function.new(
lib['ulistfmt_openForType'],
[
Fiddle::TYPE_VOIDP, # locale : LPCSTR
Fiddle::TYPE_INT, # type : UListFormatterType
Fiddle::TYPE_INT, # width : UListFormatterWidth
Fiddle::TYPE_VOIDP, # status : UErrorCode* in/out
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icu")]
extern "C" {
fn ulistfmt_openForType(
locale: *const u8, // LPCSTR
type: i32, // UListFormatterType
width: i32, // UListFormatterWidth
status: *mut i32 // UErrorCode* in/out
) -> *mut isize;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icu.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ulistfmt_openForType([MarshalAs(UnmanagedType.LPStr)] string locale, int type, int width, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icu_ulistfmt_openForType' -Namespace Win32 -PassThru
# $api::ulistfmt_openForType(locale, type, width, status)#uselib "icu.dll"
#func global ulistfmt_openForType "ulistfmt_openForType" sptr, sptr, sptr, sptr
; ulistfmt_openForType locale, type, width, varptr(status) ; 戻り値は stat
; locale : LPCSTR -> "sptr"
; type : UListFormatterType -> "sptr"
; width : UListFormatterWidth -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icu.dll" #cfunc global ulistfmt_openForType "ulistfmt_openForType" str, int, int, var ; res = ulistfmt_openForType(locale, type, width, status) ; locale : LPCSTR -> "str" ; type : UListFormatterType -> "int" ; width : UListFormatterWidth -> "int" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icu.dll" #cfunc global ulistfmt_openForType "ulistfmt_openForType" str, int, int, sptr ; res = ulistfmt_openForType(locale, type, width, varptr(status)) ; locale : LPCSTR -> "str" ; type : UListFormatterType -> "int" ; width : UListFormatterWidth -> "int" ; status : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; UListFormatter* ulistfmt_openForType(LPCSTR locale, UListFormatterType type, UListFormatterWidth width, UErrorCode* status) #uselib "icu.dll" #cfunc global ulistfmt_openForType "ulistfmt_openForType" str, int, int, var ; res = ulistfmt_openForType(locale, type, width, status) ; locale : LPCSTR -> "str" ; type : UListFormatterType -> "int" ; width : UListFormatterWidth -> "int" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; UListFormatter* ulistfmt_openForType(LPCSTR locale, UListFormatterType type, UListFormatterWidth width, UErrorCode* status) #uselib "icu.dll" #cfunc global ulistfmt_openForType "ulistfmt_openForType" str, int, int, intptr ; res = ulistfmt_openForType(locale, type, width, varptr(status)) ; locale : LPCSTR -> "str" ; type : UListFormatterType -> "int" ; width : UListFormatterWidth -> "int" ; status : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icu = windows.NewLazySystemDLL("icu.dll")
proculistfmt_openForType = icu.NewProc("ulistfmt_openForType")
)
// locale (LPCSTR), type (UListFormatterType), width (UListFormatterWidth), status (UErrorCode* in/out)
r1, _, err := proculistfmt_openForType.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(locale))),
uintptr(type),
uintptr(width),
uintptr(status),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // UListFormatter*function ulistfmt_openForType(
locale: PAnsiChar; // LPCSTR
type: Integer; // UListFormatterType
width: Integer; // UListFormatterWidth
status: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icu.dll' name 'ulistfmt_openForType';result := DllCall("icu\ulistfmt_openForType"
, "AStr", locale ; LPCSTR
, "Int", type ; UListFormatterType
, "Int", width ; UListFormatterWidth
, "Ptr", status ; UErrorCode* in/out
, "Cdecl Ptr") ; return: UListFormatter*●ulistfmt_openForType(locale, type, width, status) = DLL("icu.dll", "void* ulistfmt_openForType(char*, int, int, void*)")
# 呼び出し: ulistfmt_openForType(locale, type, width, status)
# locale : LPCSTR -> "char*"
# type : UListFormatterType -> "int"
# width : UListFormatterWidth -> "int"
# 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 "icu" fn ulistfmt_openForType(
locale: [*c]const u8, // LPCSTR
type: i32, // UListFormatterType
width: i32, // UListFormatterWidth
status: [*c]i32 // UErrorCode* in/out
) callconv(.c) [*c]isize;proc ulistfmt_openForType(
locale: cstring, # LPCSTR
`type`: int32, # UListFormatterType
width: int32, # UListFormatterWidth
status: ptr int32 # UErrorCode* in/out
): ptr int {.importc: "ulistfmt_openForType", cdecl, dynlib: "icu.dll".}pragma(lib, "icu");
extern(C)
ptrdiff_t* ulistfmt_openForType(
const(char)* locale, // LPCSTR
int type, // UListFormatterType
int width, // UListFormatterWidth
int* status // UErrorCode* in/out
);ccall((:ulistfmt_openForType, "icu.dll"), Ptr{Int},
(Cstring, Int32, Int32, Ptr{Int32}),
locale, type, width, status)
# locale : LPCSTR -> Cstring
# type : UListFormatterType -> Int32
# width : UListFormatterWidth -> Int32
# status : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
intptr_t* ulistfmt_openForType(
const char* locale,
int32_t type,
int32_t width,
int32_t* status);
]]
local icu = ffi.load("icu")
-- icu.ulistfmt_openForType(locale, type, width, status)
-- locale : LPCSTR
-- type : UListFormatterType
-- width : UListFormatterWidth
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icu.dll');
const ulistfmt_openForType = lib.func('__cdecl', 'ulistfmt_openForType', 'intptr_t *', ['str', 'int32_t', 'int32_t', 'int32_t *']);
// ulistfmt_openForType(locale, type, width, status)
// locale : LPCSTR -> 'str'
// type : UListFormatterType -> 'int32_t'
// width : UListFormatterWidth -> 'int32_t'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icu.dll", {
ulistfmt_openForType: { parameters: ["buffer", "i32", "i32", "pointer"], result: "pointer" },
});
// lib.symbols.ulistfmt_openForType(locale, type, width, status)
// locale : LPCSTR -> "buffer"
// type : UListFormatterType -> "i32"
// width : UListFormatterWidth -> "i32"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
intptr_t* ulistfmt_openForType(
const char* locale,
int32_t type,
int32_t width,
int32_t* status);
C, "icu.dll");
// $ffi->ulistfmt_openForType(locale, type, width, status);
// locale : LPCSTR
// type : UListFormatterType
// width : UListFormatterWidth
// 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 Icu extends Library {
Icu INSTANCE = Native.load("icu", Icu.class);
Pointer ulistfmt_openForType(
String locale, // LPCSTR
int type, // UListFormatterType
int width, // UListFormatterWidth
IntByReference status // UErrorCode* in/out
);
}@[Link("icu")]
lib Libicu
fun ulistfmt_openForType = ulistfmt_openForType(
locale : UInt8*, # LPCSTR
type_ : Int32, # UListFormatterType
width : Int32, # UListFormatterWidth
status : Int32* # UErrorCode* in/out
) : LibC::SSizeT*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ulistfmt_openForTypeNative = Pointer<IntPtr> Function(Pointer<Utf8>, Int32, Int32, Pointer<Int32>);
typedef ulistfmt_openForTypeDart = Pointer<IntPtr> Function(Pointer<Utf8>, int, int, Pointer<Int32>);
final ulistfmt_openForType = DynamicLibrary.open('icu.dll')
.lookupFunction<ulistfmt_openForTypeNative, ulistfmt_openForTypeDart>('ulistfmt_openForType');
// locale : LPCSTR -> Pointer<Utf8>
// type : UListFormatterType -> Int32
// width : UListFormatterWidth -> Int32
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ulistfmt_openForType(
locale: PAnsiChar; // LPCSTR
type: Integer; // UListFormatterType
width: Integer; // UListFormatterWidth
status: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icu.dll' name 'ulistfmt_openForType';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ulistfmt_openForType"
c_ulistfmt_openForType :: CString -> Int32 -> Int32 -> Ptr Int32 -> IO (Ptr CIntPtr)
-- locale : LPCSTR -> CString
-- type : UListFormatterType -> Int32
-- width : UListFormatterWidth -> Int32
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ulistfmt_openfortype =
foreign "ulistfmt_openForType"
(string @-> int32_t @-> int32_t @-> (ptr int32_t) @-> returning (ptr intptr_t))
(* locale : LPCSTR -> string *)
(* type : UListFormatterType -> int32_t *)
(* width : UListFormatterWidth -> int32_t *)
(* status : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icu (t "icu.dll"))
(cffi:use-foreign-library icu)
(cffi:defcfun ("ulistfmt_openForType" ulistfmt-open-for-type :convention :cdecl) :pointer
(locale :string) ; LPCSTR
(type :int32) ; UListFormatterType
(width :int32) ; UListFormatterWidth
(status :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ulistfmt_openForType = Win32::API::More->new('icu',
'LPVOID ulistfmt_openForType(LPCSTR locale, int type, int width, LPVOID status)');
# my $ret = $ulistfmt_openForType->Call($locale, $type, $width, $status);
# locale : LPCSTR -> LPCSTR
# type : UListFormatterType -> int
# width : UListFormatterWidth -> int
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。