ホーム › Globalization › uloc_toLegacyKey
uloc_toLegacyKey
関数Unicodeロケール拡張キーをレガシーキーワードに変換する。
シグネチャ
// icuuc.dll
#include <windows.h>
LPSTR uloc_toLegacyKey(
LPCSTR keyword
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| keyword | LPCSTR | in | Unicodeロケール拡張キー。対応するレガシーキーワード名を返す。未知ならNULL。 |
戻り値の型: LPSTR
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
LPSTR uloc_toLegacyKey(
LPCSTR keyword
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr uloc_toLegacyKey(
[MarshalAs(UnmanagedType.LPStr)] string keyword // LPCSTR
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function uloc_toLegacyKey(
<MarshalAs(UnmanagedType.LPStr)> keyword As String ' LPCSTR
) As IntPtr
End Function' keyword : LPCSTR
Declare PtrSafe Function uloc_toLegacyKey Lib "icuuc" ( _
ByVal keyword As String) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
uloc_toLegacyKey = ctypes.cdll.icuuc.uloc_toLegacyKey
uloc_toLegacyKey.restype = wintypes.LPSTR
uloc_toLegacyKey.argtypes = [
wintypes.LPCSTR, # keyword : LPCSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
uloc_toLegacyKey = Fiddle::Function.new(
lib['uloc_toLegacyKey'],
[
Fiddle::TYPE_VOIDP, # keyword : LPCSTR
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn uloc_toLegacyKey(
keyword: *const u8 // LPCSTR
) -> *mut u8;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr uloc_toLegacyKey([MarshalAs(UnmanagedType.LPStr)] string keyword);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_uloc_toLegacyKey' -Namespace Win32 -PassThru
# $api::uloc_toLegacyKey(keyword)#uselib "icuuc.dll"
#func global uloc_toLegacyKey "uloc_toLegacyKey" sptr
; uloc_toLegacyKey keyword ; 戻り値は stat
; keyword : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "icuuc.dll"
#cfunc global uloc_toLegacyKey "uloc_toLegacyKey" str
; res = uloc_toLegacyKey(keyword)
; keyword : LPCSTR -> "str"; LPSTR uloc_toLegacyKey(LPCSTR keyword)
#uselib "icuuc.dll"
#cfunc global uloc_toLegacyKey "uloc_toLegacyKey" str
; res = uloc_toLegacyKey(keyword)
; keyword : LPCSTR -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
proculoc_toLegacyKey = icuuc.NewProc("uloc_toLegacyKey")
)
// keyword (LPCSTR)
r1, _, err := proculoc_toLegacyKey.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(keyword))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // LPSTRfunction uloc_toLegacyKey(
keyword: PAnsiChar // LPCSTR
): PAnsiChar; cdecl;
external 'icuuc.dll' name 'uloc_toLegacyKey';result := DllCall("icuuc\uloc_toLegacyKey"
, "AStr", keyword ; LPCSTR
, "Cdecl Ptr") ; return: LPSTR●uloc_toLegacyKey(keyword) = DLL("icuuc.dll", "char* uloc_toLegacyKey(char*)")
# 呼び出し: uloc_toLegacyKey(keyword)
# keyword : 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 uloc_toLegacyKey(
keyword: [*c]const u8 // LPCSTR
) callconv(.c) [*c]const u8;proc uloc_toLegacyKey(
keyword: cstring # LPCSTR
): cstring {.importc: "uloc_toLegacyKey", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
const(char)* uloc_toLegacyKey(
const(char)* keyword // LPCSTR
);ccall((:uloc_toLegacyKey, "icuuc.dll"), Cstring,
(Cstring,),
keyword)
# keyword : LPCSTR -> Cstringlocal ffi = require("ffi")
ffi.cdef[[
const char* uloc_toLegacyKey(
const char* keyword);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.uloc_toLegacyKey(keyword)
-- keyword : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const uloc_toLegacyKey = lib.func('__cdecl', 'uloc_toLegacyKey', 'void *', ['str']);
// uloc_toLegacyKey(keyword)
// keyword : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
uloc_toLegacyKey: { parameters: ["buffer"], result: "pointer" },
});
// lib.symbols.uloc_toLegacyKey(keyword)
// keyword : LPCSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
const char* uloc_toLegacyKey(
const char* keyword);
C, "icuuc.dll");
// $ffi->uloc_toLegacyKey(keyword);
// keyword : 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 uloc_toLegacyKey(
String keyword // LPCSTR
);
}@[Link("icuuc")]
lib Libicuuc
fun uloc_toLegacyKey = uloc_toLegacyKey(
keyword : UInt8* # LPCSTR
) : UInt8*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef uloc_toLegacyKeyNative = Pointer<Utf8> Function(Pointer<Utf8>);
typedef uloc_toLegacyKeyDart = Pointer<Utf8> Function(Pointer<Utf8>);
final uloc_toLegacyKey = DynamicLibrary.open('icuuc.dll')
.lookupFunction<uloc_toLegacyKeyNative, uloc_toLegacyKeyDart>('uloc_toLegacyKey');
// keyword : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function uloc_toLegacyKey(
keyword: PAnsiChar // LPCSTR
): PAnsiChar; cdecl;
external 'icuuc.dll' name 'uloc_toLegacyKey';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "uloc_toLegacyKey"
c_uloc_toLegacyKey :: CString -> IO CString
-- keyword : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let uloc_tolegacykey =
foreign "uloc_toLegacyKey"
(string @-> returning string)
(* keyword : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)
(cffi:defcfun ("uloc_toLegacyKey" uloc-to-legacy-key :convention :cdecl) :string
(keyword :string)) ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $uloc_toLegacyKey = Win32::API::More->new('icuuc',
'LPSTR uloc_toLegacyKey(LPCSTR keyword)');
# my $ret = $uloc_toLegacyKey->Call($keyword);
# keyword : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。