ホーム › Globalization › u_strcasecmp
u_strcasecmp
関数大文字小文字を無視して文字列全体を比較する。
シグネチャ
// icuuc.dll
#include <windows.h>
INT u_strcasecmp(
const WORD* s1,
const WORD* s2,
DWORD options
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| s1 | WORD* | in | 比較する第一NUL終端UTF-16文字列へのポインタ。 |
| s2 | WORD* | in | 比較する第二NUL終端UTF-16文字列へのポインタ。 |
| options | DWORD | in | ケースフォールディングのビットフラグ。U_FOLD_CASE_DEFAULT等を指定する。大小無視で比較する。 |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT u_strcasecmp(
const WORD* s1,
const WORD* s2,
DWORD options
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int u_strcasecmp(
ref ushort s1, // WORD*
ref ushort s2, // WORD*
uint options // DWORD
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function u_strcasecmp(
ByRef s1 As UShort, ' WORD*
ByRef s2 As UShort, ' WORD*
options As UInteger ' DWORD
) As Integer
End Function' s1 : WORD*
' s2 : WORD*
' options : DWORD
Declare PtrSafe Function u_strcasecmp Lib "icuuc" ( _
ByRef s1 As Integer, _
ByRef s2 As Integer, _
ByVal options As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
u_strcasecmp = ctypes.cdll.icuuc.u_strcasecmp
u_strcasecmp.restype = ctypes.c_int
u_strcasecmp.argtypes = [
ctypes.POINTER(ctypes.c_ushort), # s1 : WORD*
ctypes.POINTER(ctypes.c_ushort), # s2 : WORD*
wintypes.DWORD, # options : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
u_strcasecmp = Fiddle::Function.new(
lib['u_strcasecmp'],
[
Fiddle::TYPE_VOIDP, # s1 : WORD*
Fiddle::TYPE_VOIDP, # s2 : WORD*
-Fiddle::TYPE_INT, # options : DWORD
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn u_strcasecmp(
s1: *const u16, // WORD*
s2: *const u16, // WORD*
options: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int u_strcasecmp(ref ushort s1, ref ushort s2, uint options);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_strcasecmp' -Namespace Win32 -PassThru
# $api::u_strcasecmp(s1, s2, options)#uselib "icuuc.dll"
#func global u_strcasecmp "u_strcasecmp" sptr, sptr, sptr
; u_strcasecmp varptr(s1), varptr(s2), options ; 戻り値は stat
; s1 : WORD* -> "sptr"
; s2 : WORD* -> "sptr"
; options : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global u_strcasecmp "u_strcasecmp" var, var, int ; res = u_strcasecmp(s1, s2, options) ; s1 : WORD* -> "var" ; s2 : WORD* -> "var" ; options : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global u_strcasecmp "u_strcasecmp" sptr, sptr, int ; res = u_strcasecmp(varptr(s1), varptr(s2), options) ; s1 : WORD* -> "sptr" ; s2 : WORD* -> "sptr" ; options : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT u_strcasecmp(WORD* s1, WORD* s2, DWORD options) #uselib "icuuc.dll" #cfunc global u_strcasecmp "u_strcasecmp" var, var, int ; res = u_strcasecmp(s1, s2, options) ; s1 : WORD* -> "var" ; s2 : WORD* -> "var" ; options : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT u_strcasecmp(WORD* s1, WORD* s2, DWORD options) #uselib "icuuc.dll" #cfunc global u_strcasecmp "u_strcasecmp" intptr, intptr, int ; res = u_strcasecmp(varptr(s1), varptr(s2), options) ; s1 : WORD* -> "intptr" ; s2 : WORD* -> "intptr" ; options : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procu_strcasecmp = icuuc.NewProc("u_strcasecmp")
)
// s1 (WORD*), s2 (WORD*), options (DWORD)
r1, _, err := procu_strcasecmp.Call(
uintptr(s1),
uintptr(s2),
uintptr(options),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction u_strcasecmp(
s1: Pointer; // WORD*
s2: Pointer; // WORD*
options: DWORD // DWORD
): Integer; cdecl;
external 'icuuc.dll' name 'u_strcasecmp';result := DllCall("icuuc\u_strcasecmp"
, "Ptr", s1 ; WORD*
, "Ptr", s2 ; WORD*
, "UInt", options ; DWORD
, "Cdecl Int") ; return: INT●u_strcasecmp(s1, s2, options) = DLL("icuuc.dll", "int u_strcasecmp(void*, void*, dword)")
# 呼び出し: u_strcasecmp(s1, s2, options)
# s1 : WORD* -> "void*"
# s2 : WORD* -> "void*"
# options : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "icuuc" fn u_strcasecmp(
s1: [*c]u16, // WORD*
s2: [*c]u16, // WORD*
options: u32 // DWORD
) callconv(.c) i32;proc u_strcasecmp(
s1: ptr uint16, # WORD*
s2: ptr uint16, # WORD*
options: uint32 # DWORD
): int32 {.importc: "u_strcasecmp", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
int u_strcasecmp(
ushort* s1, // WORD*
ushort* s2, // WORD*
uint options // DWORD
);ccall((:u_strcasecmp, "icuuc.dll"), Int32,
(Ptr{UInt16}, Ptr{UInt16}, UInt32),
s1, s2, options)
# s1 : WORD* -> Ptr{UInt16}
# s2 : WORD* -> Ptr{UInt16}
# options : DWORD -> UInt32local ffi = require("ffi")
ffi.cdef[[
int32_t u_strcasecmp(
uint16_t* s1,
uint16_t* s2,
uint32_t options);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.u_strcasecmp(s1, s2, options)
-- s1 : WORD*
-- s2 : WORD*
-- options : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const u_strcasecmp = lib.func('__cdecl', 'u_strcasecmp', 'int32_t', ['uint16_t *', 'uint16_t *', 'uint32_t']);
// u_strcasecmp(s1, s2, options)
// s1 : WORD* -> 'uint16_t *'
// s2 : WORD* -> 'uint16_t *'
// options : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
u_strcasecmp: { parameters: ["pointer", "pointer", "u32"], result: "i32" },
});
// lib.symbols.u_strcasecmp(s1, s2, options)
// s1 : WORD* -> "pointer"
// s2 : WORD* -> "pointer"
// options : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t u_strcasecmp(
uint16_t* s1,
uint16_t* s2,
uint32_t options);
C, "icuuc.dll");
// $ffi->u_strcasecmp(s1, s2, options);
// s1 : WORD*
// s2 : WORD*
// options : DWORD
// 構造体/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_strcasecmp(
ShortByReference s1, // WORD*
ShortByReference s2, // WORD*
int options // DWORD
);
}@[Link("icuuc")]
lib Libicuuc
fun u_strcasecmp = u_strcasecmp(
s1 : UInt16*, # WORD*
s2 : UInt16*, # WORD*
options : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef u_strcasecmpNative = Int32 Function(Pointer<Uint16>, Pointer<Uint16>, Uint32);
typedef u_strcasecmpDart = int Function(Pointer<Uint16>, Pointer<Uint16>, int);
final u_strcasecmp = DynamicLibrary.open('icuuc.dll')
.lookupFunction<u_strcasecmpNative, u_strcasecmpDart>('u_strcasecmp');
// s1 : WORD* -> Pointer<Uint16>
// s2 : WORD* -> Pointer<Uint16>
// options : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function u_strcasecmp(
s1: Pointer; // WORD*
s2: Pointer; // WORD*
options: DWORD // DWORD
): Integer; cdecl;
external 'icuuc.dll' name 'u_strcasecmp';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "u_strcasecmp"
c_u_strcasecmp :: Ptr Word16 -> Ptr Word16 -> Word32 -> IO Int32
-- s1 : WORD* -> Ptr Word16
-- s2 : WORD* -> Ptr Word16
-- options : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let u_strcasecmp =
foreign "u_strcasecmp"
((ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* s1 : WORD* -> (ptr uint16_t) *)
(* s2 : WORD* -> (ptr uint16_t) *)
(* options : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)
(cffi:defcfun ("u_strcasecmp" u-strcasecmp :convention :cdecl) :int32
(s1 :pointer) ; WORD*
(s2 :pointer) ; WORD*
(options :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $u_strcasecmp = Win32::API::More->new('icuuc',
'int u_strcasecmp(LPVOID s1, LPVOID s2, DWORD options)');
# my $ret = $u_strcasecmp->Call($s1, $s2, $options);
# s1 : WORD* -> LPVOID
# s2 : WORD* -> LPVOID
# options : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。