ホーム › Globalization › ucnvsel_selectForUTF8
ucnvsel_selectForUTF8
関数UTF-8文字列を符号化できるコンバータ名を列挙する。
シグネチャ
// icuuc.dll
#include <windows.h>
UEnumeration* ucnvsel_selectForUTF8(
const UConverterSelector* sel,
LPCSTR s,
INT length,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| sel | UConverterSelector* | in |
| s | LPCSTR | in |
| length | INT | in |
| status | UErrorCode* | inout |
戻り値の型: UEnumeration*
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
UEnumeration* ucnvsel_selectForUTF8(
const UConverterSelector* sel,
LPCSTR s,
INT length,
UErrorCode* status
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ucnvsel_selectForUTF8(
ref IntPtr sel, // UConverterSelector*
[MarshalAs(UnmanagedType.LPStr)] string s, // LPCSTR
int length, // INT
ref int status // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucnvsel_selectForUTF8(
ByRef sel As IntPtr, ' UConverterSelector*
<MarshalAs(UnmanagedType.LPStr)> s As String, ' LPCSTR
length As Integer, ' INT
ByRef status As Integer ' UErrorCode* in/out
) As IntPtr
End Function' sel : UConverterSelector*
' s : LPCSTR
' length : INT
' status : UErrorCode* in/out
Declare PtrSafe Function ucnvsel_selectForUTF8 Lib "icuuc" ( _
ByRef sel As LongPtr, _
ByVal s As String, _
ByVal length 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
ucnvsel_selectForUTF8 = ctypes.cdll.icuuc.ucnvsel_selectForUTF8
ucnvsel_selectForUTF8.restype = ctypes.c_void_p
ucnvsel_selectForUTF8.argtypes = [
ctypes.c_void_p, # sel : UConverterSelector*
wintypes.LPCSTR, # s : LPCSTR
ctypes.c_int, # length : INT
ctypes.c_void_p, # status : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
ucnvsel_selectForUTF8 = Fiddle::Function.new(
lib['ucnvsel_selectForUTF8'],
[
Fiddle::TYPE_VOIDP, # sel : UConverterSelector*
Fiddle::TYPE_VOIDP, # s : LPCSTR
Fiddle::TYPE_INT, # length : INT
Fiddle::TYPE_VOIDP, # status : UErrorCode* in/out
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn ucnvsel_selectForUTF8(
sel: *const isize, // UConverterSelector*
s: *const u8, // LPCSTR
length: i32, // INT
status: *mut i32 // UErrorCode* in/out
) -> *mut isize;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ucnvsel_selectForUTF8(ref IntPtr sel, [MarshalAs(UnmanagedType.LPStr)] string s, int length, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucnvsel_selectForUTF8' -Namespace Win32 -PassThru
# $api::ucnvsel_selectForUTF8(sel, s, length, status)#uselib "icuuc.dll"
#func global ucnvsel_selectForUTF8 "ucnvsel_selectForUTF8" sptr, sptr, sptr, sptr
; ucnvsel_selectForUTF8 sel, s, length, status ; 戻り値は stat
; sel : UConverterSelector* -> "sptr"
; s : LPCSTR -> "sptr"
; length : INT -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "icuuc.dll"
#cfunc global ucnvsel_selectForUTF8 "ucnvsel_selectForUTF8" int, str, int, int
; res = ucnvsel_selectForUTF8(sel, s, length, status)
; sel : UConverterSelector* -> "int"
; s : LPCSTR -> "str"
; length : INT -> "int"
; status : UErrorCode* in/out -> "int"; UEnumeration* ucnvsel_selectForUTF8(UConverterSelector* sel, LPCSTR s, INT length, UErrorCode* status)
#uselib "icuuc.dll"
#cfunc global ucnvsel_selectForUTF8 "ucnvsel_selectForUTF8" int, str, int, int
; res = ucnvsel_selectForUTF8(sel, s, length, status)
; sel : UConverterSelector* -> "int"
; s : LPCSTR -> "str"
; length : INT -> "int"
; status : UErrorCode* in/out -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procucnvsel_selectForUTF8 = icuuc.NewProc("ucnvsel_selectForUTF8")
)
// sel (UConverterSelector*), s (LPCSTR), length (INT), status (UErrorCode* in/out)
r1, _, err := procucnvsel_selectForUTF8.Call(
uintptr(sel),
uintptr(unsafe.Pointer(windows.BytePtrFromString(s))),
uintptr(length),
uintptr(status),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // UEnumeration*function ucnvsel_selectForUTF8(
sel: Pointer; // UConverterSelector*
s: PAnsiChar; // LPCSTR
length: Integer; // INT
status: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icuuc.dll' name 'ucnvsel_selectForUTF8';result := DllCall("icuuc\ucnvsel_selectForUTF8"
, "Ptr", sel ; UConverterSelector*
, "AStr", s ; LPCSTR
, "Int", length ; INT
, "Ptr", status ; UErrorCode* in/out
, "Cdecl Ptr") ; return: UEnumeration*●ucnvsel_selectForUTF8(sel, s, length, status) = DLL("icuuc.dll", "void* ucnvsel_selectForUTF8(void*, char*, int, void*)")
# 呼び出し: ucnvsel_selectForUTF8(sel, s, length, status)
# sel : UConverterSelector* -> "void*"
# s : LPCSTR -> "char*"
# length : INT -> "int"
# status : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。