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