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

uset_resemblesPattern

関数
文字列がUSetパターンらしいかを判定する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

CHAR uset_resemblesPattern(
    const WORD* pattern,
    INT patternLength,
    INT pos
);

パラメーター

名前方向説明
patternWORD*in集合パターンらしいか判定する対象の文字列(UTF-16)へのポインタ。
patternLengthINTinpatternの長さ(UChar単位)。NUL終端なら-1を指定できる。
posINTin判定を開始するpattern内のインデックス位置。

戻り値の型: CHAR

各言語での呼び出し定義

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

CHAR uset_resemblesPattern(
    const WORD* pattern,
    INT patternLength,
    INT pos
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern sbyte uset_resemblesPattern(
    ref ushort pattern,   // WORD*
    int patternLength,   // INT
    int pos   // INT
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function uset_resemblesPattern(
    ByRef pattern As UShort,   ' WORD*
    patternLength As Integer,   ' INT
    pos As Integer   ' INT
) As SByte
End Function
' pattern : WORD*
' patternLength : INT
' pos : INT
Declare PtrSafe Function uset_resemblesPattern Lib "icuuc" ( _
    ByRef pattern As Integer, _
    ByVal patternLength As Long, _
    ByVal pos As Long) As Byte
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

uset_resemblesPattern = ctypes.cdll.icuuc.uset_resemblesPattern
uset_resemblesPattern.restype = ctypes.c_byte
uset_resemblesPattern.argtypes = [
    ctypes.POINTER(ctypes.c_ushort),  # pattern : WORD*
    ctypes.c_int,  # patternLength : INT
    ctypes.c_int,  # pos : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
uset_resemblesPattern = Fiddle::Function.new(
  lib['uset_resemblesPattern'],
  [
    Fiddle::TYPE_VOIDP,  # pattern : WORD*
    Fiddle::TYPE_INT,  # patternLength : INT
    Fiddle::TYPE_INT,  # pos : INT
  ],
  Fiddle::TYPE_CHAR, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn uset_resemblesPattern(
        pattern: *const u16,  // WORD*
        patternLength: i32,  // INT
        pos: i32  // INT
    ) -> i8;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern sbyte uset_resemblesPattern(ref ushort pattern, int patternLength, int pos);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_uset_resemblesPattern' -Namespace Win32 -PassThru
# $api::uset_resemblesPattern(pattern, patternLength, pos)
#uselib "icuuc.dll"
#func global uset_resemblesPattern "uset_resemblesPattern" sptr, sptr, sptr
; uset_resemblesPattern varptr(pattern), patternLength, pos   ; 戻り値は stat
; pattern : WORD* -> "sptr"
; patternLength : INT -> "sptr"
; pos : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global uset_resemblesPattern "uset_resemblesPattern" var, int, int
; res = uset_resemblesPattern(pattern, patternLength, pos)
; pattern : WORD* -> "var"
; patternLength : INT -> "int"
; pos : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; CHAR uset_resemblesPattern(WORD* pattern, INT patternLength, INT pos)
#uselib "icuuc.dll"
#cfunc global uset_resemblesPattern "uset_resemblesPattern" var, int, int
; res = uset_resemblesPattern(pattern, patternLength, pos)
; pattern : WORD* -> "var"
; patternLength : INT -> "int"
; pos : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procuset_resemblesPattern = icuuc.NewProc("uset_resemblesPattern")
)

// pattern (WORD*), patternLength (INT), pos (INT)
r1, _, err := procuset_resemblesPattern.Call(
	uintptr(pattern),
	uintptr(patternLength),
	uintptr(pos),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // CHAR
function uset_resemblesPattern(
  pattern: Pointer;   // WORD*
  patternLength: Integer;   // INT
  pos: Integer   // INT
): Shortint; cdecl;
  external 'icuuc.dll' name 'uset_resemblesPattern';
result := DllCall("icuuc\uset_resemblesPattern"
    , "Ptr", pattern   ; WORD*
    , "Int", patternLength   ; INT
    , "Int", pos   ; INT
    , "Cdecl Char")   ; return: CHAR
●uset_resemblesPattern(pattern, patternLength, pos) = DLL("icuuc.dll", "char uset_resemblesPattern(void*, int, int)")
# 呼び出し: uset_resemblesPattern(pattern, patternLength, pos)
# pattern : WORD* -> "void*"
# patternLength : INT -> "int"
# pos : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。
const std = @import("std");

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

typedef uset_resemblesPatternNative = Int8 Function(Pointer<Uint16>, Int32, Int32);
typedef uset_resemblesPatternDart = int Function(Pointer<Uint16>, int, int);
final uset_resemblesPattern = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<uset_resemblesPatternNative, uset_resemblesPatternDart>('uset_resemblesPattern');
// pattern : WORD* -> Pointer<Uint16>
// patternLength : INT -> Int32
// pos : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function uset_resemblesPattern(
  pattern: Pointer;   // WORD*
  patternLength: Integer;   // INT
  pos: Integer   // INT
): Shortint; cdecl;
  external 'icuuc.dll' name 'uset_resemblesPattern';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "uset_resemblesPattern"
  c_uset_resemblesPattern :: Ptr Word16 -> Int32 -> Int32 -> IO Int8
-- pattern : WORD* -> Ptr Word16
-- patternLength : INT -> Int32
-- pos : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let uset_resemblespattern =
  foreign "uset_resemblesPattern"
    ((ptr uint16_t) @-> int32_t @-> int32_t @-> returning int8_t)
(* pattern : WORD* -> (ptr uint16_t) *)
(* patternLength : INT -> int32_t *)
(* pos : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)

(cffi:defcfun ("uset_resemblesPattern" uset-resembles-pattern :convention :cdecl) :int8
  (pattern :pointer)   ; WORD*
  (pattern-length :int32)   ; INT
  (pos :int32))   ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $uset_resemblesPattern = Win32::API::More->new('icuuc',
    'char uset_resemblesPattern(LPVOID pattern, int patternLength, int pos)');
# my $ret = $uset_resemblesPattern->Call($pattern, $patternLength, $pos);
# pattern : WORD* -> LPVOID
# patternLength : INT -> int
# pos : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。