ホーム › Globalization › utext_openUTF8
utext_openUTF8
関数UTF-8文字列に対するUTextを開く。
シグネチャ
// icuuc.dll
#include <windows.h>
UText* utext_openUTF8(
UText* ut,
LPCSTR s,
LONGLONG length,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ut | UText* | inout |
| s | LPCSTR | in |
| length | LONGLONG | in |
| status | UErrorCode* | inout |
戻り値の型: UText*
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
UText* utext_openUTF8(
UText* ut,
LPCSTR s,
LONGLONG length,
UErrorCode* status
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr utext_openUTF8(
IntPtr ut, // UText* in/out
[MarshalAs(UnmanagedType.LPStr)] string s, // LPCSTR
long length, // LONGLONG
ref int status // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function utext_openUTF8(
ut As IntPtr, ' UText* in/out
<MarshalAs(UnmanagedType.LPStr)> s As String, ' LPCSTR
length As Long, ' LONGLONG
ByRef status As Integer ' UErrorCode* in/out
) As IntPtr
End Function' ut : UText* in/out
' s : LPCSTR
' length : LONGLONG
' status : UErrorCode* in/out
Declare PtrSafe Function utext_openUTF8 Lib "icuuc" ( _
ByVal ut As LongPtr, _
ByVal s As String, _
ByVal length As LongLong, _
ByRef status As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
utext_openUTF8 = ctypes.cdll.icuuc.utext_openUTF8
utext_openUTF8.restype = ctypes.c_void_p
utext_openUTF8.argtypes = [
ctypes.c_void_p, # ut : UText* in/out
wintypes.LPCSTR, # s : LPCSTR
ctypes.c_longlong, # length : LONGLONG
ctypes.c_void_p, # status : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
utext_openUTF8 = Fiddle::Function.new(
lib['utext_openUTF8'],
[
Fiddle::TYPE_VOIDP, # ut : UText* in/out
Fiddle::TYPE_VOIDP, # s : LPCSTR
Fiddle::TYPE_LONG_LONG, # length : LONGLONG
Fiddle::TYPE_VOIDP, # status : UErrorCode* in/out
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn utext_openUTF8(
ut: *mut UText, // UText* in/out
s: *const u8, // LPCSTR
length: i64, // LONGLONG
status: *mut i32 // UErrorCode* in/out
) -> *mut UText;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr utext_openUTF8(IntPtr ut, [MarshalAs(UnmanagedType.LPStr)] string s, long length, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_utext_openUTF8' -Namespace Win32 -PassThru
# $api::utext_openUTF8(ut, s, length, status)#uselib "icuuc.dll"
#func global utext_openUTF8 "utext_openUTF8" sptr, sptr, sptr, sptr
; utext_openUTF8 varptr(ut), s, length, status ; 戻り値は stat
; ut : UText* in/out -> "sptr"
; s : LPCSTR -> "sptr"
; length : LONGLONG -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global utext_openUTF8 "utext_openUTF8" var, str, int64, int ; res = utext_openUTF8(ut, s, length, status) ; ut : UText* in/out -> "var" ; s : LPCSTR -> "str" ; length : LONGLONG -> "int64" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。#uselib "icuuc.dll" #cfunc global utext_openUTF8 "utext_openUTF8" sptr, str, int64, int ; res = utext_openUTF8(varptr(ut), s, length, status) ; ut : UText* in/out -> "sptr" ; s : LPCSTR -> "str" ; length : LONGLONG -> "int64" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; UText* utext_openUTF8(UText* ut, LPCSTR s, LONGLONG length, UErrorCode* status) #uselib "icuuc.dll" #cfunc global utext_openUTF8 "utext_openUTF8" var, str, int64, int ; res = utext_openUTF8(ut, s, length, status) ; ut : UText* in/out -> "var" ; s : LPCSTR -> "str" ; length : LONGLONG -> "int64" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; UText* utext_openUTF8(UText* ut, LPCSTR s, LONGLONG length, UErrorCode* status) #uselib "icuuc.dll" #cfunc global utext_openUTF8 "utext_openUTF8" intptr, str, int64, int ; res = utext_openUTF8(varptr(ut), s, length, status) ; ut : UText* in/out -> "intptr" ; s : LPCSTR -> "str" ; length : LONGLONG -> "int64" ; status : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procutext_openUTF8 = icuuc.NewProc("utext_openUTF8")
)
// ut (UText* in/out), s (LPCSTR), length (LONGLONG), status (UErrorCode* in/out)
r1, _, err := procutext_openUTF8.Call(
uintptr(ut),
uintptr(unsafe.Pointer(windows.BytePtrFromString(s))),
uintptr(length),
uintptr(status),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // UText*function utext_openUTF8(
ut: Pointer; // UText* in/out
s: PAnsiChar; // LPCSTR
length: Int64; // LONGLONG
status: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icuuc.dll' name 'utext_openUTF8';result := DllCall("icuuc\utext_openUTF8"
, "Ptr", ut ; UText* in/out
, "AStr", s ; LPCSTR
, "Int64", length ; LONGLONG
, "Ptr", status ; UErrorCode* in/out
, "Cdecl Ptr") ; return: UText*●utext_openUTF8(ut, s, length, status) = DLL("icuuc.dll", "void* utext_openUTF8(void*, char*, int64, void*)")
# 呼び出し: utext_openUTF8(ut, s, length, status)
# ut : UText* in/out -> "void*"
# s : LPCSTR -> "char*"
# length : LONGLONG -> "int64"
# status : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。