ホーム › Globalization › uset_indexOf
uset_indexOf
関数USet内における指定コードポイントの順位を返す。
シグネチャ
// icuuc.dll
#include <windows.h>
INT uset_indexOf(
const USet* set,
INT c
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| set | USet* | in | 対象のUnicodeセット。 |
| c | INT | in | インデックスを取得する単一コードポイント。セット内の0始まり位置を返し、未所属なら-1を返す。 |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT uset_indexOf(
const USet* set,
INT c
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int uset_indexOf(
ref IntPtr set, // USet*
int c // INT
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function uset_indexOf(
ByRef [set] As IntPtr, ' USet*
c As Integer ' INT
) As Integer
End Function' set : USet*
' c : INT
Declare PtrSafe Function uset_indexOf Lib "icuuc" ( _
ByRef set As LongPtr, _
ByVal c As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
uset_indexOf = ctypes.cdll.icuuc.uset_indexOf
uset_indexOf.restype = ctypes.c_int
uset_indexOf.argtypes = [
ctypes.c_void_p, # set : USet*
ctypes.c_int, # c : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
uset_indexOf = Fiddle::Function.new(
lib['uset_indexOf'],
[
Fiddle::TYPE_VOIDP, # set : USet*
Fiddle::TYPE_INT, # c : INT
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn uset_indexOf(
set: *const isize, // USet*
c: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int uset_indexOf(ref IntPtr set, int c);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_uset_indexOf' -Namespace Win32 -PassThru
# $api::uset_indexOf(set, c)#uselib "icuuc.dll"
#func global uset_indexOf "uset_indexOf" sptr, sptr
; uset_indexOf varptr(set), c ; 戻り値は stat
; set : USet* -> "sptr"
; c : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global uset_indexOf "uset_indexOf" var, int ; res = uset_indexOf(set, c) ; set : USet* -> "var" ; c : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global uset_indexOf "uset_indexOf" sptr, int ; res = uset_indexOf(varptr(set), c) ; set : USet* -> "sptr" ; c : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT uset_indexOf(USet* set, INT c) #uselib "icuuc.dll" #cfunc global uset_indexOf "uset_indexOf" var, int ; res = uset_indexOf(set, c) ; set : USet* -> "var" ; c : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT uset_indexOf(USet* set, INT c) #uselib "icuuc.dll" #cfunc global uset_indexOf "uset_indexOf" intptr, int ; res = uset_indexOf(varptr(set), c) ; set : USet* -> "intptr" ; c : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procuset_indexOf = icuuc.NewProc("uset_indexOf")
)
// set (USet*), c (INT)
r1, _, err := procuset_indexOf.Call(
uintptr(set),
uintptr(c),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction uset_indexOf(
set: Pointer; // USet*
c: Integer // INT
): Integer; cdecl;
external 'icuuc.dll' name 'uset_indexOf';result := DllCall("icuuc\uset_indexOf"
, "Ptr", set ; USet*
, "Int", c ; INT
, "Cdecl Int") ; return: INT●uset_indexOf(set, c) = DLL("icuuc.dll", "int uset_indexOf(void*, int)")
# 呼び出し: uset_indexOf(set, c)
# set : USet* -> "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 uset_indexOf(
set: [*c]isize, // USet*
c: i32 // INT
) callconv(.c) i32;proc uset_indexOf(
set: ptr int, # USet*
c: int32 # INT
): int32 {.importc: "uset_indexOf", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
int uset_indexOf(
ptrdiff_t* set, // USet*
int c // INT
);ccall((:uset_indexOf, "icuuc.dll"), Int32,
(Ptr{Int}, Int32),
set, c)
# set : USet* -> Ptr{Int}
# c : INT -> Int32local ffi = require("ffi")
ffi.cdef[[
int32_t uset_indexOf(
intptr_t* set,
int32_t c);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.uset_indexOf(set, c)
-- set : USet*
-- c : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const uset_indexOf = lib.func('__cdecl', 'uset_indexOf', 'int32_t', ['intptr_t *', 'int32_t']);
// uset_indexOf(set, c)
// set : USet* -> 'intptr_t *'
// c : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
uset_indexOf: { parameters: ["pointer", "i32"], result: "i32" },
});
// lib.symbols.uset_indexOf(set, c)
// set : USet* -> "pointer"
// c : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t uset_indexOf(
intptr_t* set,
int32_t c);
C, "icuuc.dll");
// $ffi->uset_indexOf(set, c);
// set : USet*
// 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);
int uset_indexOf(
LongByReference set, // USet*
int c // INT
);
}@[Link("icuuc")]
lib Libicuuc
fun uset_indexOf = uset_indexOf(
set : LibC::SSizeT*, # USet*
c : Int32 # INT
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef uset_indexOfNative = Int32 Function(Pointer<IntPtr>, Int32);
typedef uset_indexOfDart = int Function(Pointer<IntPtr>, int);
final uset_indexOf = DynamicLibrary.open('icuuc.dll')
.lookupFunction<uset_indexOfNative, uset_indexOfDart>('uset_indexOf');
// set : USet* -> Pointer<IntPtr>
// c : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function uset_indexOf(
set: Pointer; // USet*
c: Integer // INT
): Integer; cdecl;
external 'icuuc.dll' name 'uset_indexOf';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "uset_indexOf"
c_uset_indexOf :: Ptr CIntPtr -> Int32 -> IO Int32
-- set : USet* -> Ptr CIntPtr
-- c : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let uset_indexof =
foreign "uset_indexOf"
((ptr intptr_t) @-> int32_t @-> returning int32_t)
(* set : USet* -> (ptr intptr_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 ("uset_indexOf" uset-index-of :convention :cdecl) :int32
(set :pointer) ; USet*
(c :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $uset_indexOf = Win32::API::More->new('icuuc',
'int uset_indexOf(LPVOID set, int c)');
# my $ret = $uset_indexOf->Call($set, $c);
# set : USet* -> LPVOID
# c : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。