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

u_strncat

関数
UChar文字列を最大n文字まで連結する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

WORD* u_strncat(
    WORD* dst,
    const WORD* src,
    INT n
);

パラメーター

名前方向説明
dstWORD*inout連結先のNUL終端UTF-16文字列バッファへのポインタ。
srcWORD*in連結する元のUTF-16文字列へのポインタ。
nINTinsrcから連結する最大UChar数。

戻り値の型: WORD*

各言語での呼び出し定義

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

WORD* u_strncat(
    WORD* dst,
    const WORD* src,
    INT n
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr u_strncat(
    ref ushort dst,   // WORD* in/out
    ref ushort src,   // WORD*
    int n   // INT
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function u_strncat(
    ByRef dst As UShort,   ' WORD* in/out
    ByRef src As UShort,   ' WORD*
    n As Integer   ' INT
) As IntPtr
End Function
' dst : WORD* in/out
' src : WORD*
' n : INT
Declare PtrSafe Function u_strncat Lib "icuuc" ( _
    ByRef dst As Integer, _
    ByRef src As Integer, _
    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_strncat = ctypes.cdll.icuuc.u_strncat
u_strncat.restype = ctypes.c_void_p
u_strncat.argtypes = [
    ctypes.POINTER(ctypes.c_ushort),  # dst : WORD* in/out
    ctypes.POINTER(ctypes.c_ushort),  # src : WORD*
    ctypes.c_int,  # n : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
u_strncat = Fiddle::Function.new(
  lib['u_strncat'],
  [
    Fiddle::TYPE_VOIDP,  # dst : WORD* in/out
    Fiddle::TYPE_VOIDP,  # src : WORD*
    Fiddle::TYPE_INT,  # n : INT
  ],
  Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn u_strncat(
        dst: *mut u16,  // WORD* in/out
        src: *const u16,  // WORD*
        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_strncat(ref ushort dst, ref ushort src, int n);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_strncat' -Namespace Win32 -PassThru
# $api::u_strncat(dst, src, n)
#uselib "icuuc.dll"
#func global u_strncat "u_strncat" sptr, sptr, sptr
; u_strncat varptr(dst), varptr(src), n   ; 戻り値は stat
; dst : WORD* in/out -> "sptr"
; src : WORD* -> "sptr"
; n : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global u_strncat "u_strncat" var, var, int
; res = u_strncat(dst, src, n)
; dst : WORD* in/out -> "var"
; src : WORD* -> "var"
; n : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; WORD* u_strncat(WORD* dst, WORD* src, INT n)
#uselib "icuuc.dll"
#cfunc global u_strncat "u_strncat" var, var, int
; res = u_strncat(dst, src, n)
; dst : WORD* in/out -> "var"
; src : WORD* -> "var"
; n : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procu_strncat = icuuc.NewProc("u_strncat")
)

// dst (WORD* in/out), src (WORD*), n (INT)
r1, _, err := procu_strncat.Call(
	uintptr(dst),
	uintptr(src),
	uintptr(n),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WORD*
function u_strncat(
  dst: Pointer;   // WORD* in/out
  src: Pointer;   // WORD*
  n: Integer   // INT
): Pointer; cdecl;
  external 'icuuc.dll' name 'u_strncat';
result := DllCall("icuuc\u_strncat"
    , "Ptr", dst   ; WORD* in/out
    , "Ptr", src   ; WORD*
    , "Int", n   ; INT
    , "Cdecl Ptr")   ; return: WORD*
●u_strncat(dst, src, n) = DLL("icuuc.dll", "void* u_strncat(void*, void*, int)")
# 呼び出し: u_strncat(dst, src, n)
# dst : WORD* in/out -> "void*"
# src : WORD* -> "void*"
# n : 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_strncat(
    dst: [*c]u16, // WORD* in/out
    src: [*c]u16, // WORD*
    n: i32 // INT
) callconv(.c) [*c]u16;
proc u_strncat(
    dst: ptr uint16,  # WORD* in/out
    src: ptr uint16,  # WORD*
    n: int32  # INT
): ptr uint16 {.importc: "u_strncat", cdecl, dynlib: "icuuc.dll".}
pragma(lib, "icuuc");
extern(C)
ushort* u_strncat(
    ushort* dst,   // WORD* in/out
    ushort* src,   // WORD*
    int n   // INT
);
ccall((:u_strncat, "icuuc.dll"), Ptr{UInt16},
      (Ptr{UInt16}, Ptr{UInt16}, Int32),
      dst, src, n)
# dst : WORD* in/out -> Ptr{UInt16}
# src : WORD* -> Ptr{UInt16}
# n : INT -> Int32
local ffi = require("ffi")
ffi.cdef[[
uint16_t* u_strncat(
    uint16_t* dst,
    uint16_t* src,
    int32_t n);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.u_strncat(dst, src, n)
-- dst : WORD* in/out
-- src : WORD*
-- n : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const u_strncat = lib.func('__cdecl', 'u_strncat', 'uint16_t *', ['uint16_t *', 'uint16_t *', 'int32_t']);
// u_strncat(dst, src, n)
// dst : WORD* in/out -> 'uint16_t *'
// src : WORD* -> 'uint16_t *'
// n : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuuc.dll", {
  u_strncat: { parameters: ["pointer", "pointer", "i32"], result: "pointer" },
});
// lib.symbols.u_strncat(dst, src, n)
// dst : WORD* in/out -> "pointer"
// src : WORD* -> "pointer"
// n : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint16_t* u_strncat(
    uint16_t* dst,
    uint16_t* src,
    int32_t n);
C, "icuuc.dll");
// $ffi->u_strncat(dst, src, n);
// dst : WORD* in/out
// src : WORD*
// n : 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_strncat(
        ShortByReference dst,   // WORD* in/out
        ShortByReference src,   // WORD*
        int n   // INT
    );
}
@[Link("icuuc")]
lib Libicuuc
  fun u_strncat = u_strncat(
    dst : UInt16*,   # WORD* in/out
    src : UInt16*,   # WORD*
    n : Int32   # INT
  ) : UInt16*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef u_strncatNative = Pointer<Uint16> Function(Pointer<Uint16>, Pointer<Uint16>, Int32);
typedef u_strncatDart = Pointer<Uint16> Function(Pointer<Uint16>, Pointer<Uint16>, int);
final u_strncat = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<u_strncatNative, u_strncatDart>('u_strncat');
// dst : WORD* in/out -> Pointer<Uint16>
// src : WORD* -> Pointer<Uint16>
// n : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function u_strncat(
  dst: Pointer;   // WORD* in/out
  src: Pointer;   // WORD*
  n: Integer   // INT
): Pointer; cdecl;
  external 'icuuc.dll' name 'u_strncat';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "u_strncat"
  c_u_strncat :: Ptr Word16 -> Ptr Word16 -> Int32 -> IO (Ptr Word16)
-- dst : WORD* in/out -> Ptr Word16
-- src : WORD* -> Ptr Word16
-- n : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let u_strncat =
  foreign "u_strncat"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> int32_t @-> returning (ptr uint16_t))
(* dst : WORD* in/out -> (ptr uint16_t) *)
(* src : WORD* -> (ptr uint16_t) *)
(* n : 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_strncat" u-strncat :convention :cdecl) :pointer
  (dst :pointer)   ; WORD* in/out
  (src :pointer)   ; WORD*
  (n :int32))   ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $u_strncat = Win32::API::More->new('icuuc',
    'LPVOID u_strncat(LPVOID dst, LPVOID src, int n)');
# my $ret = $u_strncat->Call($dst, $src, $n);
# dst : WORD* in/out -> LPVOID
# src : WORD* -> LPVOID
# n : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。