ホーム › Globalization › u_memchr
u_memchr
関数UChar領域内で指定文字を先頭から検索する。
シグネチャ
// icuuc.dll
#include <windows.h>
WORD* u_memchr(
const WORD* s,
WORD c,
INT count
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| s | WORD* | in |
| c | WORD | in |
| count | INT | in |
戻り値の型: WORD*
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
WORD* u_memchr(
const WORD* s,
WORD c,
INT count
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr u_memchr(
ref ushort s, // WORD*
ushort c, // WORD
int count // INT
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function u_memchr(
ByRef s As UShort, ' WORD*
c As UShort, ' WORD
count As Integer ' INT
) As IntPtr
End Function' s : WORD*
' c : WORD
' count : INT
Declare PtrSafe Function u_memchr Lib "icuuc" ( _
ByRef s As Integer, _
ByVal c As Integer, _
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_memchr = ctypes.cdll.icuuc.u_memchr
u_memchr.restype = ctypes.c_void_p
u_memchr.argtypes = [
ctypes.POINTER(ctypes.c_ushort), # s : WORD*
ctypes.c_ushort, # c : WORD
ctypes.c_int, # count : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
u_memchr = Fiddle::Function.new(
lib['u_memchr'],
[
Fiddle::TYPE_VOIDP, # s : WORD*
-Fiddle::TYPE_SHORT, # c : WORD
Fiddle::TYPE_INT, # count : INT
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn u_memchr(
s: *const u16, // WORD*
c: u16, // WORD
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_memchr(ref ushort s, ushort c, int count);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_memchr' -Namespace Win32 -PassThru
# $api::u_memchr(s, c, count)#uselib "icuuc.dll"
#func global u_memchr "u_memchr" sptr, sptr, sptr
; u_memchr varptr(s), c, count ; 戻り値は stat
; s : WORD* -> "sptr"
; c : WORD -> "sptr"
; count : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global u_memchr "u_memchr" var, int, int ; res = u_memchr(s, c, count) ; s : WORD* -> "var" ; c : WORD -> "int" ; count : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global u_memchr "u_memchr" sptr, int, int ; res = u_memchr(varptr(s), c, count) ; s : WORD* -> "sptr" ; c : WORD -> "int" ; count : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WORD* u_memchr(WORD* s, WORD c, INT count) #uselib "icuuc.dll" #cfunc global u_memchr "u_memchr" var, int, int ; res = u_memchr(s, c, count) ; s : WORD* -> "var" ; c : WORD -> "int" ; count : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WORD* u_memchr(WORD* s, WORD c, INT count) #uselib "icuuc.dll" #cfunc global u_memchr "u_memchr" intptr, int, int ; res = u_memchr(varptr(s), c, count) ; s : WORD* -> "intptr" ; c : WORD -> "int" ; count : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procu_memchr = icuuc.NewProc("u_memchr")
)
// s (WORD*), c (WORD), count (INT)
r1, _, err := procu_memchr.Call(
uintptr(s),
uintptr(c),
uintptr(count),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WORD*function u_memchr(
s: Pointer; // WORD*
c: Word; // WORD
count: Integer // INT
): Pointer; cdecl;
external 'icuuc.dll' name 'u_memchr';result := DllCall("icuuc\u_memchr"
, "Ptr", s ; WORD*
, "UShort", c ; WORD
, "Int", count ; INT
, "Cdecl Ptr") ; return: WORD*●u_memchr(s, c, count) = DLL("icuuc.dll", "void* u_memchr(void*, int, int)")
# 呼び出し: u_memchr(s, c, count)
# s : WORD* -> "void*"
# c : WORD -> "int"
# count : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。