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