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

u_strToWCS

関数
UTF-16文字列をプラットフォームのワイド文字(wchar_t)列へ変換する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

LPWSTR u_strToWCS(
    LPWSTR dest,
    INT destCapacity,
    INT* pDestLength,
    const WORD* src,
    INT srcLength,
    UErrorCode* pErrorCode
);

パラメーター

名前方向
destLPWSTRin
destCapacityINTin
pDestLengthINT*inout
srcWORD*in
srcLengthINTin
pErrorCodeUErrorCode*inout

戻り値の型: LPWSTR

各言語での呼び出し定義

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

LPWSTR u_strToWCS(
    LPWSTR dest,
    INT destCapacity,
    INT* pDestLength,
    const WORD* src,
    INT srcLength,
    UErrorCode* pErrorCode
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr u_strToWCS(
    [MarshalAs(UnmanagedType.LPWStr)] string dest,   // LPWSTR
    int destCapacity,   // INT
    ref int pDestLength,   // INT* in/out
    ref ushort src,   // WORD*
    int srcLength,   // INT
    ref int pErrorCode   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function u_strToWCS(
    <MarshalAs(UnmanagedType.LPWStr)> dest As String,   ' LPWSTR
    destCapacity As Integer,   ' INT
    ByRef pDestLength As Integer,   ' INT* in/out
    ByRef src As UShort,   ' WORD*
    srcLength As Integer,   ' INT
    ByRef pErrorCode As Integer   ' UErrorCode* in/out
) As IntPtr
End Function
' dest : LPWSTR
' destCapacity : INT
' pDestLength : INT* in/out
' src : WORD*
' srcLength : INT
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function u_strToWCS Lib "icuuc" ( _
    ByVal dest As LongPtr, _
    ByVal destCapacity As Long, _
    ByRef pDestLength As Long, _
    ByRef src As Integer, _
    ByVal srcLength As Long, _
    ByRef pErrorCode As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

u_strToWCS = ctypes.cdll.icuuc.u_strToWCS
u_strToWCS.restype = wintypes.LPWSTR
u_strToWCS.argtypes = [
    wintypes.LPCWSTR,  # dest : LPWSTR
    ctypes.c_int,  # destCapacity : INT
    ctypes.POINTER(ctypes.c_int),  # pDestLength : INT* in/out
    ctypes.POINTER(ctypes.c_ushort),  # src : WORD*
    ctypes.c_int,  # srcLength : INT
    ctypes.c_void_p,  # pErrorCode : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
u_strToWCS = Fiddle::Function.new(
  lib['u_strToWCS'],
  [
    Fiddle::TYPE_VOIDP,  # dest : LPWSTR
    Fiddle::TYPE_INT,  # destCapacity : INT
    Fiddle::TYPE_VOIDP,  # pDestLength : INT* in/out
    Fiddle::TYPE_VOIDP,  # src : WORD*
    Fiddle::TYPE_INT,  # srcLength : INT
    Fiddle::TYPE_VOIDP,  # pErrorCode : UErrorCode* in/out
  ],
  Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn u_strToWCS(
        dest: *mut u16,  // LPWSTR
        destCapacity: i32,  // INT
        pDestLength: *mut i32,  // INT* in/out
        src: *const u16,  // WORD*
        srcLength: i32,  // INT
        pErrorCode: *mut i32  // UErrorCode* in/out
    ) -> *mut u16;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr u_strToWCS([MarshalAs(UnmanagedType.LPWStr)] string dest, int destCapacity, ref int pDestLength, ref ushort src, int srcLength, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_strToWCS' -Namespace Win32 -PassThru
# $api::u_strToWCS(dest, destCapacity, pDestLength, src, srcLength, pErrorCode)
#uselib "icuuc.dll"
#func global u_strToWCS "u_strToWCS" sptr, sptr, sptr, sptr, sptr, sptr
; u_strToWCS dest, destCapacity, varptr(pDestLength), varptr(src), srcLength, pErrorCode   ; 戻り値は stat
; dest : LPWSTR -> "sptr"
; destCapacity : INT -> "sptr"
; pDestLength : INT* in/out -> "sptr"
; src : WORD* -> "sptr"
; srcLength : INT -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global u_strToWCS "u_strToWCS" wstr, int, var, var, int, int
; res = u_strToWCS(dest, destCapacity, pDestLength, src, srcLength, pErrorCode)
; dest : LPWSTR -> "wstr"
; destCapacity : INT -> "int"
; pDestLength : INT* in/out -> "var"
; src : WORD* -> "var"
; srcLength : INT -> "int"
; pErrorCode : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; LPWSTR u_strToWCS(LPWSTR dest, INT destCapacity, INT* pDestLength, WORD* src, INT srcLength, UErrorCode* pErrorCode)
#uselib "icuuc.dll"
#cfunc global u_strToWCS "u_strToWCS" wstr, int, var, var, int, int
; res = u_strToWCS(dest, destCapacity, pDestLength, src, srcLength, pErrorCode)
; dest : LPWSTR -> "wstr"
; destCapacity : INT -> "int"
; pDestLength : INT* in/out -> "var"
; src : WORD* -> "var"
; srcLength : INT -> "int"
; pErrorCode : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procu_strToWCS = icuuc.NewProc("u_strToWCS")
)

// dest (LPWSTR), destCapacity (INT), pDestLength (INT* in/out), src (WORD*), srcLength (INT), pErrorCode (UErrorCode* in/out)
r1, _, err := procu_strToWCS.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(dest))),
	uintptr(destCapacity),
	uintptr(pDestLength),
	uintptr(src),
	uintptr(srcLength),
	uintptr(pErrorCode),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // LPWSTR
function u_strToWCS(
  dest: PWideChar;   // LPWSTR
  destCapacity: Integer;   // INT
  pDestLength: Pointer;   // INT* in/out
  src: Pointer;   // WORD*
  srcLength: Integer;   // INT
  pErrorCode: Pointer   // UErrorCode* in/out
): PWideChar; cdecl;
  external 'icuuc.dll' name 'u_strToWCS';
result := DllCall("icuuc\u_strToWCS"
    , "WStr", dest   ; LPWSTR
    , "Int", destCapacity   ; INT
    , "Ptr", pDestLength   ; INT* in/out
    , "Ptr", src   ; WORD*
    , "Int", srcLength   ; INT
    , "Ptr", pErrorCode   ; UErrorCode* in/out
    , "Cdecl Ptr")   ; return: LPWSTR
●u_strToWCS(dest, destCapacity, pDestLength, src, srcLength, pErrorCode) = DLL("icuuc.dll", "char* u_strToWCS(char*, int, void*, void*, int, void*)")
# 呼び出し: u_strToWCS(dest, destCapacity, pDestLength, src, srcLength, pErrorCode)
# dest : LPWSTR -> "char*"
# destCapacity : INT -> "int"
# pDestLength : INT* in/out -> "void*"
# src : WORD* -> "void*"
# srcLength : INT -> "int"
# pErrorCode : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。