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

ucnv_toUnicode

関数
バイト列からUnicodeへストリーム変換する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

void ucnv_toUnicode(
    UConverter* converter,
    WORD** target,
    const WORD* targetLimit,
    const CHAR** source,
    LPCSTR sourceLimit,
    INT* offsets,
    CHAR flush,
    UErrorCode* err
);

パラメーター

名前方向
converterUConverter*inout
targetWORD**inout
targetLimitWORD*in
sourceCHAR**in
sourceLimitLPCSTRin
offsetsINT*inout
flushCHARin
errUErrorCode*inout

戻り値の型: void

各言語での呼び出し定義

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

void ucnv_toUnicode(
    UConverter* converter,
    WORD** target,
    const WORD* targetLimit,
    const CHAR** source,
    LPCSTR sourceLimit,
    INT* offsets,
    CHAR flush,
    UErrorCode* err
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern void ucnv_toUnicode(
    ref IntPtr converter,   // UConverter* in/out
    IntPtr target,   // WORD** in/out
    ref ushort targetLimit,   // WORD*
    IntPtr source,   // CHAR**
    [MarshalAs(UnmanagedType.LPStr)] string sourceLimit,   // LPCSTR
    ref int offsets,   // INT* in/out
    sbyte flush,   // CHAR
    ref int err   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Sub ucnv_toUnicode(
    ByRef converter As IntPtr,   ' UConverter* in/out
    target As IntPtr,   ' WORD** in/out
    ByRef targetLimit As UShort,   ' WORD*
    source As IntPtr,   ' CHAR**
    <MarshalAs(UnmanagedType.LPStr)> sourceLimit As String,   ' LPCSTR
    ByRef offsets As Integer,   ' INT* in/out
    flush As SByte,   ' CHAR
    ByRef err As Integer   ' UErrorCode* in/out
)
End Sub
' converter : UConverter* in/out
' target : WORD** in/out
' targetLimit : WORD*
' source : CHAR**
' sourceLimit : LPCSTR
' offsets : INT* in/out
' flush : CHAR
' err : UErrorCode* in/out
Declare PtrSafe Sub ucnv_toUnicode Lib "icuuc" ( _
    ByRef converter As LongPtr, _
    ByVal target As LongPtr, _
    ByRef targetLimit As Integer, _
    ByVal source As LongPtr, _
    ByVal sourceLimit As String, _
    ByRef offsets As Long, _
    ByVal flush As Byte, _
    ByRef err As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ucnv_toUnicode = ctypes.cdll.icuuc.ucnv_toUnicode
ucnv_toUnicode.restype = None
ucnv_toUnicode.argtypes = [
    ctypes.c_void_p,  # converter : UConverter* in/out
    ctypes.c_void_p,  # target : WORD** in/out
    ctypes.POINTER(ctypes.c_ushort),  # targetLimit : WORD*
    ctypes.c_void_p,  # source : CHAR**
    wintypes.LPCSTR,  # sourceLimit : LPCSTR
    ctypes.POINTER(ctypes.c_int),  # offsets : INT* in/out
    ctypes.c_byte,  # flush : CHAR
    ctypes.c_void_p,  # err : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
ucnv_toUnicode = Fiddle::Function.new(
  lib['ucnv_toUnicode'],
  [
    Fiddle::TYPE_VOIDP,  # converter : UConverter* in/out
    Fiddle::TYPE_VOIDP,  # target : WORD** in/out
    Fiddle::TYPE_VOIDP,  # targetLimit : WORD*
    Fiddle::TYPE_VOIDP,  # source : CHAR**
    Fiddle::TYPE_VOIDP,  # sourceLimit : LPCSTR
    Fiddle::TYPE_VOIDP,  # offsets : INT* in/out
    Fiddle::TYPE_CHAR,  # flush : CHAR
    Fiddle::TYPE_VOIDP,  # err : UErrorCode* in/out
  ],
  Fiddle::TYPE_VOID, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn ucnv_toUnicode(
        converter: *mut isize,  // UConverter* in/out
        target: *mut *mut u16,  // WORD** in/out
        targetLimit: *const u16,  // WORD*
        source: *const *const i8,  // CHAR**
        sourceLimit: *const u8,  // LPCSTR
        offsets: *mut i32,  // INT* in/out
        flush: i8,  // CHAR
        err: *mut i32  // UErrorCode* in/out
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void ucnv_toUnicode(ref IntPtr converter, IntPtr target, ref ushort targetLimit, IntPtr source, [MarshalAs(UnmanagedType.LPStr)] string sourceLimit, ref int offsets, sbyte flush, ref int err);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucnv_toUnicode' -Namespace Win32 -PassThru
# $api::ucnv_toUnicode(converter, target, targetLimit, source, sourceLimit, offsets, flush, err)
#uselib "icuuc.dll"
#func global ucnv_toUnicode "ucnv_toUnicode" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; ucnv_toUnicode converter, varptr(target), varptr(targetLimit), varptr(source), sourceLimit, varptr(offsets), flush, err
; converter : UConverter* in/out -> "sptr"
; target : WORD** in/out -> "sptr"
; targetLimit : WORD* -> "sptr"
; source : CHAR** -> "sptr"
; sourceLimit : LPCSTR -> "sptr"
; offsets : INT* in/out -> "sptr"
; flush : CHAR -> "sptr"
; err : UErrorCode* in/out -> "sptr"
出力引数:
#uselib "icuuc.dll"
#func global ucnv_toUnicode "ucnv_toUnicode" int, var, var, var, str, var, int, int
; ucnv_toUnicode converter, target, targetLimit, source, sourceLimit, offsets, flush, err
; converter : UConverter* in/out -> "int"
; target : WORD** in/out -> "var"
; targetLimit : WORD* -> "var"
; source : CHAR** -> "var"
; sourceLimit : LPCSTR -> "str"
; offsets : INT* in/out -> "var"
; flush : CHAR -> "int"
; err : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void ucnv_toUnicode(UConverter* converter, WORD** target, WORD* targetLimit, CHAR** source, LPCSTR sourceLimit, INT* offsets, CHAR flush, UErrorCode* err)
#uselib "icuuc.dll"
#func global ucnv_toUnicode "ucnv_toUnicode" int, var, var, var, str, var, int, int
; ucnv_toUnicode converter, target, targetLimit, source, sourceLimit, offsets, flush, err
; converter : UConverter* in/out -> "int"
; target : WORD** in/out -> "var"
; targetLimit : WORD* -> "var"
; source : CHAR** -> "var"
; sourceLimit : LPCSTR -> "str"
; offsets : INT* in/out -> "var"
; flush : CHAR -> "int"
; err : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procucnv_toUnicode = icuuc.NewProc("ucnv_toUnicode")
)

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