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