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

u_memchr32

関数
UChar領域内で指定コードポイントを先頭から検索する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

WORD* u_memchr32(
    const WORD* s,
    INT c,
    INT count
);

パラメーター

名前方向
sWORD*in
cINTin
countINTin

戻り値の型: WORD*

各言語での呼び出し定義

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

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

u_memchr32 = ctypes.cdll.icuuc.u_memchr32
u_memchr32.restype = ctypes.c_void_p
u_memchr32.argtypes = [
    ctypes.POINTER(ctypes.c_ushort),  # s : WORD*
    ctypes.c_int,  # c : INT
    ctypes.c_int,  # count : INT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procu_memchr32 = icuuc.NewProc("u_memchr32")
)

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