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