ホーム › Globalization › u_strspn
u_strspn
関数集合の文字のみが続く先頭部分の長さを返す。
シグネチャ
// icuuc.dll
#include <windows.h>
INT u_strspn(
const WORD* string,
const WORD* matchSet
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| string | WORD* | in |
| matchSet | WORD* | in |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT u_strspn(
const WORD* string,
const WORD* matchSet
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int u_strspn(
ref ushort string, // WORD*
ref ushort matchSet // WORD*
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function u_strspn(
ByRef [string] As UShort, ' WORD*
ByRef matchSet As UShort ' WORD*
) As Integer
End Function' string : WORD*
' matchSet : WORD*
Declare PtrSafe Function u_strspn 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_strspn = ctypes.cdll.icuuc.u_strspn
u_strspn.restype = ctypes.c_int
u_strspn.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_strspn = Fiddle::Function.new(
lib['u_strspn'],
[
Fiddle::TYPE_VOIDP, # string : WORD*
Fiddle::TYPE_VOIDP, # matchSet : WORD*
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn u_strspn(
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_strspn(ref ushort string, ref ushort matchSet);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_strspn' -Namespace Win32 -PassThru
# $api::u_strspn(string, matchSet)#uselib "icuuc.dll"
#func global u_strspn "u_strspn" sptr, sptr
; u_strspn varptr(string), varptr(matchSet) ; 戻り値は stat
; string : WORD* -> "sptr"
; matchSet : WORD* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global u_strspn "u_strspn" var, var ; res = u_strspn(string, matchSet) ; string : WORD* -> "var" ; matchSet : WORD* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global u_strspn "u_strspn" sptr, sptr ; res = u_strspn(varptr(string), varptr(matchSet)) ; string : WORD* -> "sptr" ; matchSet : WORD* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT u_strspn(WORD* string, WORD* matchSet) #uselib "icuuc.dll" #cfunc global u_strspn "u_strspn" var, var ; res = u_strspn(string, matchSet) ; string : WORD* -> "var" ; matchSet : WORD* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT u_strspn(WORD* string, WORD* matchSet) #uselib "icuuc.dll" #cfunc global u_strspn "u_strspn" intptr, intptr ; res = u_strspn(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_strspn = icuuc.NewProc("u_strspn")
)
// string (WORD*), matchSet (WORD*)
r1, _, err := procu_strspn.Call(
uintptr(string),
uintptr(matchSet),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction u_strspn(
string: Pointer; // WORD*
matchSet: Pointer // WORD*
): Integer; cdecl;
external 'icuuc.dll' name 'u_strspn';result := DllCall("icuuc\u_strspn"
, "Ptr", string ; WORD*
, "Ptr", matchSet ; WORD*
, "Cdecl Int") ; return: INT●u_strspn(string, matchSet) = DLL("icuuc.dll", "int u_strspn(void*, void*)")
# 呼び出し: u_strspn(string, matchSet)
# string : WORD* -> "void*"
# matchSet : WORD* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。