ホーム › Globalization › u_memset
u_memset
関数UChar領域を指定文字で指定個数埋める。
シグネチャ
// icuuc.dll
#include <windows.h>
WORD* u_memset(
WORD* dest,
WORD c,
INT count
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dest | WORD* | inout | 値を設定するUTF-16バッファへのポインタ。 |
| c | WORD | in | 各要素に設定する単一UTF-16コードユニット。 |
| count | INT | in | 設定するUChar数。 |
戻り値の型: WORD*
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
WORD* u_memset(
WORD* dest,
WORD c,
INT count
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr u_memset(
ref ushort dest, // WORD* in/out
ushort c, // WORD
int count // INT
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function u_memset(
ByRef dest As UShort, ' WORD* in/out
c As UShort, ' WORD
count As Integer ' INT
) As IntPtr
End Function' dest : WORD* in/out
' c : WORD
' count : INT
Declare PtrSafe Function u_memset Lib "icuuc" ( _
ByRef dest As Integer, _
ByVal c As Integer, _
ByVal count As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
u_memset = ctypes.cdll.icuuc.u_memset
u_memset.restype = ctypes.c_void_p
u_memset.argtypes = [
ctypes.POINTER(ctypes.c_ushort), # dest : WORD* in/out
ctypes.c_ushort, # c : WORD
ctypes.c_int, # count : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
u_memset = Fiddle::Function.new(
lib['u_memset'],
[
Fiddle::TYPE_VOIDP, # dest : WORD* in/out
-Fiddle::TYPE_SHORT, # c : WORD
Fiddle::TYPE_INT, # count : INT
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn u_memset(
dest: *mut u16, // WORD* in/out
c: u16, // WORD
count: 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_memset(ref ushort dest, ushort c, int count);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_memset' -Namespace Win32 -PassThru
# $api::u_memset(dest, c, count)#uselib "icuuc.dll"
#func global u_memset "u_memset" sptr, sptr, sptr
; u_memset varptr(dest), c, count ; 戻り値は stat
; dest : WORD* in/out -> "sptr"
; c : WORD -> "sptr"
; count : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global u_memset "u_memset" var, int, int ; res = u_memset(dest, c, count) ; dest : WORD* in/out -> "var" ; c : WORD -> "int" ; count : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global u_memset "u_memset" sptr, int, int ; res = u_memset(varptr(dest), c, count) ; dest : WORD* in/out -> "sptr" ; c : WORD -> "int" ; count : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WORD* u_memset(WORD* dest, WORD c, INT count) #uselib "icuuc.dll" #cfunc global u_memset "u_memset" var, int, int ; res = u_memset(dest, c, count) ; dest : WORD* in/out -> "var" ; c : WORD -> "int" ; count : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WORD* u_memset(WORD* dest, WORD c, INT count) #uselib "icuuc.dll" #cfunc global u_memset "u_memset" intptr, int, int ; res = u_memset(varptr(dest), c, count) ; dest : WORD* in/out -> "intptr" ; c : WORD -> "int" ; count : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procu_memset = icuuc.NewProc("u_memset")
)
// dest (WORD* in/out), c (WORD), count (INT)
r1, _, err := procu_memset.Call(
uintptr(dest),
uintptr(c),
uintptr(count),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WORD*function u_memset(
dest: Pointer; // WORD* in/out
c: Word; // WORD
count: Integer // INT
): Pointer; cdecl;
external 'icuuc.dll' name 'u_memset';result := DllCall("icuuc\u_memset"
, "Ptr", dest ; WORD* in/out
, "UShort", c ; WORD
, "Int", count ; INT
, "Cdecl Ptr") ; return: WORD*●u_memset(dest, c, count) = DLL("icuuc.dll", "void* u_memset(void*, int, int)")
# 呼び出し: u_memset(dest, c, count)
# dest : WORD* in/out -> "void*"
# c : WORD -> "int"
# count : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "icuuc" fn u_memset(
dest: [*c]u16, // WORD* in/out
c: u16, // WORD
count: i32 // INT
) callconv(.c) [*c]u16;proc u_memset(
dest: ptr uint16, # WORD* in/out
c: uint16, # WORD
count: int32 # INT
): ptr uint16 {.importc: "u_memset", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
ushort* u_memset(
ushort* dest, // WORD* in/out
ushort c, // WORD
int count // INT
);ccall((:u_memset, "icuuc.dll"), Ptr{UInt16},
(Ptr{UInt16}, UInt16, Int32),
dest, c, count)
# dest : WORD* in/out -> Ptr{UInt16}
# c : WORD -> UInt16
# count : INT -> Int32local ffi = require("ffi")
ffi.cdef[[
uint16_t* u_memset(
uint16_t* dest,
uint16_t c,
int32_t count);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.u_memset(dest, c, count)
-- dest : WORD* in/out
-- c : WORD
-- count : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const u_memset = lib.func('__cdecl', 'u_memset', 'uint16_t *', ['uint16_t *', 'uint16_t', 'int32_t']);
// u_memset(dest, c, count)
// dest : WORD* in/out -> 'uint16_t *'
// c : WORD -> 'uint16_t'
// count : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
u_memset: { parameters: ["pointer", "u16", "i32"], result: "pointer" },
});
// lib.symbols.u_memset(dest, c, count)
// dest : WORD* in/out -> "pointer"
// c : WORD -> "u16"
// count : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint16_t* u_memset(
uint16_t* dest,
uint16_t c,
int32_t count);
C, "icuuc.dll");
// $ffi->u_memset(dest, c, count);
// dest : WORD* in/out
// c : WORD
// count : INT
// 構造体/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_memset(
ShortByReference dest, // WORD* in/out
short c, // WORD
int count // INT
);
}@[Link("icuuc")]
lib Libicuuc
fun u_memset = u_memset(
dest : UInt16*, # WORD* in/out
c : UInt16, # WORD
count : Int32 # INT
) : UInt16*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef u_memsetNative = Pointer<Uint16> Function(Pointer<Uint16>, Uint16, Int32);
typedef u_memsetDart = Pointer<Uint16> Function(Pointer<Uint16>, int, int);
final u_memset = DynamicLibrary.open('icuuc.dll')
.lookupFunction<u_memsetNative, u_memsetDart>('u_memset');
// dest : WORD* in/out -> Pointer<Uint16>
// c : WORD -> Uint16
// count : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function u_memset(
dest: Pointer; // WORD* in/out
c: Word; // WORD
count: Integer // INT
): Pointer; cdecl;
external 'icuuc.dll' name 'u_memset';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "u_memset"
c_u_memset :: Ptr Word16 -> Word16 -> Int32 -> IO (Ptr Word16)
-- dest : WORD* in/out -> Ptr Word16
-- c : WORD -> Word16
-- count : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let u_memset =
foreign "u_memset"
((ptr uint16_t) @-> uint16_t @-> int32_t @-> returning (ptr uint16_t))
(* dest : WORD* in/out -> (ptr uint16_t) *)
(* c : WORD -> uint16_t *)
(* count : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)
(cffi:defcfun ("u_memset" u-memset :convention :cdecl) :pointer
(dest :pointer) ; WORD* in/out
(c :uint16) ; WORD
(count :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $u_memset = Win32::API::More->new('icuuc',
'LPVOID u_memset(LPVOID dest, WORD c, int count)');
# my $ret = $u_memset->Call($dest, $c, $count);
# dest : WORD* in/out -> LPVOID
# c : WORD -> WORD
# count : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。