ホーム › Globalization › ucsdet_setDeclaredEncoding
ucsdet_setDeclaredEncoding
関数文字セット判定器に宣言済みエンコーディングを設定する。
シグネチャ
// icuin.dll
#include <windows.h>
void ucsdet_setDeclaredEncoding(
UCharsetDetector* ucsd,
LPCSTR encoding,
INT length,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ucsd | UCharsetDetector* | inout | 宣言エンコーディングを設定する文字セット検出器のハンドル。 |
| encoding | LPCSTR | in | 外部で宣言済みのエンコーディング名文字列。検出のヒントとして使われる。 |
| length | INT | in | encoding文字列の長さ。-1でNUL終端として扱う。 |
| status | UErrorCode* | 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 varptr(ucsd), encoding, length, varptr(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" var, str, int, var ; ucsdet_setDeclaredEncoding ucsd, encoding, length, status ; ucsd : UCharsetDetector* in/out -> "var" ; encoding : LPCSTR -> "str" ; length : INT -> "int" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuin.dll" #func global ucsdet_setDeclaredEncoding "ucsdet_setDeclaredEncoding" sptr, str, int, sptr ; ucsdet_setDeclaredEncoding varptr(ucsd), encoding, length, varptr(status) ; ucsd : UCharsetDetector* in/out -> "sptr" ; encoding : LPCSTR -> "str" ; length : INT -> "int" ; status : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void ucsdet_setDeclaredEncoding(UCharsetDetector* ucsd, LPCSTR encoding, INT length, UErrorCode* status) #uselib "icuin.dll" #func global ucsdet_setDeclaredEncoding "ucsdet_setDeclaredEncoding" var, str, int, var ; ucsdet_setDeclaredEncoding ucsd, encoding, length, status ; ucsd : UCharsetDetector* in/out -> "var" ; encoding : LPCSTR -> "str" ; length : INT -> "int" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void ucsdet_setDeclaredEncoding(UCharsetDetector* ucsd, LPCSTR encoding, INT length, UErrorCode* status) #uselib "icuin.dll" #func global ucsdet_setDeclaredEncoding "ucsdet_setDeclaredEncoding" intptr, str, int, intptr ; ucsdet_setDeclaredEncoding varptr(ucsd), encoding, length, varptr(status) ; ucsd : UCharsetDetector* in/out -> "intptr" ; encoding : LPCSTR -> "str" ; length : INT -> "int" ; status : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
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 // voidprocedure 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`,…) を使用。const std = @import("std");
extern "icuin" fn ucsdet_setDeclaredEncoding(
ucsd: [*c]isize, // UCharsetDetector* in/out
encoding: [*c]const u8, // LPCSTR
length: i32, // INT
status: [*c]i32 // UErrorCode* in/out
) callconv(.c) void;proc ucsdet_setDeclaredEncoding(
ucsd: ptr int, # UCharsetDetector* in/out
encoding: cstring, # LPCSTR
length: int32, # INT
status: ptr int32 # UErrorCode* in/out
) {.importc: "ucsdet_setDeclaredEncoding", cdecl, dynlib: "icuin.dll".}pragma(lib, "icuin");
extern(C)
void ucsdet_setDeclaredEncoding(
ptrdiff_t* ucsd, // UCharsetDetector* in/out
const(char)* encoding, // LPCSTR
int length, // INT
int* status // UErrorCode* in/out
);ccall((:ucsdet_setDeclaredEncoding, "icuin.dll"), Cvoid,
(Ptr{Int}, Cstring, Int32, Ptr{Int32}),
ucsd, encoding, length, status)
# ucsd : UCharsetDetector* in/out -> Ptr{Int}
# encoding : LPCSTR -> Cstring
# length : INT -> Int32
# status : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
void ucsdet_setDeclaredEncoding(
intptr_t* ucsd,
const char* encoding,
int32_t length,
int32_t* status);
]]
local icuin = ffi.load("icuin")
-- icuin.ucsdet_setDeclaredEncoding(ucsd, encoding, length, status)
-- ucsd : UCharsetDetector* in/out
-- encoding : LPCSTR
-- length : INT
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuin.dll');
const ucsdet_setDeclaredEncoding = lib.func('__cdecl', 'ucsdet_setDeclaredEncoding', 'void', ['intptr_t *', 'str', 'int32_t', 'int32_t *']);
// ucsdet_setDeclaredEncoding(ucsd, encoding, length, status)
// ucsd : UCharsetDetector* in/out -> 'intptr_t *'
// encoding : LPCSTR -> 'str'
// length : INT -> 'int32_t'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuin.dll", {
ucsdet_setDeclaredEncoding: { parameters: ["pointer", "buffer", "i32", "pointer"], result: "void" },
});
// lib.symbols.ucsdet_setDeclaredEncoding(ucsd, encoding, length, status)
// ucsd : UCharsetDetector* in/out -> "pointer"
// encoding : LPCSTR -> "buffer"
// length : INT -> "i32"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void ucsdet_setDeclaredEncoding(
intptr_t* ucsd,
const char* encoding,
int32_t length,
int32_t* status);
C, "icuin.dll");
// $ffi->ucsdet_setDeclaredEncoding(ucsd, encoding, length, status);
// ucsd : UCharsetDetector* in/out
// encoding : LPCSTR
// length : INT
// status : UErrorCode* in/out
// 構造体/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 Icuin extends Library {
Icuin INSTANCE = Native.load("icuin", Icuin.class);
void ucsdet_setDeclaredEncoding(
LongByReference ucsd, // UCharsetDetector* in/out
String encoding, // LPCSTR
int length, // INT
IntByReference status // UErrorCode* in/out
);
}@[Link("icuin")]
lib Libicuin
fun ucsdet_setDeclaredEncoding = ucsdet_setDeclaredEncoding(
ucsd : LibC::SSizeT*, # UCharsetDetector* in/out
encoding : UInt8*, # LPCSTR
length : Int32, # INT
status : Int32* # UErrorCode* in/out
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ucsdet_setDeclaredEncodingNative = Void Function(Pointer<IntPtr>, Pointer<Utf8>, Int32, Pointer<Int32>);
typedef ucsdet_setDeclaredEncodingDart = void Function(Pointer<IntPtr>, Pointer<Utf8>, int, Pointer<Int32>);
final ucsdet_setDeclaredEncoding = DynamicLibrary.open('icuin.dll')
.lookupFunction<ucsdet_setDeclaredEncodingNative, ucsdet_setDeclaredEncodingDart>('ucsdet_setDeclaredEncoding');
// ucsd : UCharsetDetector* in/out -> Pointer<IntPtr>
// encoding : LPCSTR -> Pointer<Utf8>
// length : INT -> Int32
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ucsdet_setDeclaredEncoding"
c_ucsdet_setDeclaredEncoding :: Ptr CIntPtr -> CString -> Int32 -> Ptr Int32 -> IO ()
-- ucsd : UCharsetDetector* in/out -> Ptr CIntPtr
-- encoding : LPCSTR -> CString
-- length : INT -> Int32
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ucsdet_setdeclaredencoding =
foreign "ucsdet_setDeclaredEncoding"
((ptr intptr_t) @-> string @-> int32_t @-> (ptr int32_t) @-> returning void)
(* ucsd : UCharsetDetector* in/out -> (ptr intptr_t) *)
(* encoding : LPCSTR -> string *)
(* length : INT -> int32_t *)
(* status : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuin (t "icuin.dll"))
(cffi:use-foreign-library icuin)
(cffi:defcfun ("ucsdet_setDeclaredEncoding" ucsdet-set-declared-encoding :convention :cdecl) :void
(ucsd :pointer) ; UCharsetDetector* in/out
(encoding :string) ; LPCSTR
(length :int32) ; INT
(status :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ucsdet_setDeclaredEncoding = Win32::API::More->new('icuin',
'void ucsdet_setDeclaredEncoding(LPVOID ucsd, LPCSTR encoding, int length, LPVOID status)');
# my $ret = $ucsdet_setDeclaredEncoding->Call($ucsd, $encoding, $length, $status);
# ucsd : UCharsetDetector* in/out -> LPVOID
# encoding : LPCSTR -> LPCSTR
# length : INT -> int
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型