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

ucsdet_setText

関数
文字セット判定器に判定対象テキストを設定する。
DLLicuin.dll呼出規約cdecl

シグネチャ

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

void ucsdet_setText(
    UCharsetDetector* ucsd,
    LPCSTR textIn,
    INT len,
    UErrorCode* status
);

パラメーター

名前方向
ucsdUCharsetDetector*inout
textInLPCSTRin
lenINTin
statusUErrorCode*inout

戻り値の型: void

各言語での呼び出し定義

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

void ucsdet_setText(
    UCharsetDetector* ucsd,
    LPCSTR textIn,
    INT len,
    UErrorCode* status
);
[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern void ucsdet_setText(
    ref IntPtr ucsd,   // UCharsetDetector* in/out
    [MarshalAs(UnmanagedType.LPStr)] string textIn,   // LPCSTR
    int len,   // INT
    ref int status   // UErrorCode* in/out
);
<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Sub ucsdet_setText(
    ByRef ucsd As IntPtr,   ' UCharsetDetector* in/out
    <MarshalAs(UnmanagedType.LPStr)> textIn As String,   ' LPCSTR
    len As Integer,   ' INT
    ByRef status As Integer   ' UErrorCode* in/out
)
End Sub
' ucsd : UCharsetDetector* in/out
' textIn : LPCSTR
' len : INT
' status : UErrorCode* in/out
Declare PtrSafe Sub ucsdet_setText Lib "icuin" ( _
    ByRef ucsd As LongPtr, _
    ByVal textIn As String, _
    ByVal len As Long, _
    ByRef status As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ucsdet_setText = ctypes.cdll.icuin.ucsdet_setText
ucsdet_setText.restype = None
ucsdet_setText.argtypes = [
    ctypes.c_void_p,  # ucsd : UCharsetDetector* in/out
    wintypes.LPCSTR,  # textIn : LPCSTR
    ctypes.c_int,  # len : INT
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuin.dll')
ucsdet_setText = Fiddle::Function.new(
  lib['ucsdet_setText'],
  [
    Fiddle::TYPE_VOIDP,  # ucsd : UCharsetDetector* in/out
    Fiddle::TYPE_VOIDP,  # textIn : LPCSTR
    Fiddle::TYPE_INT,  # len : INT
    Fiddle::TYPE_VOIDP,  # status : UErrorCode* in/out
  ],
  Fiddle::TYPE_VOID, Fiddle::Function::CDECL)
#[link(name = "icuin")]
extern "C" {
    fn ucsdet_setText(
        ucsd: *mut isize,  // UCharsetDetector* in/out
        textIn: *const u8,  // LPCSTR
        len: i32,  // INT
        status: *mut i32  // UErrorCode* in/out
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuin.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void ucsdet_setText(ref IntPtr ucsd, [MarshalAs(UnmanagedType.LPStr)] string textIn, int len, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_ucsdet_setText' -Namespace Win32 -PassThru
# $api::ucsdet_setText(ucsd, textIn, len, status)
#uselib "icuin.dll"
#func global ucsdet_setText "ucsdet_setText" sptr, sptr, sptr, sptr
; ucsdet_setText ucsd, textIn, len, status
; ucsd : UCharsetDetector* in/out -> "sptr"
; textIn : LPCSTR -> "sptr"
; len : INT -> "sptr"
; status : UErrorCode* in/out -> "sptr"
#uselib "icuin.dll"
#func global ucsdet_setText "ucsdet_setText" int, str, int, int
; ucsdet_setText ucsd, textIn, len, status
; ucsd : UCharsetDetector* in/out -> "int"
; textIn : LPCSTR -> "str"
; len : INT -> "int"
; status : UErrorCode* in/out -> "int"
; void ucsdet_setText(UCharsetDetector* ucsd, LPCSTR textIn, INT len, UErrorCode* status)
#uselib "icuin.dll"
#func global ucsdet_setText "ucsdet_setText" int, str, int, int
; ucsdet_setText ucsd, textIn, len, status
; ucsd : UCharsetDetector* in/out -> "int"
; textIn : LPCSTR -> "str"
; len : INT -> "int"
; status : UErrorCode* in/out -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuin = windows.NewLazySystemDLL("icuin.dll")
	procucsdet_setText = icuin.NewProc("ucsdet_setText")
)

// ucsd (UCharsetDetector* in/out), textIn (LPCSTR), len (INT), status (UErrorCode* in/out)
r1, _, err := procucsdet_setText.Call(
	uintptr(ucsd),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(textIn))),
	uintptr(len),
	uintptr(status),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure ucsdet_setText(
  ucsd: Pointer;   // UCharsetDetector* in/out
  textIn: PAnsiChar;   // LPCSTR
  len: Integer;   // INT
  status: Pointer   // UErrorCode* in/out
); cdecl;
  external 'icuin.dll' name 'ucsdet_setText';
result := DllCall("icuin\ucsdet_setText"
    , "Ptr", ucsd   ; UCharsetDetector* in/out
    , "AStr", textIn   ; LPCSTR
    , "Int", len   ; INT
    , "Ptr", status   ; UErrorCode* in/out
    , "Cdecl Int")   ; return: void
●ucsdet_setText(ucsd, textIn, len, status) = DLL("icuin.dll", "int ucsdet_setText(void*, char*, int, void*)")
# 呼び出し: ucsdet_setText(ucsd, textIn, len, status)
# ucsd : UCharsetDetector* in/out -> "void*"
# textIn : LPCSTR -> "char*"
# len : INT -> "int"
# status : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。