Win32 API 日本語リファレンス
ホームGlobalization › u_strCaseCompare

u_strCaseCompare

関数
大文字小文字を無視して二つの文字列を比較する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

// icuuc.dll
#include <windows.h>

INT u_strCaseCompare(
    const WORD* s1,
    INT length1,
    const WORD* s2,
    INT length2,
    DWORD options,
    UErrorCode* pErrorCode
);

パラメーター

名前方向説明
s1WORD*in比較する第一UTF-16文字列へのポインタ。
length1INTins1の長さ(UChar単位)。-1の場合はNUL終端として扱う。
s2WORD*in比較する第二UTF-16文字列へのポインタ。
length2INTins2の長さ(UChar単位)。-1の場合はNUL終端として扱う。
optionsDWORDin比較オプションのビットフラグ。U_FOLD_CASE_DEFAULTやコードポイント順指定等を含む。
pErrorCodeUErrorCode*inoutエラーコードを受け取るUErrorCodeポインタ。大小無視の比較結果を返す。

戻り値の型: INT

各言語での呼び出し定義

// icuuc.dll
#include <windows.h>

INT u_strCaseCompare(
    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 u_strCaseCompare(
    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 u_strCaseCompare(
    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 u_strCaseCompare 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

u_strCaseCompare = ctypes.cdll.icuuc.u_strCaseCompare
u_strCaseCompare.restype = ctypes.c_int
u_strCaseCompare.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')
u_strCaseCompare = Fiddle::Function.new(
  lib['u_strCaseCompare'],
  [
    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 u_strCaseCompare(
        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 u_strCaseCompare(ref ushort s1, int length1, ref ushort s2, int length2, uint options, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_strCaseCompare' -Namespace Win32 -PassThru
# $api::u_strCaseCompare(s1, length1, s2, length2, options, pErrorCode)
#uselib "icuuc.dll"
#func global u_strCaseCompare "u_strCaseCompare" sptr, sptr, sptr, sptr, sptr, sptr
; u_strCaseCompare varptr(s1), length1, varptr(s2), length2, options, varptr(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 u_strCaseCompare "u_strCaseCompare" var, int, var, int, int, var
; res = u_strCaseCompare(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 -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT u_strCaseCompare(WORD* s1, INT length1, WORD* s2, INT length2, DWORD options, UErrorCode* pErrorCode)
#uselib "icuuc.dll"
#cfunc global u_strCaseCompare "u_strCaseCompare" var, int, var, int, int, var
; res = u_strCaseCompare(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 -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procu_strCaseCompare = icuuc.NewProc("u_strCaseCompare")
)

// s1 (WORD*), length1 (INT), s2 (WORD*), length2 (INT), options (DWORD), pErrorCode (UErrorCode* in/out)
r1, _, err := procu_strCaseCompare.Call(
	uintptr(s1),
	uintptr(length1),
	uintptr(s2),
	uintptr(length2),
	uintptr(options),
	uintptr(pErrorCode),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function u_strCaseCompare(
  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 'u_strCaseCompare';
result := DllCall("icuuc\u_strCaseCompare"
    , "Ptr", s1   ; WORD*
    , "Int", length1   ; INT
    , "Ptr", s2   ; WORD*
    , "Int", length2   ; INT
    , "UInt", options   ; DWORD
    , "Ptr", pErrorCode   ; UErrorCode* in/out
    , "Cdecl Int")   ; return: INT
●u_strCaseCompare(s1, length1, s2, length2, options, pErrorCode) = DLL("icuuc.dll", "int u_strCaseCompare(void*, int, void*, int, dword, void*)")
# 呼び出し: u_strCaseCompare(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`,…) を使用。
const std = @import("std");

extern "icuuc" fn u_strCaseCompare(
    s1: [*c]u16, // WORD*
    length1: i32, // INT
    s2: [*c]u16, // WORD*
    length2: i32, // INT
    options: u32, // DWORD
    pErrorCode: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;
proc u_strCaseCompare(
    s1: ptr uint16,  # WORD*
    length1: int32,  # INT
    s2: ptr uint16,  # WORD*
    length2: int32,  # INT
    options: uint32,  # DWORD
    pErrorCode: ptr int32  # UErrorCode* in/out
): int32 {.importc: "u_strCaseCompare", cdecl, dynlib: "icuuc.dll".}
pragma(lib, "icuuc");
extern(C)
int u_strCaseCompare(
    ushort* s1,   // WORD*
    int length1,   // INT
    ushort* s2,   // WORD*
    int length2,   // INT
    uint options,   // DWORD
    int* pErrorCode   // UErrorCode* in/out
);
ccall((:u_strCaseCompare, "icuuc.dll"), Int32,
      (Ptr{UInt16}, Int32, Ptr{UInt16}, Int32, UInt32, Ptr{Int32}),
      s1, length1, s2, length2, options, pErrorCode)
# s1 : WORD* -> Ptr{UInt16}
# length1 : INT -> Int32
# s2 : WORD* -> Ptr{UInt16}
# length2 : INT -> Int32
# options : DWORD -> UInt32
# pErrorCode : UErrorCode* in/out -> Ptr{Int32}
local ffi = require("ffi")
ffi.cdef[[
int32_t u_strCaseCompare(
    uint16_t* s1,
    int32_t length1,
    uint16_t* s2,
    int32_t length2,
    uint32_t options,
    int32_t* pErrorCode);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.u_strCaseCompare(s1, length1, s2, length2, options, pErrorCode)
-- s1 : WORD*
-- length1 : INT
-- s2 : WORD*
-- length2 : INT
-- options : DWORD
-- pErrorCode : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const u_strCaseCompare = lib.func('__cdecl', 'u_strCaseCompare', 'int32_t', ['uint16_t *', 'int32_t', 'uint16_t *', 'int32_t', 'uint32_t', 'int32_t *']);
// u_strCaseCompare(s1, length1, s2, length2, options, pErrorCode)
// s1 : WORD* -> 'uint16_t *'
// length1 : INT -> 'int32_t'
// s2 : WORD* -> 'uint16_t *'
// length2 : INT -> 'int32_t'
// options : DWORD -> 'uint32_t'
// pErrorCode : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuuc.dll", {
  u_strCaseCompare: { parameters: ["pointer", "i32", "pointer", "i32", "u32", "pointer"], result: "i32" },
});
// lib.symbols.u_strCaseCompare(s1, length1, s2, length2, options, pErrorCode)
// s1 : WORD* -> "pointer"
// length1 : INT -> "i32"
// s2 : WORD* -> "pointer"
// length2 : INT -> "i32"
// options : DWORD -> "u32"
// pErrorCode : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t u_strCaseCompare(
    uint16_t* s1,
    int32_t length1,
    uint16_t* s2,
    int32_t length2,
    uint32_t options,
    int32_t* pErrorCode);
C, "icuuc.dll");
// $ffi->u_strCaseCompare(s1, length1, s2, length2, options, pErrorCode);
// s1 : WORD*
// length1 : INT
// s2 : WORD*
// length2 : INT
// options : DWORD
// pErrorCode : 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 Icuuc extends Library {
    Icuuc INSTANCE = Native.load("icuuc", Icuuc.class);
    int u_strCaseCompare(
        ShortByReference s1,   // WORD*
        int length1,   // INT
        ShortByReference s2,   // WORD*
        int length2,   // INT
        int options,   // DWORD
        IntByReference pErrorCode   // UErrorCode* in/out
    );
}
@[Link("icuuc")]
lib Libicuuc
  fun u_strCaseCompare = u_strCaseCompare(
    s1 : UInt16*,   # WORD*
    length1 : Int32,   # INT
    s2 : UInt16*,   # WORD*
    length2 : Int32,   # INT
    options : UInt32,   # DWORD
    pErrorCode : Int32*   # UErrorCode* in/out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef u_strCaseCompareNative = Int32 Function(Pointer<Uint16>, Int32, Pointer<Uint16>, Int32, Uint32, Pointer<Int32>);
typedef u_strCaseCompareDart = int Function(Pointer<Uint16>, int, Pointer<Uint16>, int, int, Pointer<Int32>);
final u_strCaseCompare = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<u_strCaseCompareNative, u_strCaseCompareDart>('u_strCaseCompare');
// s1 : WORD* -> Pointer<Uint16>
// length1 : INT -> Int32
// s2 : WORD* -> Pointer<Uint16>
// length2 : INT -> Int32
// options : DWORD -> Uint32
// pErrorCode : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function u_strCaseCompare(
  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 'u_strCaseCompare';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "u_strCaseCompare"
  c_u_strCaseCompare :: Ptr Word16 -> Int32 -> Ptr Word16 -> Int32 -> Word32 -> Ptr Int32 -> IO Int32
-- s1 : WORD* -> Ptr Word16
-- length1 : INT -> Int32
-- s2 : WORD* -> Ptr Word16
-- length2 : INT -> Int32
-- options : DWORD -> Word32
-- pErrorCode : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let u_strcasecompare =
  foreign "u_strCaseCompare"
    ((ptr uint16_t) @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> uint32_t @-> (ptr int32_t) @-> returning int32_t)
(* s1 : WORD* -> (ptr uint16_t) *)
(* length1 : INT -> int32_t *)
(* s2 : WORD* -> (ptr uint16_t) *)
(* length2 : INT -> int32_t *)
(* options : DWORD -> uint32_t *)
(* pErrorCode : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)

(cffi:defcfun ("u_strCaseCompare" u-str-case-compare :convention :cdecl) :int32
  (s1 :pointer)   ; WORD*
  (length1 :int32)   ; INT
  (s2 :pointer)   ; WORD*
  (length2 :int32)   ; INT
  (options :uint32)   ; DWORD
  (p-error-code :pointer))   ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $u_strCaseCompare = Win32::API::More->new('icuuc',
    'int u_strCaseCompare(LPVOID s1, int length1, LPVOID s2, int length2, DWORD options, LPVOID pErrorCode)');
# my $ret = $u_strCaseCompare->Call($s1, $length1, $s2, $length2, $options, $pErrorCode);
# s1 : WORD* -> LPVOID
# length1 : INT -> int
# s2 : WORD* -> LPVOID
# length2 : INT -> int
# options : DWORD -> DWORD
# pErrorCode : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型