ホーム › Globalization › unorm_compare
unorm_compare
関数二つの文字列を正規化を考慮して比較する。
シグネチャ
// icuuc.dll
#include <windows.h>
INT unorm_compare(
const WORD* s1,
INT length1,
const WORD* s2,
INT length2,
DWORD options,
UErrorCode* pErrorCode
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| s1 | WORD* | in |
| length1 | INT | in |
| s2 | WORD* | in |
| length2 | INT | in |
| options | DWORD | in |
| pErrorCode | UErrorCode* | inout |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT unorm_compare(
const WORD* s1,
INT length1,
const WORD* s2,
INT length2,
DWORD options,
UErrorCode* pErrorCode
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int unorm_compare(
ref ushort s1, // WORD*
int length1, // INT
ref ushort s2, // WORD*
int length2, // INT
uint options, // DWORD
ref int pErrorCode // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function unorm_compare(
ByRef s1 As UShort, ' WORD*
length1 As Integer, ' INT
ByRef s2 As UShort, ' WORD*
length2 As Integer, ' INT
options As UInteger, ' DWORD
ByRef pErrorCode As Integer ' UErrorCode* in/out
) As Integer
End Function' s1 : WORD*
' length1 : INT
' s2 : WORD*
' length2 : INT
' options : DWORD
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function unorm_compare Lib "icuuc" ( _
ByRef s1 As Integer, _
ByVal length1 As Long, _
ByRef s2 As Integer, _
ByVal length2 As Long, _
ByVal options As Long, _
ByRef pErrorCode As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
unorm_compare = ctypes.cdll.icuuc.unorm_compare
unorm_compare.restype = ctypes.c_int
unorm_compare.argtypes = [
ctypes.POINTER(ctypes.c_ushort), # s1 : WORD*
ctypes.c_int, # length1 : INT
ctypes.POINTER(ctypes.c_ushort), # s2 : WORD*
ctypes.c_int, # length2 : INT
wintypes.DWORD, # options : DWORD
ctypes.c_void_p, # pErrorCode : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
unorm_compare = Fiddle::Function.new(
lib['unorm_compare'],
[
Fiddle::TYPE_VOIDP, # s1 : WORD*
Fiddle::TYPE_INT, # length1 : INT
Fiddle::TYPE_VOIDP, # s2 : WORD*
Fiddle::TYPE_INT, # length2 : INT
-Fiddle::TYPE_INT, # options : DWORD
Fiddle::TYPE_VOIDP, # pErrorCode : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn unorm_compare(
s1: *const u16, // WORD*
length1: i32, // INT
s2: *const u16, // WORD*
length2: i32, // INT
options: u32, // DWORD
pErrorCode: *mut i32 // UErrorCode* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int unorm_compare(ref ushort s1, int length1, ref ushort s2, int length2, uint options, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_unorm_compare' -Namespace Win32 -PassThru
# $api::unorm_compare(s1, length1, s2, length2, options, pErrorCode)#uselib "icuuc.dll"
#func global unorm_compare "unorm_compare" sptr, sptr, sptr, sptr, sptr, sptr
; unorm_compare varptr(s1), length1, varptr(s2), length2, options, pErrorCode ; 戻り値は stat
; s1 : WORD* -> "sptr"
; length1 : INT -> "sptr"
; s2 : WORD* -> "sptr"
; length2 : INT -> "sptr"
; options : DWORD -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global unorm_compare "unorm_compare" var, int, var, int, int, int ; res = unorm_compare(s1, length1, s2, length2, options, pErrorCode) ; s1 : WORD* -> "var" ; length1 : INT -> "int" ; s2 : WORD* -> "var" ; length2 : INT -> "int" ; options : DWORD -> "int" ; pErrorCode : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global unorm_compare "unorm_compare" sptr, int, sptr, int, int, int ; res = unorm_compare(varptr(s1), length1, varptr(s2), length2, options, pErrorCode) ; s1 : WORD* -> "sptr" ; length1 : INT -> "int" ; s2 : WORD* -> "sptr" ; length2 : INT -> "int" ; options : DWORD -> "int" ; pErrorCode : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT unorm_compare(WORD* s1, INT length1, WORD* s2, INT length2, DWORD options, UErrorCode* pErrorCode) #uselib "icuuc.dll" #cfunc global unorm_compare "unorm_compare" var, int, var, int, int, int ; res = unorm_compare(s1, length1, s2, length2, options, pErrorCode) ; s1 : WORD* -> "var" ; length1 : INT -> "int" ; s2 : WORD* -> "var" ; length2 : INT -> "int" ; options : DWORD -> "int" ; pErrorCode : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT unorm_compare(WORD* s1, INT length1, WORD* s2, INT length2, DWORD options, UErrorCode* pErrorCode) #uselib "icuuc.dll" #cfunc global unorm_compare "unorm_compare" intptr, int, intptr, int, int, int ; res = unorm_compare(varptr(s1), length1, varptr(s2), length2, options, pErrorCode) ; s1 : WORD* -> "intptr" ; length1 : INT -> "int" ; s2 : WORD* -> "intptr" ; length2 : INT -> "int" ; options : DWORD -> "int" ; pErrorCode : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procunorm_compare = icuuc.NewProc("unorm_compare")
)
// s1 (WORD*), length1 (INT), s2 (WORD*), length2 (INT), options (DWORD), pErrorCode (UErrorCode* in/out)
r1, _, err := procunorm_compare.Call(
uintptr(s1),
uintptr(length1),
uintptr(s2),
uintptr(length2),
uintptr(options),
uintptr(pErrorCode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction unorm_compare(
s1: Pointer; // WORD*
length1: Integer; // INT
s2: Pointer; // WORD*
length2: Integer; // INT
options: DWORD; // DWORD
pErrorCode: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'unorm_compare';result := DllCall("icuuc\unorm_compare"
, "Ptr", s1 ; WORD*
, "Int", length1 ; INT
, "Ptr", s2 ; WORD*
, "Int", length2 ; INT
, "UInt", options ; DWORD
, "Ptr", pErrorCode ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●unorm_compare(s1, length1, s2, length2, options, pErrorCode) = DLL("icuuc.dll", "int unorm_compare(void*, int, void*, int, dword, void*)")
# 呼び出し: unorm_compare(s1, length1, s2, length2, options, pErrorCode)
# s1 : WORD* -> "void*"
# length1 : INT -> "int"
# s2 : WORD* -> "void*"
# length2 : INT -> "int"
# options : DWORD -> "dword"
# pErrorCode : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。