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

u_strchr32

関数
文字列中で指定コードポイントを先頭から検索する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

WORD* u_strchr32(
    const WORD* s,
    INT c
);

パラメーター

名前方向説明
sWORD*in検索対象のNUL終端UTF-16文字列へのポインタ。
cINTin検索する単一コードポイント(補助文字対応)。最初の出現位置を返す。

戻り値の型: WORD*

各言語での呼び出し定義

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

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

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

lib = Fiddle.dlopen('icuuc.dll')
u_strchr32 = Fiddle::Function.new(
  lib['u_strchr32'],
  [
    Fiddle::TYPE_VOIDP,  # s : WORD*
    Fiddle::TYPE_INT,  # c : INT
  ],
  Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn u_strchr32(
        s: *const u16,  // WORD*
        c: 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_strchr32(ref ushort s, int c);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_strchr32' -Namespace Win32 -PassThru
# $api::u_strchr32(s, c)
#uselib "icuuc.dll"
#func global u_strchr32 "u_strchr32" sptr, sptr
; u_strchr32 varptr(s), c   ; 戻り値は stat
; s : WORD* -> "sptr"
; c : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global u_strchr32 "u_strchr32" var, int
; res = u_strchr32(s, c)
; s : WORD* -> "var"
; c : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; WORD* u_strchr32(WORD* s, INT c)
#uselib "icuuc.dll"
#cfunc global u_strchr32 "u_strchr32" var, int
; res = u_strchr32(s, c)
; s : WORD* -> "var"
; c : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procu_strchr32 = icuuc.NewProc("u_strchr32")
)

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

extern "icuuc" fn u_strchr32(
    s: [*c]u16, // WORD*
    c: i32 // INT
) callconv(.c) [*c]u16;
proc u_strchr32(
    s: ptr uint16,  # WORD*
    c: int32  # INT
): ptr uint16 {.importc: "u_strchr32", cdecl, dynlib: "icuuc.dll".}
pragma(lib, "icuuc");
extern(C)
ushort* u_strchr32(
    ushort* s,   // WORD*
    int c   // INT
);
ccall((:u_strchr32, "icuuc.dll"), Ptr{UInt16},
      (Ptr{UInt16}, Int32),
      s, c)
# s : WORD* -> Ptr{UInt16}
# c : INT -> Int32
local ffi = require("ffi")
ffi.cdef[[
uint16_t* u_strchr32(
    uint16_t* s,
    int32_t c);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.u_strchr32(s, c)
-- s : WORD*
-- c : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const u_strchr32 = lib.func('__cdecl', 'u_strchr32', 'uint16_t *', ['uint16_t *', 'int32_t']);
// u_strchr32(s, c)
// s : WORD* -> 'uint16_t *'
// c : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuuc.dll", {
  u_strchr32: { parameters: ["pointer", "i32"], result: "pointer" },
});
// lib.symbols.u_strchr32(s, c)
// s : WORD* -> "pointer"
// c : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint16_t* u_strchr32(
    uint16_t* s,
    int32_t c);
C, "icuuc.dll");
// $ffi->u_strchr32(s, c);
// s : WORD*
// c : INT
// 構造体/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);
    Pointer u_strchr32(
        ShortByReference s,   // WORD*
        int c   // INT
    );
}
@[Link("icuuc")]
lib Libicuuc
  fun u_strchr32 = u_strchr32(
    s : UInt16*,   # WORD*
    c : Int32   # INT
  ) : UInt16*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef u_strchr32Native = Pointer<Uint16> Function(Pointer<Uint16>, Int32);
typedef u_strchr32Dart = Pointer<Uint16> Function(Pointer<Uint16>, int);
final u_strchr32 = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<u_strchr32Native, u_strchr32Dart>('u_strchr32');
// s : WORD* -> Pointer<Uint16>
// c : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function u_strchr32(
  s: Pointer;   // WORD*
  c: Integer   // INT
): Pointer; cdecl;
  external 'icuuc.dll' name 'u_strchr32';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "u_strchr32"
  c_u_strchr32 :: Ptr Word16 -> Int32 -> IO (Ptr Word16)
-- s : WORD* -> Ptr Word16
-- c : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let u_strchr32 =
  foreign "u_strchr32"
    ((ptr uint16_t) @-> int32_t @-> returning (ptr uint16_t))
(* s : WORD* -> (ptr uint16_t) *)
(* c : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)

(cffi:defcfun ("u_strchr32" u-strchr32 :convention :cdecl) :pointer
  (s :pointer)   ; WORD*
  (c :int32))   ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $u_strchr32 = Win32::API::More->new('icuuc',
    'LPVOID u_strchr32(LPVOID s, int c)');
# my $ret = $u_strchr32->Call($s, $c);
# s : WORD* -> LPVOID
# c : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API