ホーム › Globalization › ucol_mergeSortkeys
ucol_mergeSortkeys
関数二つのソートキーを結合して一つのキーにする。
シグネチャ
// icuin.dll
#include <windows.h>
INT ucol_mergeSortkeys(
const BYTE* src1,
INT src1Length,
const BYTE* src2,
INT src2Length,
BYTE* dest,
INT destCapacity
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| src1 | BYTE* | in | 結合する1つ目のソートキーのバイト列。 |
| src1Length | INT | in | src1の長さ(バイト数)。-1でNUL終端として扱う。 |
| src2 | BYTE* | in | 結合する2つ目のソートキーのバイト列。 |
| src2Length | INT | in | src2の長さ(バイト数)。-1でNUL終端として扱う。 |
| dest | BYTE* | inout | 結合結果のソートキーを書き込む出力バイトバッファ。 |
| destCapacity | INT | in | destバッファの容量(バイト数)。0で必要長を取得する。 |
戻り値の型: INT
各言語での呼び出し定義
// icuin.dll
#include <windows.h>
INT ucol_mergeSortkeys(
const BYTE* src1,
INT src1Length,
const BYTE* src2,
INT src2Length,
BYTE* dest,
INT destCapacity
);[DllImport("icuin.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int ucol_mergeSortkeys(
IntPtr src1, // BYTE*
int src1Length, // INT
IntPtr src2, // BYTE*
int src2Length, // INT
IntPtr dest, // BYTE* in/out
int destCapacity // INT
);<DllImport("icuin.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucol_mergeSortkeys(
src1 As IntPtr, ' BYTE*
src1Length As Integer, ' INT
src2 As IntPtr, ' BYTE*
src2Length As Integer, ' INT
dest As IntPtr, ' BYTE* in/out
destCapacity As Integer ' INT
) As Integer
End Function' src1 : BYTE*
' src1Length : INT
' src2 : BYTE*
' src2Length : INT
' dest : BYTE* in/out
' destCapacity : INT
Declare PtrSafe Function ucol_mergeSortkeys Lib "icuin" ( _
ByVal src1 As LongPtr, _
ByVal src1Length As Long, _
ByVal src2 As LongPtr, _
ByVal src2Length As Long, _
ByVal dest As LongPtr, _
ByVal destCapacity As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ucol_mergeSortkeys = ctypes.cdll.icuin.ucol_mergeSortkeys
ucol_mergeSortkeys.restype = ctypes.c_int
ucol_mergeSortkeys.argtypes = [
ctypes.POINTER(ctypes.c_ubyte), # src1 : BYTE*
ctypes.c_int, # src1Length : INT
ctypes.POINTER(ctypes.c_ubyte), # src2 : BYTE*
ctypes.c_int, # src2Length : INT
ctypes.POINTER(ctypes.c_ubyte), # dest : BYTE* in/out
ctypes.c_int, # destCapacity : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuin.dll')
ucol_mergeSortkeys = Fiddle::Function.new(
lib['ucol_mergeSortkeys'],
[
Fiddle::TYPE_VOIDP, # src1 : BYTE*
Fiddle::TYPE_INT, # src1Length : INT
Fiddle::TYPE_VOIDP, # src2 : BYTE*
Fiddle::TYPE_INT, # src2Length : INT
Fiddle::TYPE_VOIDP, # dest : BYTE* in/out
Fiddle::TYPE_INT, # destCapacity : INT
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuin")]
extern "C" {
fn ucol_mergeSortkeys(
src1: *const u8, // BYTE*
src1Length: i32, // INT
src2: *const u8, // BYTE*
src2Length: i32, // INT
dest: *mut u8, // BYTE* in/out
destCapacity: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuin.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int ucol_mergeSortkeys(IntPtr src1, int src1Length, IntPtr src2, int src2Length, IntPtr dest, int destCapacity);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuin_ucol_mergeSortkeys' -Namespace Win32 -PassThru
# $api::ucol_mergeSortkeys(src1, src1Length, src2, src2Length, dest, destCapacity)#uselib "icuin.dll"
#func global ucol_mergeSortkeys "ucol_mergeSortkeys" sptr, sptr, sptr, sptr, sptr, sptr
; ucol_mergeSortkeys varptr(src1), src1Length, varptr(src2), src2Length, varptr(dest), destCapacity ; 戻り値は stat
; src1 : BYTE* -> "sptr"
; src1Length : INT -> "sptr"
; src2 : BYTE* -> "sptr"
; src2Length : INT -> "sptr"
; dest : BYTE* in/out -> "sptr"
; destCapacity : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuin.dll" #cfunc global ucol_mergeSortkeys "ucol_mergeSortkeys" var, int, var, int, var, int ; res = ucol_mergeSortkeys(src1, src1Length, src2, src2Length, dest, destCapacity) ; src1 : BYTE* -> "var" ; src1Length : INT -> "int" ; src2 : BYTE* -> "var" ; src2Length : INT -> "int" ; dest : BYTE* in/out -> "var" ; destCapacity : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuin.dll" #cfunc global ucol_mergeSortkeys "ucol_mergeSortkeys" sptr, int, sptr, int, sptr, int ; res = ucol_mergeSortkeys(varptr(src1), src1Length, varptr(src2), src2Length, varptr(dest), destCapacity) ; src1 : BYTE* -> "sptr" ; src1Length : INT -> "int" ; src2 : BYTE* -> "sptr" ; src2Length : INT -> "int" ; dest : BYTE* in/out -> "sptr" ; destCapacity : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT ucol_mergeSortkeys(BYTE* src1, INT src1Length, BYTE* src2, INT src2Length, BYTE* dest, INT destCapacity) #uselib "icuin.dll" #cfunc global ucol_mergeSortkeys "ucol_mergeSortkeys" var, int, var, int, var, int ; res = ucol_mergeSortkeys(src1, src1Length, src2, src2Length, dest, destCapacity) ; src1 : BYTE* -> "var" ; src1Length : INT -> "int" ; src2 : BYTE* -> "var" ; src2Length : INT -> "int" ; dest : BYTE* in/out -> "var" ; destCapacity : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT ucol_mergeSortkeys(BYTE* src1, INT src1Length, BYTE* src2, INT src2Length, BYTE* dest, INT destCapacity) #uselib "icuin.dll" #cfunc global ucol_mergeSortkeys "ucol_mergeSortkeys" intptr, int, intptr, int, intptr, int ; res = ucol_mergeSortkeys(varptr(src1), src1Length, varptr(src2), src2Length, varptr(dest), destCapacity) ; src1 : BYTE* -> "intptr" ; src1Length : INT -> "int" ; src2 : BYTE* -> "intptr" ; src2Length : INT -> "int" ; dest : BYTE* in/out -> "intptr" ; destCapacity : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuin = windows.NewLazySystemDLL("icuin.dll")
procucol_mergeSortkeys = icuin.NewProc("ucol_mergeSortkeys")
)
// src1 (BYTE*), src1Length (INT), src2 (BYTE*), src2Length (INT), dest (BYTE* in/out), destCapacity (INT)
r1, _, err := procucol_mergeSortkeys.Call(
uintptr(src1),
uintptr(src1Length),
uintptr(src2),
uintptr(src2Length),
uintptr(dest),
uintptr(destCapacity),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction ucol_mergeSortkeys(
src1: Pointer; // BYTE*
src1Length: Integer; // INT
src2: Pointer; // BYTE*
src2Length: Integer; // INT
dest: Pointer; // BYTE* in/out
destCapacity: Integer // INT
): Integer; cdecl;
external 'icuin.dll' name 'ucol_mergeSortkeys';result := DllCall("icuin\ucol_mergeSortkeys"
, "Ptr", src1 ; BYTE*
, "Int", src1Length ; INT
, "Ptr", src2 ; BYTE*
, "Int", src2Length ; INT
, "Ptr", dest ; BYTE* in/out
, "Int", destCapacity ; INT
, "Cdecl Int") ; return: INT●ucol_mergeSortkeys(src1, src1Length, src2, src2Length, dest, destCapacity) = DLL("icuin.dll", "int ucol_mergeSortkeys(void*, int, void*, int, void*, int)")
# 呼び出し: ucol_mergeSortkeys(src1, src1Length, src2, src2Length, dest, destCapacity)
# src1 : BYTE* -> "void*"
# src1Length : INT -> "int"
# src2 : BYTE* -> "void*"
# src2Length : INT -> "int"
# dest : BYTE* in/out -> "void*"
# destCapacity : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "icuin" fn ucol_mergeSortkeys(
src1: [*c]u8, // BYTE*
src1Length: i32, // INT
src2: [*c]u8, // BYTE*
src2Length: i32, // INT
dest: [*c]u8, // BYTE* in/out
destCapacity: i32 // INT
) callconv(.c) i32;proc ucol_mergeSortkeys(
src1: ptr uint8, # BYTE*
src1Length: int32, # INT
src2: ptr uint8, # BYTE*
src2Length: int32, # INT
dest: ptr uint8, # BYTE* in/out
destCapacity: int32 # INT
): int32 {.importc: "ucol_mergeSortkeys", cdecl, dynlib: "icuin.dll".}pragma(lib, "icuin");
extern(C)
int ucol_mergeSortkeys(
ubyte* src1, // BYTE*
int src1Length, // INT
ubyte* src2, // BYTE*
int src2Length, // INT
ubyte* dest, // BYTE* in/out
int destCapacity // INT
);ccall((:ucol_mergeSortkeys, "icuin.dll"), Int32,
(Ptr{UInt8}, Int32, Ptr{UInt8}, Int32, Ptr{UInt8}, Int32),
src1, src1Length, src2, src2Length, dest, destCapacity)
# src1 : BYTE* -> Ptr{UInt8}
# src1Length : INT -> Int32
# src2 : BYTE* -> Ptr{UInt8}
# src2Length : INT -> Int32
# dest : BYTE* in/out -> Ptr{UInt8}
# destCapacity : INT -> Int32local ffi = require("ffi")
ffi.cdef[[
int32_t ucol_mergeSortkeys(
uint8_t* src1,
int32_t src1Length,
uint8_t* src2,
int32_t src2Length,
uint8_t* dest,
int32_t destCapacity);
]]
local icuin = ffi.load("icuin")
-- icuin.ucol_mergeSortkeys(src1, src1Length, src2, src2Length, dest, destCapacity)
-- src1 : BYTE*
-- src1Length : INT
-- src2 : BYTE*
-- src2Length : INT
-- dest : BYTE* in/out
-- destCapacity : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuin.dll');
const ucol_mergeSortkeys = lib.func('__cdecl', 'ucol_mergeSortkeys', 'int32_t', ['uint8_t *', 'int32_t', 'uint8_t *', 'int32_t', 'uint8_t *', 'int32_t']);
// ucol_mergeSortkeys(src1, src1Length, src2, src2Length, dest, destCapacity)
// src1 : BYTE* -> 'uint8_t *'
// src1Length : INT -> 'int32_t'
// src2 : BYTE* -> 'uint8_t *'
// src2Length : INT -> 'int32_t'
// dest : BYTE* in/out -> 'uint8_t *'
// destCapacity : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuin.dll", {
ucol_mergeSortkeys: { parameters: ["pointer", "i32", "pointer", "i32", "pointer", "i32"], result: "i32" },
});
// lib.symbols.ucol_mergeSortkeys(src1, src1Length, src2, src2Length, dest, destCapacity)
// src1 : BYTE* -> "pointer"
// src1Length : INT -> "i32"
// src2 : BYTE* -> "pointer"
// src2Length : INT -> "i32"
// dest : BYTE* in/out -> "pointer"
// destCapacity : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ucol_mergeSortkeys(
uint8_t* src1,
int32_t src1Length,
uint8_t* src2,
int32_t src2Length,
uint8_t* dest,
int32_t destCapacity);
C, "icuin.dll");
// $ffi->ucol_mergeSortkeys(src1, src1Length, src2, src2Length, dest, destCapacity);
// src1 : BYTE*
// src1Length : INT
// src2 : BYTE*
// src2Length : INT
// dest : BYTE* in/out
// destCapacity : 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 Icuin extends Library {
Icuin INSTANCE = Native.load("icuin", Icuin.class);
int ucol_mergeSortkeys(
byte[] src1, // BYTE*
int src1Length, // INT
byte[] src2, // BYTE*
int src2Length, // INT
byte[] dest, // BYTE* in/out
int destCapacity // INT
);
}@[Link("icuin")]
lib Libicuin
fun ucol_mergeSortkeys = ucol_mergeSortkeys(
src1 : UInt8*, # BYTE*
src1Length : Int32, # INT
src2 : UInt8*, # BYTE*
src2Length : Int32, # INT
dest : UInt8*, # BYTE* in/out
destCapacity : Int32 # INT
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ucol_mergeSortkeysNative = Int32 Function(Pointer<Uint8>, Int32, Pointer<Uint8>, Int32, Pointer<Uint8>, Int32);
typedef ucol_mergeSortkeysDart = int Function(Pointer<Uint8>, int, Pointer<Uint8>, int, Pointer<Uint8>, int);
final ucol_mergeSortkeys = DynamicLibrary.open('icuin.dll')
.lookupFunction<ucol_mergeSortkeysNative, ucol_mergeSortkeysDart>('ucol_mergeSortkeys');
// src1 : BYTE* -> Pointer<Uint8>
// src1Length : INT -> Int32
// src2 : BYTE* -> Pointer<Uint8>
// src2Length : INT -> Int32
// dest : BYTE* in/out -> Pointer<Uint8>
// destCapacity : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ucol_mergeSortkeys(
src1: Pointer; // BYTE*
src1Length: Integer; // INT
src2: Pointer; // BYTE*
src2Length: Integer; // INT
dest: Pointer; // BYTE* in/out
destCapacity: Integer // INT
): Integer; cdecl;
external 'icuin.dll' name 'ucol_mergeSortkeys';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ucol_mergeSortkeys"
c_ucol_mergeSortkeys :: Ptr Word8 -> Int32 -> Ptr Word8 -> Int32 -> Ptr Word8 -> Int32 -> IO Int32
-- src1 : BYTE* -> Ptr Word8
-- src1Length : INT -> Int32
-- src2 : BYTE* -> Ptr Word8
-- src2Length : INT -> Int32
-- dest : BYTE* in/out -> Ptr Word8
-- destCapacity : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ucol_mergesortkeys =
foreign "ucol_mergeSortkeys"
((ptr uint8_t) @-> int32_t @-> (ptr uint8_t) @-> int32_t @-> (ptr uint8_t) @-> int32_t @-> returning int32_t)
(* src1 : BYTE* -> (ptr uint8_t) *)
(* src1Length : INT -> int32_t *)
(* src2 : BYTE* -> (ptr uint8_t) *)
(* src2Length : INT -> int32_t *)
(* dest : BYTE* in/out -> (ptr uint8_t) *)
(* destCapacity : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuin (t "icuin.dll"))
(cffi:use-foreign-library icuin)
(cffi:defcfun ("ucol_mergeSortkeys" ucol-merge-sortkeys :convention :cdecl) :int32
(src1 :pointer) ; BYTE*
(src1-length :int32) ; INT
(src2 :pointer) ; BYTE*
(src2-length :int32) ; INT
(dest :pointer) ; BYTE* in/out
(dest-capacity :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ucol_mergeSortkeys = Win32::API::More->new('icuin',
'int ucol_mergeSortkeys(LPVOID src1, int src1Length, LPVOID src2, int src2Length, LPVOID dest, int destCapacity)');
# my $ret = $ucol_mergeSortkeys->Call($src1, $src1Length, $src2, $src2Length, $dest, $destCapacity);
# src1 : BYTE* -> LPVOID
# src1Length : INT -> int
# src2 : BYTE* -> LPVOID
# src2Length : INT -> int
# dest : BYTE* in/out -> LPVOID
# destCapacity : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。