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

uset_spanBackUTF8

関数
UTF-8文字列末尾からUSet条件に合う長さを返す。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

INT uset_spanBackUTF8(
    const USet* set,
    LPCSTR s,
    INT length,
    USetSpanCondition spanCondition
);

パラメーター

名前方向
setUSet*in
sLPCSTRin
lengthINTin
spanConditionUSetSpanConditionin

戻り値の型: 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 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" int, str, int, int
; res = uset_spanBackUTF8(set, s, length, spanCondition)
; set : USet* -> "int"
; s : LPCSTR -> "str"
; length : INT -> "int"
; spanCondition : USetSpanCondition -> "int"
; INT uset_spanBackUTF8(USet* set, LPCSTR s, INT length, USetSpanCondition spanCondition)
#uselib "icuuc.dll"
#cfunc global uset_spanBackUTF8 "uset_spanBackUTF8" int, str, int, int
; res = uset_spanBackUTF8(set, s, length, spanCondition)
; set : USet* -> "int"
; s : LPCSTR -> "str"
; length : INT -> "int"
; spanCondition : USetSpanCondition -> "int"
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   // INT
function 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`,…) を使用。