ホーム › Globalization › ucnv_getType
ucnv_getType
関数変換器の文字コード種別を取得する。
シグネチャ
// icuuc.dll
#include <windows.h>
UConverterType ucnv_getType(
const UConverter* converter
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| converter | UConverter* | in | コンバーター種別(SBCS/DBCS/UTF-8等)を問い合わせる対象のポインタ。 |
戻り値の型: UConverterType
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
UConverterType ucnv_getType(
const UConverter* converter
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int ucnv_getType(
ref IntPtr converter // UConverter*
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucnv_getType(
ByRef converter As IntPtr ' UConverter*
) As Integer
End Function' converter : UConverter*
Declare PtrSafe Function ucnv_getType Lib "icuuc" ( _
ByRef converter As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ucnv_getType = ctypes.cdll.icuuc.ucnv_getType
ucnv_getType.restype = ctypes.c_int
ucnv_getType.argtypes = [
ctypes.c_void_p, # converter : UConverter*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
ucnv_getType = Fiddle::Function.new(
lib['ucnv_getType'],
[
Fiddle::TYPE_VOIDP, # converter : UConverter*
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn ucnv_getType(
converter: *const isize // UConverter*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int ucnv_getType(ref IntPtr converter);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucnv_getType' -Namespace Win32 -PassThru
# $api::ucnv_getType(converter)#uselib "icuuc.dll"
#func global ucnv_getType "ucnv_getType" sptr
; ucnv_getType varptr(converter) ; 戻り値は stat
; converter : UConverter* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global ucnv_getType "ucnv_getType" var ; res = ucnv_getType(converter) ; converter : UConverter* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global ucnv_getType "ucnv_getType" sptr ; res = ucnv_getType(varptr(converter)) ; converter : UConverter* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; UConverterType ucnv_getType(UConverter* converter) #uselib "icuuc.dll" #cfunc global ucnv_getType "ucnv_getType" var ; res = ucnv_getType(converter) ; converter : UConverter* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; UConverterType ucnv_getType(UConverter* converter) #uselib "icuuc.dll" #cfunc global ucnv_getType "ucnv_getType" intptr ; res = ucnv_getType(varptr(converter)) ; converter : UConverter* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procucnv_getType = icuuc.NewProc("ucnv_getType")
)
// converter (UConverter*)
r1, _, err := procucnv_getType.Call(
uintptr(converter),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // UConverterTypefunction ucnv_getType(
converter: Pointer // UConverter*
): Integer; cdecl;
external 'icuuc.dll' name 'ucnv_getType';result := DllCall("icuuc\ucnv_getType"
, "Ptr", converter ; UConverter*
, "Cdecl Int") ; return: UConverterType●ucnv_getType(converter) = DLL("icuuc.dll", "int ucnv_getType(void*)")
# 呼び出し: ucnv_getType(converter)
# converter : UConverter* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "icuuc" fn ucnv_getType(
converter: [*c]isize // UConverter*
) callconv(.c) i32;proc ucnv_getType(
`converter`: ptr int # UConverter*
): int32 {.importc: "ucnv_getType", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
int ucnv_getType(
ptrdiff_t* converter // UConverter*
);ccall((:ucnv_getType, "icuuc.dll"), Int32,
(Ptr{Int},),
converter)
# converter : UConverter* -> Ptr{Int}local ffi = require("ffi")
ffi.cdef[[
int32_t ucnv_getType(
intptr_t* converter);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.ucnv_getType(converter)
-- converter : UConverter*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const ucnv_getType = lib.func('__cdecl', 'ucnv_getType', 'int32_t', ['intptr_t *']);
// ucnv_getType(converter)
// converter : UConverter* -> 'intptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
ucnv_getType: { parameters: ["pointer"], result: "i32" },
});
// lib.symbols.ucnv_getType(converter)
// converter : UConverter* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ucnv_getType(
intptr_t* converter);
C, "icuuc.dll");
// $ffi->ucnv_getType(converter);
// converter : UConverter*
// 構造体/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 ucnv_getType(
LongByReference converter // UConverter*
);
}@[Link("icuuc")]
lib Libicuuc
fun ucnv_getType = ucnv_getType(
converter : LibC::SSizeT* # UConverter*
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ucnv_getTypeNative = Int32 Function(Pointer<IntPtr>);
typedef ucnv_getTypeDart = int Function(Pointer<IntPtr>);
final ucnv_getType = DynamicLibrary.open('icuuc.dll')
.lookupFunction<ucnv_getTypeNative, ucnv_getTypeDart>('ucnv_getType');
// converter : UConverter* -> Pointer<IntPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ucnv_getType(
converter: Pointer // UConverter*
): Integer; cdecl;
external 'icuuc.dll' name 'ucnv_getType';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ucnv_getType"
c_ucnv_getType :: Ptr CIntPtr -> IO Int32
-- converter : UConverter* -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ucnv_gettype =
foreign "ucnv_getType"
((ptr intptr_t) @-> returning int32_t)
(* converter : UConverter* -> (ptr intptr_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)
(cffi:defcfun ("ucnv_getType" ucnv-get-type :convention :cdecl) :int32
(converter :pointer)) ; UConverter*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ucnv_getType = Win32::API::More->new('icuuc',
'int ucnv_getType(LPVOID converter)');
# my $ret = $ucnv_getType->Call($converter);
# converter : UConverter* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型