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