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