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

uscript_getShortName

関数
スクリプトコードからスクリプトの短縮名を取得する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

LPSTR uscript_getShortName(
    UScriptCode scriptCode
);

パラメーター

名前方向説明
scriptCodeUScriptCodein短縮名を取得したいUScriptCode列挙値。4文字のISO 15924略称を返す。

戻り値の型: LPSTR

各言語での呼び出し定義

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

LPSTR uscript_getShortName(
    UScriptCode scriptCode
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr uscript_getShortName(
    int scriptCode   // UScriptCode
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function uscript_getShortName(
    scriptCode As Integer   ' UScriptCode
) As IntPtr
End Function
' scriptCode : UScriptCode
Declare PtrSafe Function uscript_getShortName Lib "icuuc" ( _
    ByVal scriptCode As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

uscript_getShortName = ctypes.cdll.icuuc.uscript_getShortName
uscript_getShortName.restype = wintypes.LPSTR
uscript_getShortName.argtypes = [
    ctypes.c_int,  # scriptCode : UScriptCode
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
uscript_getShortName = Fiddle::Function.new(
  lib['uscript_getShortName'],
  [
    Fiddle::TYPE_INT,  # scriptCode : UScriptCode
  ],
  Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn uscript_getShortName(
        scriptCode: i32  // UScriptCode
    ) -> *mut u8;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr uscript_getShortName(int scriptCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_uscript_getShortName' -Namespace Win32 -PassThru
# $api::uscript_getShortName(scriptCode)
#uselib "icuuc.dll"
#func global uscript_getShortName "uscript_getShortName" sptr
; uscript_getShortName scriptCode   ; 戻り値は stat
; scriptCode : UScriptCode -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "icuuc.dll"
#cfunc global uscript_getShortName "uscript_getShortName" int
; res = uscript_getShortName(scriptCode)
; scriptCode : UScriptCode -> "int"
; LPSTR uscript_getShortName(UScriptCode scriptCode)
#uselib "icuuc.dll"
#cfunc global uscript_getShortName "uscript_getShortName" int
; res = uscript_getShortName(scriptCode)
; scriptCode : UScriptCode -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procuscript_getShortName = icuuc.NewProc("uscript_getShortName")
)

// scriptCode (UScriptCode)
r1, _, err := procuscript_getShortName.Call(
	uintptr(scriptCode),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // LPSTR
function uscript_getShortName(
  scriptCode: Integer   // UScriptCode
): PAnsiChar; cdecl;
  external 'icuuc.dll' name 'uscript_getShortName';
result := DllCall("icuuc\uscript_getShortName"
    , "Int", scriptCode   ; UScriptCode
    , "Cdecl Ptr")   ; return: LPSTR
●uscript_getShortName(scriptCode) = DLL("icuuc.dll", "char* uscript_getShortName(int)")
# 呼び出し: uscript_getShortName(scriptCode)
# scriptCode : UScriptCode -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。
const std = @import("std");

extern "icuuc" fn uscript_getShortName(
    scriptCode: i32 // UScriptCode
) callconv(.c) [*c]const u8;
proc uscript_getShortName(
    scriptCode: int32  # UScriptCode
): cstring {.importc: "uscript_getShortName", cdecl, dynlib: "icuuc.dll".}
pragma(lib, "icuuc");
extern(C)
const(char)* uscript_getShortName(
    int scriptCode   // UScriptCode
);
ccall((:uscript_getShortName, "icuuc.dll"), Cstring,
      (Int32,),
      scriptCode)
# scriptCode : UScriptCode -> Int32
local ffi = require("ffi")
ffi.cdef[[
const char* uscript_getShortName(
    int32_t scriptCode);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.uscript_getShortName(scriptCode)
-- scriptCode : UScriptCode
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const uscript_getShortName = lib.func('__cdecl', 'uscript_getShortName', 'void *', ['int32_t']);
// uscript_getShortName(scriptCode)
// scriptCode : UScriptCode -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuuc.dll", {
  uscript_getShortName: { parameters: ["i32"], result: "pointer" },
});
// lib.symbols.uscript_getShortName(scriptCode)
// scriptCode : UScriptCode -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
const char* uscript_getShortName(
    int32_t scriptCode);
C, "icuuc.dll");
// $ffi->uscript_getShortName(scriptCode);
// scriptCode : UScriptCode
// 構造体/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 uscript_getShortName(
        int scriptCode   // UScriptCode
    );
}
@[Link("icuuc")]
lib Libicuuc
  fun uscript_getShortName = uscript_getShortName(
    scriptCode : Int32   # UScriptCode
  ) : UInt8*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef uscript_getShortNameNative = Pointer<Utf8> Function(Int32);
typedef uscript_getShortNameDart = Pointer<Utf8> Function(int);
final uscript_getShortName = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<uscript_getShortNameNative, uscript_getShortNameDart>('uscript_getShortName');
// scriptCode : UScriptCode -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function uscript_getShortName(
  scriptCode: Integer   // UScriptCode
): PAnsiChar; cdecl;
  external 'icuuc.dll' name 'uscript_getShortName';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "uscript_getShortName"
  c_uscript_getShortName :: Int32 -> IO CString
-- scriptCode : UScriptCode -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let uscript_getshortname =
  foreign "uscript_getShortName"
    (int32_t @-> returning string)
(* scriptCode : UScriptCode -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)

(cffi:defcfun ("uscript_getShortName" uscript-get-short-name :convention :cdecl) :string
  (script-code :int32))   ; UScriptCode
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $uscript_getShortName = Win32::API::More->new('icuuc',
    'LPSTR uscript_getShortName(int scriptCode)');
# my $ret = $uscript_getShortName->Call($scriptCode);
# scriptCode : UScriptCode -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型