ホーム › Globalization › u_austrcpy
u_austrcpy
関数UChar文字列をASCII文字列に変換してコピーする。
シグネチャ
// icuuc.dll
#include <windows.h>
LPSTR u_austrcpy(
LPSTR dst,
const WORD* src
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dst | LPSTR | in |
| src | WORD* | in |
戻り値の型: LPSTR
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
LPSTR u_austrcpy(
LPSTR dst,
const WORD* src
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr u_austrcpy(
[MarshalAs(UnmanagedType.LPStr)] string dst, // LPSTR
ref ushort src // WORD*
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function u_austrcpy(
<MarshalAs(UnmanagedType.LPStr)> dst As String, ' LPSTR
ByRef src As UShort ' WORD*
) As IntPtr
End Function' dst : LPSTR
' src : WORD*
Declare PtrSafe Function u_austrcpy Lib "icuuc" ( _
ByVal dst As String, _
ByRef src As Integer) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
u_austrcpy = ctypes.cdll.icuuc.u_austrcpy
u_austrcpy.restype = wintypes.LPSTR
u_austrcpy.argtypes = [
wintypes.LPCSTR, # dst : LPSTR
ctypes.POINTER(ctypes.c_ushort), # src : WORD*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
u_austrcpy = Fiddle::Function.new(
lib['u_austrcpy'],
[
Fiddle::TYPE_VOIDP, # dst : LPSTR
Fiddle::TYPE_VOIDP, # src : WORD*
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn u_austrcpy(
dst: *mut u8, // LPSTR
src: *const u16 // WORD*
) -> *mut u8;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr u_austrcpy([MarshalAs(UnmanagedType.LPStr)] string dst, ref ushort src);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_austrcpy' -Namespace Win32 -PassThru
# $api::u_austrcpy(dst, src)#uselib "icuuc.dll"
#func global u_austrcpy "u_austrcpy" sptr, sptr
; u_austrcpy dst, varptr(src) ; 戻り値は stat
; dst : LPSTR -> "sptr"
; src : WORD* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global u_austrcpy "u_austrcpy" str, var ; res = u_austrcpy(dst, src) ; dst : LPSTR -> "str" ; src : WORD* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global u_austrcpy "u_austrcpy" str, sptr ; res = u_austrcpy(dst, varptr(src)) ; dst : LPSTR -> "str" ; src : WORD* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; LPSTR u_austrcpy(LPSTR dst, WORD* src) #uselib "icuuc.dll" #cfunc global u_austrcpy "u_austrcpy" str, var ; res = u_austrcpy(dst, src) ; dst : LPSTR -> "str" ; src : WORD* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; LPSTR u_austrcpy(LPSTR dst, WORD* src) #uselib "icuuc.dll" #cfunc global u_austrcpy "u_austrcpy" str, intptr ; res = u_austrcpy(dst, varptr(src)) ; dst : LPSTR -> "str" ; src : WORD* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procu_austrcpy = icuuc.NewProc("u_austrcpy")
)
// dst (LPSTR), src (WORD*)
r1, _, err := procu_austrcpy.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(dst))),
uintptr(src),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // LPSTRfunction u_austrcpy(
dst: PAnsiChar; // LPSTR
src: Pointer // WORD*
): PAnsiChar; cdecl;
external 'icuuc.dll' name 'u_austrcpy';result := DllCall("icuuc\u_austrcpy"
, "AStr", dst ; LPSTR
, "Ptr", src ; WORD*
, "Cdecl Ptr") ; return: LPSTR●u_austrcpy(dst, src) = DLL("icuuc.dll", "char* u_austrcpy(char*, void*)")
# 呼び出し: u_austrcpy(dst, src)
# dst : LPSTR -> "char*"
# src : WORD* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。