ホーム › Globalization › u_uastrcpy
u_uastrcpy
関数ASCII文字列をUChar文字列に変換してコピーする。
シグネチャ
// icuuc.dll
#include <windows.h>
WORD* u_uastrcpy(
WORD* dst,
LPCSTR src
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dst | WORD* | inout | 変換コピー先のUTF-16バッファへのポインタ。 |
| src | LPCSTR | in | コピー元の不変ASCII(char)NUL終端文字列へのポインタ。UTF-16へ変換して格納する。 |
戻り値の型: 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 方式にも切替可。#uselib "icuuc.dll" #cfunc global u_uastrcpy "u_uastrcpy" sptr, str ; res = u_uastrcpy(varptr(dst), src) ; dst : WORD* in/out -> "sptr" ; src : LPCSTR -> "str" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; WORD* u_uastrcpy(WORD* dst, LPCSTR src) #uselib "icuuc.dll" #cfunc global u_uastrcpy "u_uastrcpy" intptr, str ; res = u_uastrcpy(varptr(dst), src) ; dst : WORD* in/out -> "intptr" ; src : LPCSTR -> "str" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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`,…) を使用。const std = @import("std");
extern "icuuc" fn u_uastrcpy(
dst: [*c]u16, // WORD* in/out
src: [*c]const u8 // LPCSTR
) callconv(.c) [*c]u16;proc u_uastrcpy(
dst: ptr uint16, # WORD* in/out
src: cstring # LPCSTR
): ptr uint16 {.importc: "u_uastrcpy", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
ushort* u_uastrcpy(
ushort* dst, // WORD* in/out
const(char)* src // LPCSTR
);ccall((:u_uastrcpy, "icuuc.dll"), Ptr{UInt16},
(Ptr{UInt16}, Cstring),
dst, src)
# dst : WORD* in/out -> Ptr{UInt16}
# src : LPCSTR -> Cstringlocal ffi = require("ffi")
ffi.cdef[[
uint16_t* u_uastrcpy(
uint16_t* dst,
const char* src);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.u_uastrcpy(dst, src)
-- dst : WORD* in/out
-- src : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const u_uastrcpy = lib.func('__cdecl', 'u_uastrcpy', 'uint16_t *', ['uint16_t *', 'str']);
// u_uastrcpy(dst, src)
// dst : WORD* in/out -> 'uint16_t *'
// src : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
u_uastrcpy: { parameters: ["pointer", "buffer"], result: "pointer" },
});
// lib.symbols.u_uastrcpy(dst, src)
// dst : WORD* in/out -> "pointer"
// src : LPCSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint16_t* u_uastrcpy(
uint16_t* dst,
const char* src);
C, "icuuc.dll");
// $ffi->u_uastrcpy(dst, src);
// dst : WORD* in/out
// src : LPCSTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Icuuc extends Library {
Icuuc INSTANCE = Native.load("icuuc", Icuuc.class);
Pointer u_uastrcpy(
ShortByReference dst, // WORD* in/out
String src // LPCSTR
);
}@[Link("icuuc")]
lib Libicuuc
fun u_uastrcpy = u_uastrcpy(
dst : UInt16*, # WORD* in/out
src : UInt8* # LPCSTR
) : UInt16*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef u_uastrcpyNative = Pointer<Uint16> Function(Pointer<Uint16>, Pointer<Utf8>);
typedef u_uastrcpyDart = Pointer<Uint16> Function(Pointer<Uint16>, Pointer<Utf8>);
final u_uastrcpy = DynamicLibrary.open('icuuc.dll')
.lookupFunction<u_uastrcpyNative, u_uastrcpyDart>('u_uastrcpy');
// dst : WORD* in/out -> Pointer<Uint16>
// src : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function u_uastrcpy(
dst: Pointer; // WORD* in/out
src: PAnsiChar // LPCSTR
): Pointer; cdecl;
external 'icuuc.dll' name 'u_uastrcpy';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "u_uastrcpy"
c_u_uastrcpy :: Ptr Word16 -> CString -> IO (Ptr Word16)
-- dst : WORD* in/out -> Ptr Word16
-- src : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let u_uastrcpy =
foreign "u_uastrcpy"
((ptr uint16_t) @-> string @-> returning (ptr uint16_t))
(* dst : WORD* in/out -> (ptr uint16_t) *)
(* src : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)
(cffi:defcfun ("u_uastrcpy" u-uastrcpy :convention :cdecl) :pointer
(dst :pointer) ; WORD* in/out
(src :string)) ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $u_uastrcpy = Win32::API::More->new('icuuc',
'LPVOID u_uastrcpy(LPVOID dst, LPCSTR src)');
# my $ret = $u_uastrcpy->Call($dst, $src);
# dst : WORD* in/out -> LPVOID
# src : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。