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