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