⚠️ これは 非公式の翻訳サイトです。DCMTK / OFFIS とは無関係です。正確な情報は 原文(https://support.dcmtk.org/docs/mod_oficonv.html) を参照してください。

oficonv: 文字集合変換ライブラリ

このモジュールには、DCMTK での利用と DICOM 規格で使われる文字集合エンコーディングに合わせて改変した Citrus iconv 実装が含まれています。

主な関数は次のとおりです。

例

次の例は、ごく単純な文字集合変換を示します。簡潔にするため、エラー処理コードはほとんど省略しています。

// we want to convert from ISO 8859-1 to UTF-8
iconv_t id = OFiconv_open("UTF-8", "ISO-8859-1");
if (id != OFreinterpret_cast(iconv_t, -1))
{
 // set up input and output buffer
 char output[20];
 char input[20];
    strcpy(input, "J\xF6rg");

 // set up the parameters for OFiconv
 char *src_ptr = input; // Following the Posix spec, this pointer is not const
 size_t src_len = std::strlen(src_ptr);
 char *dst_ptr = output;
 size_t dst_len = 20;

 // perform the conversion
 size_t result = OFiconv(id, &src_ptr, &src_len, &dst_ptr, &dst_len);

 // null terminate
 if (dst_len > 0) *dst_ptr = '\0';

 if (result != OFstatic_cast(size_t, -1))
    {
        std::cout << "UTF-8 string: " << output << std::endl;
    }

 // close the conversion descriptor
 OFiconv_close(id);
}