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

u_strcspn

関数
集合の文字が現れない先頭部分の長さを返す。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

INT u_strcspn(
    const WORD* string,
    const WORD* matchSet
);

パラメーター

名前方向
stringWORD*in
matchSetWORD*in

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // INT
function 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`,…) を使用。