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

ucsdet_setDeclaredEncoding

関数
文字セット判定器に宣言済みエンコーディングを設定する。
DLLicuin.dll呼出規約cdecl

シグネチャ

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

void ucsdet_setDeclaredEncoding(
    UCharsetDetector* ucsd,
    LPCSTR encoding,
    INT length,
    UErrorCode* status
);

パラメーター

名前方向
ucsdUCharsetDetector*inout
encodingLPCSTRin
lengthINTin
statusUErrorCode*inout

戻り値の型: void

各言語での呼び出し定義

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

void ucsdet_setDeclaredEncoding(
    UCharsetDetector* ucsd,
    LPCSTR encoding,
    INT length,
    UErrorCode* status
);
[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern void ucsdet_setDeclaredEncoding(
    ref IntPtr ucsd,   // UCharsetDetector* in/out
    [MarshalAs(UnmanagedType.LPStr)] string encoding,   // LPCSTR
    int length,   // INT
    ref int status   // UErrorCode* in/out
);
<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Sub ucsdet_setDeclaredEncoding(
    ByRef ucsd As IntPtr,   ' UCharsetDetector* in/out
    <MarshalAs(UnmanagedType.LPStr)> encoding As String,   ' LPCSTR
    length As Integer,   ' INT
    ByRef status As Integer   ' UErrorCode* in/out
)
End Sub
' ucsd : UCharsetDetector* in/out
' encoding : LPCSTR
' length : INT
' status : UErrorCode* in/out
Declare PtrSafe Sub ucsdet_setDeclaredEncoding Lib "icuin" ( _
    ByRef ucsd As LongPtr, _
    ByVal encoding As String, _
    ByVal length 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_setDeclaredEncoding = ctypes.cdll.icuin.ucsdet_setDeclaredEncoding
ucsdet_setDeclaredEncoding.restype = None
ucsdet_setDeclaredEncoding.argtypes = [
    ctypes.c_void_p,  # ucsd : UCharsetDetector* in/out
    wintypes.LPCSTR,  # encoding : LPCSTR
    ctypes.c_int,  # length : INT
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuin.dll')
ucsdet_setDeclaredEncoding = Fiddle::Function.new(
  lib['ucsdet_setDeclaredEncoding'],
  [
    Fiddle::TYPE_VOIDP,  # ucsd : UCharsetDetector* in/out
    Fiddle::TYPE_VOIDP,  # encoding : LPCSTR
    Fiddle::TYPE_INT,  # length : INT
    Fiddle::TYPE_VOIDP,  # status : UErrorCode* in/out
  ],
  Fiddle::TYPE_VOID, Fiddle::Function::CDECL)
#[link(name = "icuin")]
extern "C" {
    fn ucsdet_setDeclaredEncoding(
        ucsd: *mut isize,  // UCharsetDetector* in/out
        encoding: *const u8,  // LPCSTR
        length: 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_setDeclaredEncoding(ref IntPtr ucsd, [MarshalAs(UnmanagedType.LPStr)] string encoding, int length, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_ucsdet_setDeclaredEncoding' -Namespace Win32 -PassThru
# $api::ucsdet_setDeclaredEncoding(ucsd, encoding, length, status)
#uselib "icuin.dll"
#func global ucsdet_setDeclaredEncoding "ucsdet_setDeclaredEncoding" sptr, sptr, sptr, sptr
; ucsdet_setDeclaredEncoding ucsd, encoding, length, status
; ucsd : UCharsetDetector* in/out -> "sptr"
; encoding : LPCSTR -> "sptr"
; length : INT -> "sptr"
; status : UErrorCode* in/out -> "sptr"
#uselib "icuin.dll"
#func global ucsdet_setDeclaredEncoding "ucsdet_setDeclaredEncoding" int, str, int, int
; ucsdet_setDeclaredEncoding ucsd, encoding, length, status
; ucsd : UCharsetDetector* in/out -> "int"
; encoding : LPCSTR -> "str"
; length : INT -> "int"
; status : UErrorCode* in/out -> "int"
; void ucsdet_setDeclaredEncoding(UCharsetDetector* ucsd, LPCSTR encoding, INT length, UErrorCode* status)
#uselib "icuin.dll"
#func global ucsdet_setDeclaredEncoding "ucsdet_setDeclaredEncoding" int, str, int, int
; ucsdet_setDeclaredEncoding ucsd, encoding, length, status
; ucsd : UCharsetDetector* in/out -> "int"
; encoding : LPCSTR -> "str"
; length : INT -> "int"
; status : UErrorCode* in/out -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuin = windows.NewLazySystemDLL("icuin.dll")
	procucsdet_setDeclaredEncoding = icuin.NewProc("ucsdet_setDeclaredEncoding")
)

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