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

u_uastrcpy

関数
ASCII文字列をUChar文字列に変換してコピーする。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

WORD* u_uastrcpy(
    WORD* dst,
    LPCSTR src
);

パラメーター

名前方向
dstWORD*inout
srcLPCSTRin

戻り値の型: WORD*

各言語での呼び出し定義

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

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

u_uastrcpy = ctypes.cdll.icuuc.u_uastrcpy
u_uastrcpy.restype = ctypes.c_void_p
u_uastrcpy.argtypes = [
    ctypes.POINTER(ctypes.c_ushort),  # dst : WORD* in/out
    wintypes.LPCSTR,  # src : LPCSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procu_uastrcpy = icuuc.NewProc("u_uastrcpy")
)

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