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