diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index ca4ea277..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -ChangeLog merge=merge-changelog diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9e32a341..a6638a16 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,61 +11,43 @@ jobs: runs-on: ubuntu-latest steps: + - name: ๐Ÿ“ Checkout + uses: actions/checkout@v4 - #--------------------------------------------collect-------------------------------------------- - - uses: actions/checkout@v3 - - - name: ๐Ÿท๏ธ Get infomations - run: | - tag="${GITHUB_REF#refs/tags/}" - echo "tag=$tag" >> $GITHUB_ENV - echo "pkgname=cppp-reiconv-$tag" >> $GITHUB_ENV - echo "srcdir=$(pwd)" >> $GITHUB_ENV + - name: ๐Ÿงฐ Setup Rubisco + id: rubisco + uses: cppp-project/rubisco@main + with: + host: x86_64-linux-gnu - - name: ๐Ÿ“ Collect dependencies - run: | - sudo apt-get update - sudo apt-get install p7zip-full zip xz-utils -y - sudo apt-get install gperf cmake gcc python3 -y - - #--------------------------------------------build-------------------------------------------- - - name: ๐Ÿงณ Prepare for source distribution building - run: | - mkdir -p ./dist - ./setup.sh - - - name: ๐Ÿ› ๏ธ Build source distribution + - name: ๐Ÿ“ Collect subpackages run: | - ./cpppdist.py - - - name: ๐Ÿ“ฆ Make packages + git clone https://github.com/cppp-project/build-aux --depth 1 + git clone https://github.com/cppp-project/cppp-platform --depth 1 + + - name: ๐Ÿ“ฆ Build source distribution run: | - tar cvf ${{ env.pkgname }}.tar ${{ env.pkgname }} - zip -r -9 dist/${{ env.pkgname }}.zip ${{ env.pkgname }} - 7z a dist/${{ env.pkgname }}.7z ${{ env.pkgname }} - xz -c -9 -k ${{ env.pkgname }}.tar > dist/${{ env.pkgname }}.tar.xz - gzip -c -9 -k ${{ env.pkgname }}.tar > dist/${{ env.pkgname }}.tar.gz + rubisco dist + # Rubisco will support it later. + - name: ๐Ÿ“ฆ Generate checksum + run: | cd dist - for i in $(ls) ; do md5sum $i > $i.md5 ; done + for i in $(ls) ; do sha256sum $i > $i.sha256 ; done cd .. - - #--------------------------------------------publish-------------------------------------------- - name: โฌ†๏ธ Create release and upload assets uses: softprops/action-gh-release@v1 with: - tag_name: ${{ env.tag }} + tag_name: ${{ steps.rubisco.outputs.tag }} files: ./dist/* build-linux: - - needs: build-dist strategy: fail-fast: false matrix: - arch: [ + host: [ aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabi, @@ -75,51 +57,44 @@ jobs: mips64-linux-gnuabi64, mips64el-linux-gnuabi64, mipsel-linux-gnu, - mipsisa32r6-linux-gnu, - mipsisa32r6el-linux-gnu, - mipsisa64r6-linux-gnuabi64, - mipsisa64r6el-linux-gnuabi64, powerpc-linux-gnu, powerpc64-linux-gnu, - powerpc64le-linux-gnu, riscv64-linux-gnu, sh4-linux-gnu, x86_64-linux-gnu ] - + runs-on: ubuntu-latest - + steps: - - #--------------------------------------------collect-------------------------------------------- - - name: ๐Ÿท๏ธ Get infomations - run: | - tag="${GITHUB_REF#refs/tags/}" - echo "tag=$tag" >> $GITHUB_ENV - echo "pkgname=cppp-reiconv-$tag" >> $GITHUB_ENV - echo "srcdir=$(pwd)" >> $GITHUB_ENV + - name: ๐Ÿ“ Checkout + uses: actions/checkout@v4 + - name: ๐Ÿงฐ Setup Rubisco + id: rubisco + uses: cppp-project/rubisco@main + with: + host: ${{ matrix.host }} + + # Rubisco don't support setup cross-compiler now. - name: ๐Ÿ“ Collect dependencies run: | sudo apt-get update - sudo apt-get install p7zip-full zip xz-utils wget -y - sudo apt-get install gperf cmake -y - if [ "${{ matrix.arch }}" = "x86_64-linux-gnu" ] ; + if [ "${{ matrix.host }}" = "x86_64-linux-gnu" ] ; then sudo apt-get install gcc g++ -y ; else - sudo apt-get install gcc-${{ matrix.arch }} g++-${{ matrix.arch }} -y ; + sudo apt-get install gcc-${{ matrix.host }} g++-${{ matrix.host }} -y ; fi - - - name: ๐Ÿ“ Get source distribution tarball + + - name: ๐Ÿ“ Collect subpackages run: | - wget https://github.com/${{ github.repository }}/releases/download/${{ env.tag }}/${{ env.pkgname }}.tar.gz - tar zxvf ${{ env.pkgname }}.tar.gz - mv ${{ env.pkgname }}/* . - - #--------------------------------------------build-------------------------------------------- - - name: ๐Ÿงณ Prepare for binary distribution building + git clone https://github.com/cppp-project/build-aux --depth 1 + git clone https://github.com/cppp-project/cppp-platform --depth 1 + + - name: ๐Ÿงณ Prepare for building run: | + mkdir -p ${{ steps.rubisco.outputs.pkgname }}-${{ matrix.host }} mkdir -p dist - name: ๐Ÿ› ๏ธ Build binary distribution @@ -127,184 +102,142 @@ jobs: export C_COMPILER="gcc" export CXX_COMPILER="g++" export LINKER="ld" - export CC_CROSS="/usr/bin/${{ matrix.arch }}-$C_COMPILER" - export CXX_CROSS="/usr/bin/${{ matrix.arch }}-$CXX_COMPILER" - export LD="/usr/bin/${{ matrix.arch }}-$LINKER" + export CC_CROSS="/usr/bin/${{ matrix.host }}-$C_COMPILER" + export CXX_CROSS="/usr/bin/${{ matrix.host }}-$CXX_COMPILER" + export LD="/usr/bin/${{ matrix.host }}-$LINKER" mkdir build cd build - cmake .. -DCMAKE_INSTALL_PREFIX=${{ env.srcdir }}/${{ env.pkgname }}-${{ matrix.arch }} -DCMAKE_C_COMPILER=$CC_CROSS -DCMAKE_CXX_COMPILER=$CXX_CROSS -DCMAKE_LINKER=$LD - cmake --build . --config=Release - cmake --install . + cmake .. -DBUILD_TESTING=OFF -DICONV_COMPAT=OFF -DCMAKE_INSTALL_PREFIX="${{ steps.rubisco.outputs.srcdir }}/${{ steps.rubisco.outputs.pkgname }}-${{ matrix.host }}" -DCMAKE_C_COMPILER=$CC_CROSS -DCMAKE_CXX_COMPILER=$CXX_CROSS -DCMAKE_LINKER=$LD + cmake --build . --config=Release -j $(nproc) + cmake --install . --config=Release cd .. - name: ๐Ÿ“ฆ Make packages run: | - tar cvf ${{ env.pkgname }}-${{ matrix.arch }}.tar ${{ env.pkgname }}-${{ matrix.arch }} - zip -r -9 dist/${{ env.pkgname }}-${{ matrix.arch }}.zip ${{ env.pkgname }}-${{ matrix.arch }} - 7z a dist/${{ env.pkgname }}-${{ matrix.arch }}.7z ${{ env.pkgname }}-${{ matrix.arch }} - xz -c -9 -k ${{ env.pkgname }}-${{ matrix.arch }}.tar > dist/${{ env.pkgname }}-${{ matrix.arch }}.tar.xz - gzip -c -9 -k ${{ env.pkgname }}-${{ matrix.arch }}.tar > dist/${{ env.pkgname }}-${{ matrix.arch }}.tar.gz + tar cvf dist/${{ steps.rubisco.outputs.pkgname }}-${{ matrix.host }}.tar ${{ steps.rubisco.outputs.pkgname }}-${{ matrix.host }} + xz -9 dist/${{ steps.rubisco.outputs.pkgname }}-${{ matrix.host }}.tar + - name: ๐Ÿ“ฆ Generate checksum + run: | cd dist - for i in $(ls) ; do md5sum $i > $i.md5 ; done + for i in $(ls) ; do sha256sum $i > $i.sha256 ; done cd .. - - #--------------------------------------------publish-------------------------------------------- - name: โฌ†๏ธ Create release and upload assets uses: softprops/action-gh-release@v1 with: - tag_name: ${{ env.tag }} + tag_name: ${{ steps.rubisco.outputs.tag }} files: ./dist/* - build-macos: - - needs: build-dist - - strategy: - fail-fast: false - matrix: - arch: [ - x86_64, - arm64 - ] + build-darwin: runs-on: macos-latest steps: - - #--------------------------------------------collect-------------------------------------------- - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable + - name: ๐Ÿ“ Checkout + uses: actions/checkout@v4 - - name: ๐Ÿท๏ธ Get infomations - run: | - tag="${GITHUB_REF#refs/tags/}" - echo "tag=$tag" >> $GITHUB_ENV - echo "pkgname=cppp-reiconv-$tag" >> $GITHUB_ENV - echo "srcdir=$(pwd)" >> $GITHUB_ENV + - name: ๐Ÿงฐ Setup Rubisco + id: rubisco + uses: cppp-project/rubisco@main + with: + host: arm64-apple-darwin - name: ๐Ÿ“ Collect dependencies run: | - brew install p7zip zip xz wget md5sha1sum - brew install gperf cmake - - - name: ๐Ÿ“ Get source distribution tarball + brew install coreutils + + - name: ๐Ÿ“ Collect subpackages run: | - wget https://github.com/${{ github.repository }}/releases/download/${{ env.tag }}/${{ env.pkgname }}.tar.gz - tar zxvf ${{ env.pkgname }}.tar.gz - mv ${{ env.pkgname }}/* . - - #--------------------------------------------build-------------------------------------------- - - name: ๐Ÿงณ Prepare for binary distribution building + git clone https://github.com/cppp-project/build-aux --depth 1 + git clone https://github.com/cppp-project/cppp-platform --depth 1 + + - name: ๐Ÿงณ Prepare for building run: | + mkdir -p ${{ steps.rubisco.outputs.pkgname }}-arm64-apple-darwin mkdir -p dist - + - name: ๐Ÿ› ๏ธ Build binary distribution run: | - export CC_CROSS="clang" - export CXX_CROSS="clang++" - mkdir build cd build - cmake .. -DCMAKE_INSTALL_PREFIX=${{ env.srcdir }}/${{ env.pkgname }}-${{ matrix.arch }}-darwin-apple -DCMAKE_C_COMPILER=$CC_CROSS -DCMAKE_CXX_COMPILER=$CXX_CROSS -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -arch ${{ matrix.arch }}" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -arch ${{ matrix.arch }}" - cmake --build . --config=Release - cmake --install . + cmake .. -DBUILD_TESTING=OFF -DICONV_COMPAT=OFF -DCMAKE_INSTALL_PREFIX="${{ steps.rubisco.outputs.srcdir }}/${{ steps.rubisco.outputs.pkgname }}-arm64-apple-darwin" + cmake --build . --config=Release -j $(nproc) + cmake --install . --config=Release cd .. - + - name: ๐Ÿ“ฆ Make packages run: | - tar cvf ${{ env.pkgname }}-${{ matrix.arch }}-darwin-apple.tar ${{ env.pkgname }}-${{ matrix.arch }}-darwin-apple - zip -r -9 dist/${{ env.pkgname }}-${{ matrix.arch }}-darwin-apple.zip ${{ env.pkgname }}-${{ matrix.arch }}-darwin-apple - 7z a dist/${{ env.pkgname }}-${{ matrix.arch }}-darwin-apple.7z ${{ env.pkgname }}-${{ matrix.arch }}-darwin-apple - xz -c -9 -k ${{ env.pkgname }}-${{ matrix.arch }}-darwin-apple.tar > dist/${{ env.pkgname }}-${{ matrix.arch }}-darwin-apple.tar.xz - gzip -c -9 -k ${{ env.pkgname }}-${{ matrix.arch }}-darwin-apple.tar > dist/${{ env.pkgname }}-${{ matrix.arch }}-darwin-apple.tar.gz + tar cvf dist/${{ steps.rubisco.outputs.pkgname }}-arm64-apple-darwin.tar ${{ steps.rubisco.outputs.pkgname }}-arm64-apple-darwin + xz -9 dist/${{ steps.rubisco.outputs.pkgname }}-arm64-apple-darwin.tar + - name: ๐Ÿ“ฆ Generate checksum + run: | cd dist - for i in $(ls) ; do md5sum $i > $i.md5 ; done - cd .. - #--------------------------------------------publish-------------------------------------------- + for i in $(ls) ; do sha256sum $i > $i.sha256 ; done + cd .. - name: โฌ†๏ธ Create release and upload assets uses: softprops/action-gh-release@v1 with: - tag_name: ${{ env.tag }} + tag_name: ${{ steps.rubisco.outputs.tag }} files: ./dist/* - build-msvc: - - needs: build-dist - - strategy: - fail-fast: false - matrix: - include: - - { arch: amd64, msvc_arch: x64 } - - { arch: i386, msvc_arch: Win32 } - - { arch: arm64, msvc_arch: ARM64 } - - { arch: arm, msvc_arch: ARM } - - runs-on: windows-latest - - steps: - - #--------------------------------------------collect-------------------------------------------- - - name: ๐Ÿงณ Set up MSVC - uses: microsoft/setup-msbuild@v1 - - - name: ๐Ÿท๏ธ Get infomations - run: | - $tag="$env:GITHUB_REF_NAME" - echo "tag=$tag" >> $env:GITHUB_ENV - echo "pkgname=cppp-reiconv-$tag" >> $env:GITHUB_ENV - echo "srcdir=$($PWD.Path)" >> $env:GITHUB_ENV - - - name: ๐Ÿ“ Collect dependencies - run: | - choco install 7zip.commandline zip gzip dos2unix wget mingw -y - - - name: ๐Ÿ“ Get source distribution tarball - run: | - wget https://github.com/${{ github.repository }}/releases/download/${{ env.tag }}/${{ env.pkgname }}.tar.gz - tar zxvf ${{ env.pkgname }}.tar.gz - Move-Item -Path ${{ env.pkgname }}\* -Destination . - - - name: ๐Ÿงณ Prepare for binary distribution building - run: | - mkdir dist - - - name: ๐Ÿ› ๏ธ Build binary distribution - run: | - mkdir build - cd build - cmake .. -DCMAKE_INSTALL_PREFIX=${{ env.srcdir }}/${{ env.pkgname }}-${{ matrix.arch }}-windows-msvc -A ${{ matrix.msvc_arch }} - cmake --build . --config=Release - cmake --install . - cd .. - - - name: ๐Ÿ“ฆ Make packages - run: | - tar cvf ${{ env.pkgname }}-${{ matrix.arch }}-windows-msvc.tar ${{ env.pkgname }}-${{ matrix.arch }}-windows-msvc - zip -r -9 dist/${{ env.pkgname }}-${{ matrix.arch }}-windows-msvc.zip ${{ env.pkgname }}-${{ matrix.arch }}-windows-msvc - 7z a dist/${{ env.pkgname }}-${{ matrix.arch }}-windows-msvc.7z ${{ env.pkgname }}-${{ matrix.arch }}-windows-msvc - xz -9 -k ${{ env.pkgname }}-${{ matrix.arch }}-windows-msvc.tar - gzip -9 -k ${{ env.pkgname }}-${{ matrix.arch }}-windows-msvc.tar - mv ${{ env.pkgname }}-${{ matrix.arch }}-windows-msvc.tar.xz dist - mv ${{ env.pkgname }}-${{ matrix.arch }}-windows-msvc.tar.gz dist - - cd dist - Get-ChildItem | ForEach-Object { - md5sum $_.Name > ($_.Name + ".md5") - dos2unix ($_.Name + ".md5") - } - cd .. - - #--------------------------------------------publish-------------------------------------------- - - - name: โฌ†๏ธ Create release and upload assets - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ env.tag }} - files: ./dist/* + # Rubisco cannot been install due to encoding problems on Windows. + # build-windows: + + # runs-on: windows-latest + + # steps: + # - name: ๐Ÿ“ Checkout + # uses: actions/checkout@v4 + + # - name: ๐Ÿงฐ Setup Rubisco + # id: rubisco + # uses: cppp-project/rubisco@main + # with: + # host: x86_64-windows-msvc + + # - name: ๐Ÿ“ Collect dependencies + # run: | + # choco install zip dos2unix mingw -y + + # - name: ๐Ÿ“ Collect subpackages + # run: | + # git clone https://github.com/cppp-project/build-aux --depth 1 + # git clone https://github.com/cppp-project/cppp-platform --depth 1 + + # - name: ๐Ÿงณ Prepare for building + # run: | + # mkdir -p ${{ steps.rubisco.outputs.pkgname }}-x86_64-windows-msvc + # mkdir -p dist + + # - name: ๐Ÿ› ๏ธ Build binary distribution + # run: | + # mkdir build + # cd build + # cmake .. -DBUILD_TESTING=OFF -DICONV_COMPAT=ON -DCMAKE_INSTALL_PREFIX="${{ steps.rubisco.outputs.srcdir }}/${{ steps.rubisco.outputs.pkgname }}-x86_64-windows-msvc" + # cmake --build . --config=Release -j $(nproc) + # cmake --install . --config=Release + # cd .. + + # - name: ๐Ÿ“ฆ Make packages + # run: | + # tar cvf dist/${{ steps.rubisco.outputs.pkgname }}-x86_64-windows-msvc.tar ${{ steps.rubisco.outputs.pkgname }}-x86_64-windows-msvc + # xz -9 dist/${{ steps.rubisco.outputs.pkgname }}-x86_64-windows-msvc.tar + + # - name: ๐Ÿ“ฆ Generate checksum + # run: | + # cd dist + # Get-ChildItem | ForEach-Object { + # sha256sum $_.Name > ($_.Name + ".sha256") + # dos2unix ($_.Name + ".sha256") + # } + # cd .. + + # - name: โฌ†๏ธ Create release and upload assets + # uses: softprops/action-gh-release@v1 + # with: + # tag_name: ${{ steps.rubisco.outputs.tag }} + # files: ./dist/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b937fe55..6fb6bcf2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,77 +1,38 @@ -name: โœ”๏ธ Test cppp-reiconv library +name: โœ”๏ธ Test cppp-reiconv on: release: types: [published] push: branches: [ "main" ] - workflow_dispatch: + pull_request: + branches: [ "main" ] jobs: - test-linux: + build: + runs-on: ${{ matrix.os }} - runs-on: ubuntu-latest + strategy: + fail-fast: false - steps: - #--------------------------------------------collect-------------------------------------------- - - uses: actions/checkout@v3 + matrix: + include: + - { os: macos-latest, host: aarch64-apple-darwin } + - { os: ubuntu-latest, host: x86_64-linux-gnu } - - name: ๐Ÿงฐ Setup Python - uses: actions/setup-python@v4 - - - name: ๐Ÿ“ Collect dependencies - run: | - sudo apt-get update - sudo apt-get install gcc cmake -y - - - name: ๐Ÿงฐ Setup build-aux - run: | - ./setup.sh - - #--------------------------------------------build-------------------------------------------- - - name: ๐Ÿ› ๏ธ Build - run : | - mkdir -p build - cd build - cmake .. -DENABLE_EXTRA=ON -DENABLE_TEST=ON - cmake --build . --config=Release - cd .. - - #--------------------------------------------test-------------------------------------------- - - name: โœ”๏ธ Test - run : | - cd build - ctest --verbose -C Release - cd .. - - test-macos: + steps: + - name: ๐Ÿ“ Checkout + uses: actions/checkout@v4 - runs-on: macos-latest + - name: ๐Ÿงฐ Setup Rubisco + uses: cppp-project/rubisco@main + with: + host: ${{ matrix.host }} - steps: - #--------------------------------------------collect-------------------------------------------- - - uses: actions/checkout@v3 - - - name: ๐Ÿ“ Collect dependencies + - name: ๐Ÿ“ Setup subpackages run: | - brew install cmake - - - name: ๐Ÿงฐ Setup build-aux - run : | - ./setup.sh - - #--------------------------------------------build-------------------------------------------- - - name: ๐Ÿ› ๏ธ Build - run : | - mkdir build - cd build - cmake .. -DENABLE_EXTRA=ON -DENABLE_TEST=ON - cmake --build . --config=Release - cd .. - - #--------------------------------------------test-------------------------------------------- - - name: โœ”๏ธ Test - run : | - cd build - ctest --verbose -C Release - cd .. + git clone https://github.com/cppp-project/build-aux --depth 1 + git clone https://github.com/cppp-project/cppp-platform --depth 1 + + - name: ๐Ÿงช Test + run: rubisco test diff --git a/.gitignore b/.gitignore index db96c706..5ab9e39b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,64 +1,74 @@ # CMake build files -build/ +build +install CMakeFiles -*.so -*.so.*.*.* -*.a -*.dylib -*.stackdump -*.lib -*.pdb -*.dll -*.exe cmake_install.cmake CMakeCache.txt CTestTestfile.cmake DartConfiguration.tcl Makefile -uninstall.cmake +cmake_uninstall.cmake reiconv.hpp CTestCostData.txt -*.inst Testing +install_manifest.txt +CPackConfig.cmake +CPackSourceConfig.cmake +_CPack_Packages +pdb +tests/check-encoding +tests/check-stateful +tests/check-stateless +tests/data-generator +tests/sort +tests/test-bom-state +tests/test-discard +windows/cppp-reiconv.rc +*.inst *.log *.dSYM +*.so +*.so.*.*.* +*.a +*.dylib +*.stackdump +*.lib +*.pdb +*.dll +*.exe +*.sln +*.out +*.vcxproj +*.vcxproj.filters +*.vcxproj.user +*.vcxproj.user.* +build.ninja +.ninja_* +Release/ +Debug/ +RelWithDebInfo/ +MinSizeRel/ +x64/ +x86/ +ARM/ +ARM64/ +*.suo +*.user +*.user.* +*.dir +__pycache__ + +# Dist files +dist/ +cppp-reiconv-* +*.tar.xz +*.deb # Makefile.devel temp files lib/generated/genaliases -lib/generated/genaliases_sysaix -lib/generated/genaliases_syshpux -lib/generated/genaliases_sysosf1 -lib/generated/genaliases_syssolaris -lib/generated/genaliases2_aix -lib/generated/genaliases2_aix_sysaix -lib/generated/genaliases2_dos -lib/generated/genaliases2_extra -lib/generated/genaliases2_osf1 -lib/generated/genaliases2_osf1_sysosf1 -lib/generated/genaliases2_zos -lib/generated/genflags -/*/**/*.gperf - - -# Test suite runable -tests/cmp -tests/cmp.exe -tests/gengb18030z -tests/gengb18030z.exe -tests/genutf8 -tests/genutf8.exe -tests/reiconv-test -tests/reiconv-test.exe -tests/table-from -tests/table-from.exe -tests/table-to -tests/table-to.exe -tests/test-shiftseq -tests/test-shiftseq.exe -tests/uniq-u -tests/uniq-u.exe -tests/tmp-*.TXT -a.out +lib/generated/genindexes +lib/generated/check-encodings +*.gperf # Patterns for all subdirectories: all kinds of automatic backup files. *.orig @@ -68,18 +78,18 @@ a.out *.swp .#* \#*# -.vscode -.cache +.vscode/ +.cache/ -# Autopull modules +# Submodules. build-aux/ +cppp-platform/ # Temp tests files. tests/data/UTF-8.TXT tests/data/GB18030-2005.TXT tests/data/GB18030-2022.TXT +tests/tmp-*.TXT *.tmp - -# Dist directory and temps -cppp-reiconv-v* -__pycache__ +*.dump +benchmark/benchmark diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 00000000..e0f2ca05 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,11 @@ +{ + "MD013": { + "code_blocks": false + }, + "MD024": { + "siblings_only": true + }, + "MD033": { + "allowed_elements": ["img"] + } +} diff --git a/.rubisco/build.yml b/.rubisco/build.yml new file mode 100644 index 00000000..6a9a5325 --- /dev/null +++ b/.rubisco/build.yml @@ -0,0 +1,19 @@ +name: ๐Ÿ› ๏ธ Build ${{ project.name }} + +steps: + - name: ๐Ÿ“ฆ Make binary distribution directory + mkdir: ${{ project.name }}-${{ project.version }}-bin + + - name: ๐Ÿ› ๏ธ Configure and build + run: | + cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX="${{ project.name }}-${{ project.version }}-bin" + cmake --build build --config Release -v -j ${{ nproc }} + + - name: ๐Ÿ“ฆ Install to temp install path + run: | + cmake --install build --config Release --prefix "${{ project.name }}-${{ project.version }}-bin" + + - name: ๐Ÿ“ฆ Packing the binary distribution + compress: ${{ project.name }}-${{ project.version }}-bin + to: dist/${{ project.name }}-${{ project.version }} + format: [zip, tar.xz] diff --git a/.rubisco/dist.yml b/.rubisco/dist.yml new file mode 100644 index 00000000..252da1ec --- /dev/null +++ b/.rubisco/dist.yml @@ -0,0 +1,99 @@ +name: ๐Ÿ“ Make ${{ project.name }} distribution package + +vars: + - ignores: + [ + ".git", + ".venv", + ".github", + "build", + "install", + "dist", + "CMakeFiles", + "cmake_install.cmake", + "CMakeCache.txt", + "CTestTestfile.cmake", + "DartConfiguration.tcl", + "Makefile", + "cmake_uninstall.cmake", + "reiconv.hpp", + "CTestCostData.txt", + "Testing", + "install_manifest.txt", + "CPackConfig.cmake", + "CPackSourceConfig.cmake", + "_CPack_Packages", + "tests/check-ascii-converters", + "tests/check-stateful", + "tests/check-stateless", + "tests/data-generator", + "tests/sort", + "windows/cppp-reiconv.rc", + "pdb", + "*.inst", + "*.log", + "*.dSYM", + "*.so", + "*.so.*.*.*", + "*.a", + "*.dylib", + "*.stackdump", + "*.lib", + "*.pdb", + "*.dll", + "*.exe", + "*.sln", + "*.vcxproj", + "*.vcxproj.filters", + "*.vcxproj.user", + "*.vcxproj.user.*", + "build.ninja", + ".ninja_*", + "Release", + "Debug", + "RelWithDebInfo", + "MinSizeRel", + "x64", + "x86", + "ARM", + "ARM64", + "*.suo", + "*.user", + "*.user.*", + "*.dir", + "__pycache__", + "dist", + "cppp-reiconv-*", + "*.tar.xz", + "*.deb", + "lib/generated/genaliases", + "*.gperf", + "*.orig", + "*.rej", + "*~", + "*.kate-swp", + "*.swp", + ".vscode", + ".cache", + "build-aux/", + "tests/data/UTF-8.TXT", + "tests/data/GB18030-2005.TXT", + "tests/data/GB18030-2022.TXT", + "tests/tmp-*.TXT", + "*.tmp", + ] + +steps: + - name: ๐Ÿ“ฆ Make source distribution directory + mkdir: ${{ project.name }}-${{ project.version }} + - mkdir: dist + + - name: ๐Ÿ“ฆ Copy files to source distribution directory + copy: ${{ cwd }} + to: ${{ project.name }}-${{ project.version }} + excludes: ${{ ignores }} + + - name: ๐Ÿ“ฆ Packing the source distribution + compress: ${{ project.name }}-${{ project.version }} + to: dist/${{ project.name }}-${{ project.version }} + format: [zip, tar.xz] diff --git a/.rubisco/test.yml b/.rubisco/test.yml new file mode 100644 index 00000000..a2785c7a --- /dev/null +++ b/.rubisco/test.yml @@ -0,0 +1,13 @@ +name: ๐Ÿงช Run tests for ${{ project.name }} + +steps: + - name: ๐Ÿ› ๏ธ Configure and build + run: | + cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON + cmake --build build --config Release -v -j ${{ nproc }} + + - name: ๐Ÿงช Run tests + run: | + cd build + ctest --output-on-failure -C Release + cd .. diff --git a/CMakeLists.txt b/CMakeLists.txt index 79d3deed..1a35a9f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2023 The C++ Plus Project. +# Copyright (C) 2023-2024 The C++ Plus Project. # This file is part of the cppp-reiconv library. # # The cppp-reiconv library is free software; you can redistribute it @@ -12,104 +12,150 @@ # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public -# License along with the cppp-reiconv library; see the file COPYING. +# License along with the cppp-reiconv library; see the file LICENSE. # If not, see . cmake_minimum_required(VERSION 3.12) -project(cppp-reiconv VERSION 2.1.0) +project(cppp-reiconv + VERSION 3.0.0 + DESCRIPTION "A character set conversion library based on GNU LIBICONV." + HOMEPAGE_URL "https://github.com/cppp-project/cppp-reiconv") -# Define options -option(ENABLE_EXTRA "Enable extra encodings and features." OFF) - -# Set C++ standard -set(CMAKE_CXX_STANDARD 17) +option(BUILD_TESTING "Test suites for '${PROJECT_NAME}' enabled." ON) +option(ICONV_COMPAT "Enable compatibility with iconv." OFF) # ---------------------------------------------------------------------------------- -# Import build-aux subdirectory. +# Import build auxiliaries. if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/build-aux") set(BUILD_AUX "${CMAKE_CURRENT_SOURCE_DIR}/build-aux") add_subdirectory("${BUILD_AUX}") - message(STATUS "Using '${BUILD_AUX}' for C++ Plus build-aux directory.") + message(STATUS "Using '${BUILD_AUX}' for C+++ build-aux directory.") elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../build-aux") set(BUILD_AUX "${CMAKE_CURRENT_SOURCE_DIR}/../build-aux") else() - message(FATAL_ERROR "CMake build-aux directory is not exists, try to execute 'setup.cmd' or './setup.sh' to get it.") + message(FATAL_ERROR "C+++ build-aux directory is not exists.") endif() get_filename_component(BUILD_AUX "${BUILD_AUX}" ABSOLUTE) include("${BUILD_AUX}/cmake/cppp.cmake") - -cppp_init_nls_util() - # ---------------------------------------------------------------------------------- -check_have_visibility() -if(MSVC) +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/cppp-platform") + +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + add_compile_options(-Wno-unused-parameter) + add_compile_options(-Wno-missing-field-initializers) + add_compile_options(-Wno-implicit-fallthrough) + add_compile_options(-Wno-unused-function) + add_compile_options(-Wno-sign-compare) + add_compile_options(-Wno-type-limits) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(-Wno-unused-parameter) + add_compile_options(-Wno-missing-field-initializers) + add_compile_options(-Wno-implicit-fallthrough) + add_compile_options(-Wno-unused-function) + add_compile_options(-Wno-sign-compare) + add_compile_options(-Wno-type-limits) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_options(/wd4996) + add_compile_options(/wd4267) + add_compile_options(/wd4244) add_compile_options(/wd4018) endif() -# Generate header file for build -if(WIN32) - set(DLL_VARIABLE "__declspec(dllexport)") -elseif(HAVE_VISIBILITY) - set(DLL_VARIABLE "__attribute__((__visibility__(\"default\")))") -else() - set(DLL_VARIABLE "") -endif() +# Header for install. +# cppp/reiconv.hpp +set(CPPP_API "${CPPP_IMPORT_API}") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/cppp/reiconv.hpp.in" "${output_includedir}/cppp/reiconv.hpp.inst") + +# cppp/reiconv.h +set(CPPP_API "${CPPP_IMPORT_API}") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/cppp/reiconv.h.in" "${output_includedir}/cppp/reiconv.h.inst") + +# Header for build. +# cppp/reiconv.hpp +set(CPPP_API "${CPPP_EXPORT_API}") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/cppp/reiconv.hpp.in" "${output_includedir}/cppp/reiconv.hpp") -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/windows/libcppp-reiconv.rc.in" "${CMAKE_BINARY_DIR}/windows/libcppp-reiconv.rc") -# Generate header file for install -if(WIN32) - set(DLL_VARIABLE "__declspec(dllimport)") -else() - set(DLL_VARIABLE "") -endif() -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/cppp/reiconv.hpp.in" "${output_includedir}/cppp/reiconv.hpp.inst") -cppp_nls_autotranslate("${output_includedir}/cppp/reiconv.hpp.inst" "${CMAKE_CURRENT_SOURCE_DIR}/lang") +# cppp/reiconv.h +set(CPPP_API "${CPPP_EXPORT_API}") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/cppp/reiconv.h.in" "${output_includedir}/cppp/reiconv.h") + +# cppp-reiconv.rc +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/windows/cppp-reiconv.rc.in" "${CMAKE_BINARY_DIR}/windows/cppp-reiconv.rc") + +# cppp/encodings/reiconv.hpp +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/lib/generated/indexes.hpp.shippet" _INDEXES_CODE) +string(STRIP "${_INDEXES_CODE}" INDEXES_CODE) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/cppp/encodings/reiconv.hpp.in" "${output_includedir}/cppp/encodings/reiconv.hpp") + +# cppp/encodings/reiconv.h +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/lib/generated/indexes.h.shippet" _INDEXES_CODE) +string(STRIP "${_INDEXES_CODE}" INDEXES_CODE) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/cppp/encodings/reiconv.h.in" "${output_includedir}/cppp/encodings/reiconv.h") -# Add includes +# iconv.h +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/iconv.h.in" "${output_includedir}/iconv.h") + +# Add includes. include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib") -include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib/generated") include_directories("${output_includedir}") -# Add definitions -if(ENABLE_EXTRA) - message(STATUS "Extra encodings and features enabled.") - add_compile_definitions(ENABLE_EXTRA=1) +# Add definitions. +add_compile_definitions(VERSION_MAJOR=${PROJECT_VERSION_MAJOR}) +add_compile_definitions(VERSION_MINOR=${PROJECT_VERSION_MINOR}) +add_compile_definitions(VERSION_PATCH=${PROJECT_VERSION_PATCH}) + +include(CheckFunctionExists) +check_function_exists(nl_langinfo HAVE_LANGINFO_CODESET) +if(HAVE_LANGINFO_CODESET) + add_compile_definitions(HAVE_LANGINFO_CODESET=1) endif() -# Add library -cppp_build_library(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/lib/iconv.cpp" TRUE TRUE "${CMAKE_BINARY_DIR}/windows/libcppp-reiconv.rc") +# Add library. +set(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/lib/iconv.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/reiconv.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/locale_charset.c" + "${CMAKE_CURRENT_SOURCE_DIR}/lib/locale_charset.cpp") +cppp_build_library(${PROJECT_NAME} SOURCES TRUE TRUE "${CMAKE_BINARY_DIR}/windows/cppp-reiconv.rc") # Include test suite. -include("tests/tests.cmake") +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests" AND BUILD_TESTING) + include("${CMAKE_CURRENT_SOURCE_DIR}/tests/tests.cmake") +endif() -# Install -# Static -# PERMISSIONS 0644 -install(TARGETS libcppp-reiconv.static - DESTINATION "${install_staticdir}" - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - LIBRARY DESTINATION "${install_shareddir}" - ARCHIVE DESTINATION "${install_staticdir}" - RUNTIME DESTINATION "${install_bindir}" - INCLUDES DESTINATION "${install_includedir}" ) - -# Shared -# PERMISSIONS 0755 -install(TARGETS libcppp-reiconv.shared - EXPORT libcppp-reiconv-export - DESTINATION "${install_shareddir}" - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - LIBRARY DESTINATION "${install_shareddir}" - ARCHIVE DESTINATION "${install_staticdir}" - RUNTIME DESTINATION "${install_bindir}" - INCLUDES DESTINATION "${install_includedir}" ) - -# Includes -# install includes +# Install libraries. +cppp_install_library(${PROJECT_NAME}) + +# Install headers. # PERMISSIONS 0644 install(FILES "${output_includedir}/cppp/reiconv.hpp.inst" DESTINATION "${install_includedir}" RENAME "cppp/reiconv.hpp" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) + +# PERMISSIONS 0644 +install(FILES "${output_includedir}/cppp/encodings/reiconv.hpp" + DESTINATION "${install_includedir}" + RENAME "cppp/encodings/reiconv.hpp" + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) + +# PERMISSIONS 0644 +install(FILES "${output_includedir}/cppp/reiconv.h.inst" + DESTINATION "${install_includedir}" + RENAME "cppp/reiconv.h" + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) + +# PERMISSIONS 0644 +install(FILES "${output_includedir}/cppp/encodings/reiconv.h" + DESTINATION "${install_includedir}" + RENAME "cppp/encodings/reiconv.h" + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) + +# PERMISSIONS 0644 +if(ICONV_COMPAT) + install(FILES "${output_includedir}/iconv.h" + DESTINATION "${install_includedir}" + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) +endif() + +include("${CMAKE_CURRENT_SOURCE_DIR}/cpack.cmake") diff --git a/CPPPPKG b/CPPPPKG deleted file mode 100644 index 2e64cca9..00000000 --- a/CPPPPKG +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name" : "cppp-reiconv", - "version" : "2.1.0", - "list_file_path": "FILELIST", - "description": "C++ Plus character set conversion library", - "authors": [ - "The C++ Plus Project", - "Bruno Haible", - "ChenPi11" - ], - "webpage": "https://github.com/cppp-project/cppp-reiconv", - "subpackages": { - "build-aux": { "path": "build-aux", "ignore": true } - }, - "license": [ - "LGPLv3" - ] -} diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index e32ba067..00000000 --- a/ChangeLog +++ /dev/null @@ -1,6208 +0,0 @@ -2023-10-03 ChenPi11 - - Update C++ standard of the project. - Remove unused canonical files and codes. - Move 'lib/gen*.c' to 'tools/gen*.cpp'. - Optimize 'Makefile.devel'. - Move generated files to C++ to avoid 'register' warnings. - Add test and clean target in 'Makefile.devel'. - Update 'FILELIST'. - Update GitHub Action for build and test. - Prepare for release version 2.1.0. - -2023-09-09 ChenPi11 - - Version 2.1.0 compile failed (release failed). - Update doccomments in reiconv.hpp.in. - Add function 'int iconv_string(const iconv_t& cd, const char *start, const char *end, char **resultp, size_t *lengthp)' - Add function 'int iconv_string(int tocode_cp, int fromcode_cp, const char* start, const char* end, char** resultp, size_t* lengthp, bool strict=true)' - Update function 'encode' definion. - Fix some warnings in Clang. - Change the 'autodetect' feature of 'iconv_string' to a non extra feature. - Update language maps. - Fix compile error in MinGW GNU GCC. - -2023-09-02 ChenPi11 - - Optimize 'iconv_open(int, int)'. - Change version to '2.1.0'. - Update NEWS.md. - Remove some authors because they are only contributors. - Prepare for release version 2.1.0. - -2023-08-29 ChenPi11 - - Fix type-conflict warning when in clang. - Fully remove wchar support. - Add function 'extern iconv_t iconv_open (int tocode_cp, int fromcode_cp, bool strict=true)'. - Update language map. - -2023-08-27 ChenPi11 - - Add codepage definitions. - -2023-08-24 ChenPi11 - - Fix subdirectory import bug. - Optimize the way to import build-aux. - -2023-08-23 ChenPi11 - - Add CTest on Windows support. - -2023-07-28 ChenPi11 - - Finish NLS Translate language maps (en_US, zh_CN). - Add Doxygen notes for 'cppp/reiconv.hpp'. - Fix 'reiconv_version' bug (changed it to 2.0). - Remove 'iconv_allocation_t'; - -2023-07-19 ChenPi11 - - Fix encode()'s EILSEQ bug. - -2023-07-17 ChenPi11 - - Add social preview in README.md. - -2023-07-16 ChenPi11 - - Finish GitHub build CI for Windows. - Fix encoding bug in Windows Resource '(C)' character. - Fix shared library runtime and archive install destination problem. - -2023-07-15 ChenPi11 - - Fix macro bug in MSVC resource build. - Add GitHub build CI for Linux and macOS. - -2023-07-12 ChenPi11 - - Change `int` to 'unsigned short' in canonical headers. - Finish GitHub CI test for Linux and macOS. - -2023-07-10 ChenPi11 - - Update build-aux setup scripts. - Fix GitHub test CI's bug. - -2023-07-08 ChenPi11 - - Add GitHub test CI. - -2023-07-07 ChenPi11 - - Perfect the documents. - -2023-07-03 ChenPi11 - - Add 'GB18030' tests. - Add C++ Plus dist utils and change version info. - Remove function 'iconv_open_into'. - -2023-07-02 ChenPi11 - - Add C++ Plus dist utils. - -2023-07-01 ChenPi11 - - Remove src, srclib, gnulib, po, man, tools. - Remove unused things. - Change 'COPYING.LIB' to 'COPYING'. - Redist 'GNU LIBICONV' to 'cppp-reiconv'. - Remove 'CHAR' and 'WCHAR_T' encoding. - Remove libcharset. - Preparing to transition to C++. - Remove autoconf buildsystem support. - Add CMake support. - Move generated file into 'lib/generated'. - Move cppp-reiconv to a C++ library. - Remove translit support. - Remove 'LIBICONV_PLUG'. - -2023-06-29 Bruno Haible - - Update the installation instructions for Windows. - * INSTALL.windows: Add a note about MSYS2. - -2023-05-29 Bruno Haible - - GB18030: Help transitioning away from PUA code points. - * lib/gb18030ext.h (gb18030_2005_ext_wctomb): Remove function. - (gb18030ext_wctomb): Renamed from gb18030_2022_ext_wctomb. - * lib/gb18030uni.h (gb18030_2005_uni_wctomb): Map 6 Ext-B code points to - 4-bytes sequences. - (gb18030_2022_uni_wctomb): Small refactoring. - * lib/gb18030_2005.h (gb18030_2005_pua2charset): Map 6 PUA code points - to 4-bytes sequences instead of 2-bytes sequences. - (gb18030_2005_wctomb): Update accordingly. Invoke gb18030ext_wctomb - instead of gb18030_2005_ext_wctomb. - * lib/gb18030_2022.h (gb18030_2022_wctomb): Invoke gb18030ext_wctomb - instead of gb18030_2022_ext_wctomb. - * tests/GB18030-2005.IRREVERSIBLE.TXT: Update the inverse mappings of 6 - Ext-B code points and 6 PUA code points. - * NEWS: Mention it. - -2023-05-24 Bruno Haible - - man pages: List a fifth condition when iconv(3) may stop. - Based on the patch to the man-pages project - = - - * man/iconv.3: List a fifth condition. - -2023-05-24 Bruno Haible - - man pages: Use man page section title from groff or the distro. - Reported by Mike Fulton in - . - * man/*.[13]: Remove section title "Linux Programmer's Manual". - -2023-05-21 Bruno Haible - - Support creating shared libraries on Hurd/x86_64. - Patch from - . - * m4/libtool.m4 (_LT_ENABLE_LOCK): Treat Hurd/x86_64 like - Linux/x86_64. - -2023-05-21 Bruno Haible - - Fix link error regarding _libiconv_version on MSVC in C++ mode. - Reported at . - * include/iconv.h.in (_libiconv_version): Enclose in an extern "C" - block. - -2023-05-20 Bruno Haible - - Implement GB18030 version 2022. - * lib/encodings.def (GB18030): Add alias GB18030:2005. - (GB18030:2022): New encoding. - * lib/gb18030ext.h (gb18030_2005_ext_2uni_pagefe): Renamed from - gb18030ext_2uni_pagefe. - (gb18030_2022_ext_2uni_pagefe): New array. - (gb18030_2005_ext_mbtowc): Renamed from gb18030ext_mbtowc. - (gb18030_2022_ext_mbtowc): New function. - (gb18030_2005_ext_wctomb): Renamed from gb18030ext_wctomb. - (gb18030_2022_ext_wctomb): New function. - * lib/gb18030uni.h (gb18030_2022_charset2uni_pua1, - gb18030_2022_charset2uni_pua2): New arrays. - (gb18030_2005_uni_mbtowc): Renamed from gb18030uni_mbtowc. - (gb18030_2022_uni_mbtowc): New function. - (gb18030_2022_uni2charset_pua1, gb18030_2022_uni2charset_pua2): New - arrays. - (gb18030_2005_uni_wctomb): Renamed from gb18030uni_wctomb. - (gb18030_2022_uni_wctomb): New function. - * lib/gb18030_2005.h: Renamed from lib/gb18030.h. Update comments. - (gb18030_2005_mbtowc): Renamed from gb18030_mbtowc. - (gb18030_2005_pua2charset): Renamed from gb18030_pua2charset. - (gb18030_2005_wctomb): Renamed from gb18030_wctomb. - * lib/gb18030_2022.h: New file, based on lib/gb18030_2005.h. - * lib/converters.h: Don't include gb18030.h. Include gb18030_2005.h, - gb18030_2022.h. - * lib/Makefile.in (SOURCE_FILES): Remove gb18030.h. Add gb18030_2005.h, - gb18030_2022.h. - * tests/GB18030-2005-BMP.TXT: Renamed from tests/GB18030-BMP.TXT. - * tests/GB18030-2005.IRREVERSIBLE.TXT: Renamed from - tests/GB18030.IRREVERSIBLE.TXT. - * tests/GB18030-2022-BMP.TXT: New file. - * tests/Makefile.in (check): Test GB18030:2005 instead of GB18030. Also - test GB18030:2022. - (clean): Don't remove GB18030.TXT. Instead, remove GB18030-2005.TXT and - GB18030-2022.TXT. - (SOURCE_FILES): Update. Add GB18030-2022-BMP.TXT. - * README: Mention the new encoding. - * man/iconv_open.3: Likewise. - * NEWS: Likewise. - -2023-05-19 Bruno Haible - - Make the compiler used by Makefile.devel customizable. - Reported by Mike Fulton in - . - * Makefile.devel: Require GNU make. - (CC): Use value from the environment, if set and non-empty. - (CFLAGS): Use value from the environment, if set. - * autogen.sh (GMAKE): New variable. - Use it for executing Makefile.devel. - -2023-05-17 Bruno Haible - - On z/OS, allow charset tagging of temporary shell scripts. - Reported by Mike Fulton in - . - * lib/genaliases.c (BINARY_MODE): New macro. - (main): Use it instead of "b". - -2023-05-12 Bruno Haible - - Integrate the last change. - * src/Makefile.in (SOURCE_FILES): Add zos-tag.h. - * tests/Makefile.in (SOURCE_FILES): Add check-tag. - * NEWS: Mention the new functionality. - -2023-05-12 Mike Fulton - - On z/OS, set a charset tag on iconv's output file. - For the concept of charset tags as external metadata on z/OS files, see - . - * src/zos-tag.h: New file. - * src/iconv.c: Include zos-tag.h. - (convert): Add a 'tocode' parameter. On z/OS, turn off auto-conversion - and tag the output file. - (main): Update callers. - * tests/check-ebcdic: On z/OS, make all test files initially untagged. - * tests/check-tag: New file. - * tests/Makefile.in (check): Pass the host_os to check-ebcdic. Invoke - check-tag. - -2023-04-03 Bruno Haible - - Fix genflags compilation error. - * lib/genflags.c (ICONV_SURFACE_EBCDIC_ZOS_UNIX): New macro, copied from - include/iconv.h.in. - - Allow overriding the newline conversion for EBCDIC encodings. - Reported by Mike Fulton in - . - * include/iconv.h.in (ICONV_SURFACE_NONE, - ICONV_SURFACE_EBCDIC_ZOS_UNIX): New macros. - (ICONV_GET_FROM_SURFACE, ICONV_SET_FROM_SURFACE, ICONV_GET_TO_SURFACE, - ICONV_SET_TO_SURFACE): New macros. - * lib/converters.h (struct conv_struct): Add the fields isurface, - osurface. - (swap_x15_x25): New macro. - * lib/iconv.c (iconv_open, iconv_open_into): Add local variables - from_surface, to_surface. - (ALL_SURFACES): New macro. - (iconvctl): Adjust ICONV_TRIVIALP implementation. Implement the - ICONV_{GET,SET}_{FROM,TO}_SURFACE requests. - * lib/iconv_open1.h: Parse a /ZOS_UNIX surface specifier. Set - from_surface, to_surface. - * lib/iconv_open2.h: Copy the values of from_surface, to_surface into - the conversion descriptor. - * lib/ebcdic*.h (*_mbtowc): Test the isurface. If requested, call - swap_x15_x25 right after fetching an input byte. - (*_wctomb): Test the osurface. If requested, call swap_x15_x25 right - before storing an output byte. - * man/iconvctl.3 (REQUEST VALUES): Document the - ICONV_{GET,SET}_{FROM,TO}_SURFACE requests. - * src/iconv.c (main): If ICONV_EBCDIC_ZOS_UNIX is set, set the from/to - surfaces accordingly. - * man/iconv.1 (ENVIRONMENT): New section. - * tests/check-ebcdic: New file. - * tests/Makefile.in (check): Invoke it. - (SOURCE_FILES): Add it. - * NEWS: Mention the new functionality. - -2023-03-31 Bruno Haible - - Add some transliterations for mathematical symbols. - Based on - and the translit_neutral change in - . - Reported by Mike Fulton in - . - * lib/translit.def: Add a couple of transliterations in the range - U+27C0..U+29FF. - * NEWS: Mention it. - -2023-03-31 Bruno Haible - - Upgrade transliterations to Unicode 15.0.0. - * tools/gen-translit-def-part.lisp: Update comments. - * lib/translit.def: Include differences between the generated files - translit-part-4.0.0.def and translit-part-15.0.0.def. - -2023-03-31 Bruno Haible - - Make table of transliterations more maintainable. - * tools/gen-translit-def-part.lisp: New file. - * Makefile.in (SOURCE_FILES): Add it. - -2023-03-31 Bruno Haible - - Fix table of transliterations. - * lib/translit.def: Sort according to Unicode code point. - -2023-02-13 Bruno Haible - - Fix iconv link command for Cygwin. - Inspired by https://www.cygwin.com/git-cygwin-packages/?p=git/cygwin-packages/libiconv.git;a=blob;f=1.16-cross-install.patch;h=7b3c5c0d761497a20abf0e4cc38d74f2755445fb;hb=HEAD . - Rationale: libintl may depends on libiconv. - * src/Makefile.in (install): On the link command line, mention libintl - before libiconv. - -2023-01-29 Bruno Haible - - Fix a clang warning "a function declaration without a prototype...". - * lib/loop_wchar.h (mbrtowc): Don't declare. Drop portability to BeOS. - -2022-07-18 Bruno Haible - - Make autopull.sh more suited for continuous integration. - * autopull.sh: Support option --one-time. - -2022-07-18 Bruno Haible - - Move gnulib-tool invocation back from autopull.sh to autogen.sh. - * autogen.sh: Revert last change. Improve comments. - * autopull.sh: Only call 'gitsub.sh pull'. - * HACKING: Mention autopull.sh. - -2022-07-17 Bruno Haible - - Split autogen.sh into autopull.sh and autogen.sh. - * autopull.sh: New file, based on autogen.sh. - * autogen.sh: Remove code that was moved to autopull.sh. Remove - --skip-gnulib option. - * Makefile.devel (all): Remove srclib/Makefile.gnulib. - * Makefile.in (SOURCE_FILES): Add autogen.sh. - * HACKING: Mention autopull.sh. - -2022-05-22 Bruno Haible - - Add GNU Project notice. - * JOIN-GNU: New file. Inspired by a suggestion from Josรฉ E. Marchesi - on the gnu-prog-discuss mailing list. - * README: Refer to it. - * Makefile.in (SOURCE_FILES): Add it. - -2022-05-15 Bruno Haible - - Switch to libtool 2.4.7. - * m4/libtool.m4: Update from libtool-2.4.7, with modifications: - 2008-04-06 Bruno Haible - * m4/libtool.m4 (LT_INIT): When setting LIBTOOL, use - CONFIG_SHELL; don't assume that the Makefile.in will set SHELL - to ${CONFIG_SHELL}. - * m4/ltoptions.m4: Likewise. - * m4/ltsugar.m4: Likewise. - * m4/ltversion.m4: Likewise. - * m4/lt~obsolete.m4: Likewise. - * build-aux/ltmain.sh: Update from libtool-2.4.7, with modifications: - 2017-07-15 Bruno Haible - Allow building statically linked binaries, through - LDFLAGS="-static". Apply patch from - . - * build-aux/ltmain.sh (func_mode_help, func_mode_link): In the - link mode, accept option '-static-uninstalled-libs' in place of - '-static', and make '-static' an equivalent of '-all-static'. - -2022-04-13 Bruno Haible - - Fix undefined behaviour. - * tests/test-shiftseq.c (main2): Make input array larger. - -2022-02-12 Bruno Haible - - Update translations. - * po/ro.po: Update Romanian translations. - * po/wa.po: Update Walloon translations. - -2022-02-12 Bruno Haible - - Prepare for version 1.17. - * configure.ac: Bump version number to 1.17. - * include/iconv.h.in (_LIBICONV_VERSION): Likewise. - * lib/Makefile.in (LIBICONV_VERSION_INFO): Bump to 9:0:7. - * src/iconv.c (print_version): Update copyright year. - * windows/iconv.rc: Likewise. - * windows/libiconv.rc: Likewise. - * README: Update download link. - -2022-02-12 Bruno Haible - - Update source file list (regression 2022-01-23). - * lib/Makefile.in (SOURCE_FILES): Add encodings_zos.def, ebcdic*.h. - (GENERATED_FILES): Add aliases_zos.h, canonical_zos.h. - * tests/Makefile.in (SOURCE_FILES): Add IBM-*.TXT. - -2022-01-23 Bruno Haible - - Update NEWS. - * NEWS: Mention the EBCDIC encodings. - -2022-01-23 Bruno Haible - - Optimize the EBCDIC table sizes. - * lib/converters.h (DEDUPLICATE_TABLES): New macro. - * lib/ebcdic1025.h: Deduplicate tables with ebcdic880.h. - * lib/ebcdic1123.h: Deduplicate tables with ebcdic1025.h. - * lib/ebcdic1132.h: Deduplicate tables with ebcdic838.h. - * lib/ebcdic1153.h: Deduplicate tables with ebcdic870.h. - * lib/ebcdic1154.h: Deduplicate tables with ebcdic880.h. - * lib/ebcdic1155.h: Deduplicate tables with ebcdic1026.h. - * lib/ebcdic1156.h: Deduplicate tables with ebcdic1112.h. - * lib/ebcdic1157.h: Deduplicate tables with ebcdic1122.h. - * lib/ebcdic1158.h: Deduplicate tables with ebcdic1154.h, ebcdic1123.h. - * lib/ebcdic1160.h: Deduplicate tables with ebcdic838.h. - * lib/ebcdic1164.h: Deduplicate tables with ebcdic1130.h. - * lib/ebcdic1165.h: Deduplicate tables with ebcdic870.h. - * lib/ebcdic1166.h: Deduplicate tables with ebcdic1154.h. - * lib/ebcdic4971.h: Deduplicate tables with ebcdic875.h. - * lib/ebcdic12712.h: Deduplicate tables with ebcdic424.h. - -2022-01-23 Bruno Haible - - New EBCDIC encodings. - Reported by Ulrich Schwab and Calvin Buckley via Jack Woehr. - * NOTES: Mention how to enable EBCDIC encodings. - * tests/IBM-*.TXT: New files. - * tools/8bit_tab_to_h.c (main): Emit copyright header with year 2022. - * tools/Makefile: Add rules for generating ebcdic*.h. - * lib/ebcdic*.h: New files, automatically generated by tools/Makefile. - * lib/ebcdic838.h: Tweak reverse mapping manually. - * lib/ebcdic1160.h: Likewise. - * lib/converters.h: Include all ebcdic*.h. - * lib/encodings_zos.def: New file. - * lib/genaliases2.c: Include encodings_zos.def. - * lib/genflags.c: Likewise. - * Makefile.devel (lib/aliases_zos.h lib/canonical_zos.h): New rule. - (lib/flags.h, totally-clean): Update. - * lib/aliases2.h: Include aliases_zos.h. - * lib/iconv.c (USE_ZOS): New macro. - Include encodings_zos.def, canonical_zos.h. - * README, man/iconv_open.3: Document the IBM-* encodings. - * tests/Makefile.in (check-extra-yes): Also test the EBCDIC encodings. - -2022-01-04 Bruno Haible - - Update after gnulib changed. - * gnulib-local/m4/alloca.m4 (gl_FUNC_ALLOCA): Set GL_GENERATE_ALLOCA_H - instead of ALLOCA_H. Drop AC_SUBST and AM_CONDITIONAL invocations. - -2021-09-19 Bruno Haible - - tests: Avoid check-subst failures in QEMU user-mode environments. - * Makefile.devel (GNULIB_MODULES): Add stdbool. - (gnulib-imported-files): Copy also tests/qemu.h. - * tests/is-native.c: New file. - * tests/Makefile.in (is-native, is-native.@OBJEXT@): New targets. - (clean): Remove the 'is-native' program. - (SOURCE_FILES): Add is-native.c. - (IMPORTED_FILES): Add qemu.h. - * tests/check-subst: Invoke 'locale charmap' only in native - environments. - -2021-06-27 Bruno Haible - - README: Update. - Reported at . - * README: Overhaul the paragraph that mentions iconv.m4. - -2021-06-06 Bruno Haible - - gnulib-local: Put real license notice into the source files. - * gnulib-local/lib/alloca.in.h: Use an LGPLv2+ notice. - -2021-02-28 Bruno Haible - - Update DEPENDENCIES. - * DEPENDENCIES: List the normal dependencies of a package with an - Autoconf-generated configure file. - -2021-02-07 Bruno Haible - - Support creating shared libraries on MidnightBSD. - Patch from . - * m4/libtool.m4: Treat MidnightBSD like FreeBSD. - * build-aux/ltmain.sh: Likewise. - -2021-01-31 Bruno Haible - - Update after gnulib changed on 2020-08-26. - * configure.ac: Test $iconv_arg1, not $am_cv_proto_iconv_arg1. - -2021-01-31 Bruno Haible - - Switch to autoconf 2.71. - * autogen.sh: Update comment. - * configure.ac: Use AS_HELP_STRING instead of AC_HELP_STRING. Invoke - AC_C_BIGENDIAN instead of CL_WORDS_LITTLEENDIAN. - * m4/eilseq.m4: Require Autoconf >= 2.61. - (AC_EILSEQ): Improve quoting. Use AC_COMPUTE_INT instead of - _AC_COMPUTE_INT. - * m4/endian.m4: Remove file. - * Makefile.in (SOURCE_FILES): Remove it. - -2020-12-08 Bruno Haible - - Switch to autoconf 2.70. - * Makefile.devel (AUTOCONF, AUTOHEADER): Remove '-2.69' suffix. - * HACKING: Remove sentence about symbolic links. - * autogen.sh: Update comment. - -2020-08-31 Bruno Haible - - Fix some -Wcast-qual warning, reported by clang. - * lib/iconv.c (compare_by_name): Add more 'const'. - (iconv_canonicalize): Cast value to 'unsigned char', not pointer to 'unsigned char *'. - * lib/iconv_open1.h: Likewise. - -2020-08-30 Bruno Haible - - Make sure that build-aux/compile is in the tarball. - * autogen.sh: Fetch also 'build-aux/compile' through gnulib-tool. - * Makefile.devel (srclib/Makefile.in): Don't fetch nor delete - 'build-aux/compile'. - * Makefile.in (AUTOMAKE_IMPORTED_FILES): Remove build-aux/compile. - (IMPORTED_FILES): Add build-aux/compile. - -2020-08-29 Bruno Haible - - Update after gnulib changed. - * configure.ac (AC_PREREQ): Bump minimum Autoconf version to 2.64. - -2020-08-06 Bruno Haible - - Avoid a GCC warning with GCC >= 7. - Reported by Reini Urban - in . - * lib/gentranslit.c (main): Reset i to 0 each time p gets a new value. - Add assertion about i's possible values. - -2020-04-05 Bruno Haible - - Fix an autogen.sh failure (regression from 2016-12-04). - Reported by Petr Ovtchenkov in - . - * autogen.sh: Invoke also the Makefile target srclib/Makefile.in, so as - to get build-aux/install-sh. Finish the "copy files" phase before recursing - through the subpackages tree through Makefile.devel. - * Makefile.devel: Reorder targets. - -2020-04-04 Bruno Haible - - Don't use LGPLv3. - * gnulib-local/modules/mbstate (License): Set to LGPLv2+. - -2020-04-04 Bruno Haible - - Change the license of the library from LGPL 2.0 to LGPL 2.1. - * COPYING.LIB: Upgrade to LGPL 2.1. - -2019-12-23 Bruno Haible - - Do export the symbol 'locale_charset' (needed by GNU bash). - * lib/Makefile.in (DEFS): Define also BUILDING_LIBCHARSET. - -2019-09-01 Bruno Haible - - build: Add support for shallow-cloning of subdirectories. - * gitsub.sh (func_usage): Document allowed git options with 'git pull'. - (func_pull): Accept GIT_OPTIONS argument. - (pull): Parse git options before complaining about too many arguments. - Pass the git options to func_pull. - -2019-07-05 Bruno Haible - - Don't export the symbol 'aliases_lookup' on non-ELF platforms. - * Makefile.devel (lib/aliases.h, lib/aliases_sysaix.h, - lib/aliases_syshpux.h, lib/aliases_sysosf1.h, lib/aliases_syssolaris.h): - Add a 'static' keyword in front of the declaration of aliases_lookup. - -2019-07-02 Bruno Haible - - Update to current gnulib. - * Makefile.devel (GNULIB_MODULES): Add lib-symbol-visibility. - (srclib/Makefile.gnulib): Copy codeset.m4. - * srclib/Makefile.am (AM_CFLAGS): Initialize. - -2019-07-02 Bruno Haible - - Drop unused macro gl_GLIBC21. - * autogen.sh: Don't copy glibc21.m4. - -2019-05-22 Bruno Haible - - Fix comment. - Reported by Paul Hardy . - * lib/jisx0213.h: Fix comment about the underlying standard version. - -2019-05-11 Bruno Haible - - Update bug reporting instructions. - * README: Tell users to report bugs in the bug tracker or by email. - * src/iconv.c (usage): Likewise. - (print_version): Move URL out of translatable string. - -2019-04-26 Bruno Haible - - Update translations. - $ rsync -Lrtvz translationproject.org::tp/latest/libiconv/ po/new - $ cd po/new - $ for f in *.po; do \ - msgmerge --update --lang=${f%.po} --previous $f ../libiconv.pot; \ - done - $ mv *.po ../ - $ cd ..; rm -rf new - -2019-04-26 Bruno Haible - - Update POT file. - $ cd po; make update-po - -2019-04-26 Bruno Haible - - Prepare for version 1.16. - * configure.ac: Bump version number to 1.16. - * include/iconv.h.in (_LIBICONV_VERSION): Likewise. - * lib/Makefile.in (LIBICONV_VERSION_INFO): Bump to 8:1:6. - * src/iconv.c (print_version): Update copyright year. - * windows/iconv.rc: Likewise. - * windows/libiconv.rc: Likewise. - * README: Update download link. - -2019-04-26 Bruno Haible - - Tweak exported symbols when --enable-relocatable is used. - * lib/Makefile.in (DEFS): Map 'relocate2' to a different symbol. - -2019-04-01 Bruno Haible - - build: Separate git operations from build operations. - * gitsub.sh: New file, from gnulib. - * .gitmodules: New file. - * autogen.sh: Remove all git operations. Look at GNULIB_SRCDIR - environment variable. Ignore the GNULIB_TOOL environment variable. - * HACKING: Explain when to use gitsub.sh. - -2019-03-07 Bruno Haible - - Avoid signed integer overflow during shifts. - Reported by Jeffrey Walton . - * lib/tcvn.h (tcvn_wctomb): Use unsigned integer type for bit mask - operation. - * lib/viscii.h (viscii_wctomb): Likewise. - -2019-03-04 Bruno Haible - - Add support for --enable-relocatable to libcharset. - * autogen.sh: Copy some more files to libcharset/build-aux/ and - libcharset/m4/. - -2019-03-04 Bruno Haible - - Update --enable-relocatable support after gnulib changed. - * configure.ac: Move the LT_INIT invocation before the gl_RELOCATABLE - invocation. Remove unused argument to gl_RELOCATABLE. - -2019-01-27 Bruno Haible - - Accommodate a shell that is not in /bin/sh. - * Makefile.in (SHELL): Use the value found by configure. - * lib/Makefile.in (SHELL): Likewise. - * man/Makefile.in (SHELL): Likewise. - * src/Makefile.in (SHELL): Likewise. - * tests/Makefile.in (SHELL): Likewise. - (check, check-extra-yes): Use SHELL to run the check-* scripts. - -2019-01-27 Bruno Haible - - Update after gnulib changed. - * Makefile.in (GNULIB_IMPORTED_FILES): Remove build-aux/snippet/*. - -2019-01-27 Bruno Haible - - Update support for building with MSVC. Automake does not install ar-lib. - * autogen.sh: Fetch build-aux/ar-lib here. - * Makefile.devel (srclib/Makefile.in): Don't fetch build-aux/ar-lib - here. - * Makefile.in (AUTOMAKE_IMPORTED_FILES): Remove build-aux/ar-lib. - (IMPORTED_FILES): Add build-aux/ar-lib. - -2019-01-06 Bruno Haible - - Revisit handling of file descriptors closed by the parent process. - * src/iconv.c (main): Add comment. - -2018-10-23 Bruno Haible - - Remove outdated DJGPP build infrastructure. - Approved by Juan Manuel Guerrero . - * djgpp: Remove directory. - * INSTALL.djgpp: Remove file. - * Makefile.in (SOURCE_FILES): Remove them. - -2018-10-23 Bruno Haible - - Update after gnulib changed. - * configure.ac (AC_PREREQ): Bump minimum Autoconf version to 2.63. - -2018-09-22 Bruno Haible - - Avoid some warnings in MSVC build. - * include/export.h: Handle MSVC compiler as well. - -2018-09-22 Bruno Haible - - Update from gnulib. Move mapping tables into the code. - * autogen.sh: Don't create libcharset/m4/relocatable-lib.m4. - * Makefile.in (mostlyclean, clean, distclean, maintainer-clean): Don't - remove lib/charset.alias. - * tests/check-subst: Don't set CHARSETALIASDIR. - -2018-05-04 Bruno Haible - - Drop special instructions for OSF/1. - * INSTALL.generic: Remove the recommendation for OSF/1. - -2018-05-04 Bruno Haible - - Simplify: Remove the ability to install a preloadable library. - * preload/*: Remove directory. - * Makefile.devel: Don't recurse into 'preload'. - * Makefile.in: Likewise. - * configure.ac: Don't declare 'preload' as a subdirectory. - * README, NEWS: Update. - -2018-05-04 Bruno Haible - - Simplify code. Drop support for Borland C++ on Windows. - * lib/iconv.c: Simplify 'defined _WIN32 || defined __WIN32__' to just - 'defined _WIN32'. - * lib/iconv_open1.h: Likewise. - -2018-05-04 Bruno Haible - - * lib/relocatable.c: Update from gnulib. - -2018-05-04 Bruno Haible - - Switch to automake 1.16. - * autogen.sh: Update comment. - * Makefile.devel (AUTOMAKE, ACLOCAL): Switch to version 1.16. - * libcharset/Makefile.devel (ACLOCAL): Likewise. - * preload/Makefile.devel (ACLOCAL): Likewise. - -2018-03-27 Bruno Haible - - Doc tweaks. - * README: Don't recommend to use --prefix=/usr/local, as it produces - problems with GCC (since GCC's treatment of /usr/local/include and - /usr/local/lib is inconsistent by default). Don't recommend to use - the iconv.m4 installed by GNU gettext, because it won't work when - GNU automake and GNU gettext are installed with different --prefix - options; instead recommend the 'iconv' module from gnulib. - -2018-01-27 Bruno Haible - - Rename some files. - * INSTALL.windows: Renamed from README.windows. - * INSTALL.djgpp: Renamed from README.djgpp. - * Makefile.in (SOURCE_FILES): Update. - -2018-01-03 Bruno Haible - - Fix installation in 64-bit mode on AIX. - * lib/Makefile.in (AR): New variable. - (install): Use it instead of hardcoding 'ar'. - -2017-11-26 Bruno Haible - - Avoid end-of-lines problem in generated shell scripts on Cygwin. - Patch by Feiyun Wang . - * lib/genaliases.c (main): Create canonical.sh and canonical_local.sh - with Unix end-of-line characters, regardless of Cygwin choice of - text mode vs. binary mode. - -2017-07-15 Bruno Haible - - Allow building statically linked binaries, through LDFLAGS="-static". - Apply patch from - . - * build-aux/ltmain.sh (func_mode_help, func_mode_link): In the link - mode, accept option '-static-uninstalled-libs' in place of '-static', - and make '-static' an equivalent of '-all-static'. - -2017-07-15 Bruno Haible - - Don't attempt to build preloadable_libiconv.so when linking statically. - * preload/configure.ac (enable_shared, enable_static): Don't force - shared libraries when LDFLAGS indicates static linking. - (PLUGLIB): Set to empty when is not configured for building shared - libraries. - -2017-07-15 Bruno Haible - - Get rid of autom4te.cache directories, as far as possible. - * Makefile.devel (srclib/Makefile.in, aclocal.m4, configure, - config.h.in): Remove autom4te.cache after invoking aclocal, autoconf, - autoheader, automake. - * preload/Makefile.devel (aclocal, configure): Likewise. - -2017-05-18 Bruno Haible - - * lib/relocatable.h: Update from gnulib. - * lib/relocatable.c: Update from gnulib. - -2017-01-30 Bruno Haible - - Prepare for version 1.15. - * src/iconv.c (print_version): Update copyright year. - * windows/iconv.rc: Likewise. - * windows/libiconv.rc: Likewise. - -2016-12-29 Bruno Haible - - Make Makefile.devel consistent with .gitignore. - * Makefile.devel (srclib/Makefile.in): Depend on aclocal.m4. - (totally-clean): Remove also aclocal.m4. - -2016-12-25 Bruno Haible - - Tweak autogen.sh. - * autogen.sh: Emit a "done" diagnostic when autogen.sh completed - successfully. - -2016-12-25 Bruno Haible - - Reorder Makefile.devel. - * Makefile.devel: Reorder: put gnulib targets before autotools targets. - -2016-12-14 Bruno Haible - - Cleanup useless removals. - * lib/Makefile.in (distclean): No need to remove 'libtool'. - -2016-12-04 Bruno Haible - - Update comments. - * Makefile.devel: Update comments about release process. - -2016-12-04 Bruno Haible - - Create tarballs through an Automake-like "make dist" command. - * Makefile.in (SOURCE_FILES, LIBTOOL_IMPORTED_FILES, - AUTOMAKE_OLD_IMPORTED_FILES, AUTOMAKE_IMPORTED_FILES, IMPORTED_FILES, - GENERATED_FILES, DISTRIBUTED_BUILT_FILES, DISTFILES): New macros. - (distdir): New target. - (PACKAGE, VERSION, TAR, GZIP): New macros. - (dist): New target. - * lib/Makefile.in (SOURCE_FILES, IMPORTED_FILES, GENERATED_FILES, - DISTRIBUTED_BUILT_FILES, DISTFILES): New macros. - (distdir): New target. - * man/Makefile.in (SOURCE_FILES, IMPORTED_FILES, GENERATED_FILES, - DISTRIBUTED_BUILT_FILES, DISTFILES): New macros. - (distdir): New target. - * preload/Makefile.in (SOURCE_FILES, IMPORTED_FILES, GENERATED_FILES, - DISTRIBUTED_BUILT_FILES, DISTFILES): New macros. - (distdir): New target. - * src/Makefile.in (SOURCE_FILES, IMPORTED_FILES, GENERATED_FILES, - DISTRIBUTED_BUILT_FILES, DISTFILES): New macros. - (distdir): New target. - * tests/Makefile.in (SOURCE_FILES, IMPORTED_FILES, GENERATED_FILES, - DISTRIBUTED_BUILT_FILES, DISTFILES): New macros. - (distdir): New target. - -2016-12-04 Bruno Haible - - Remove duplicates of imported files from version control. - * autogen.sh: Copy imported files to libcharset. - -2016-12-04 Bruno Haible - - Always use the newest released copies of files brought in from Automake. - * Makefile.devel (srclib/Makefile.in): Make sure to get new versions of - files brought in by automake. - * build-aux/install-sh: Remove from version control. - * build-aux/missing: Likewise. - -2016-12-04 Bruno Haible - - Always use the newest copies of config.guess, config.sub. - * Makefile.devel (gnulib-imported-files): New target. - * autogen.sh: Invoke it. - * build-aux/config.guess: Remove from version control. - * build-aux/config.sub: Likewise. - -2016-12-04 Bruno Haible - - Always use the newest copy of fcntl-o.m4. - * m4/fcntl-o.m4: Remove file. Rely on srcm4/fcntl-o.m4 instead. - -2016-12-04 Bruno Haible - - Remove obsolete documentation. - * PORTS: Remove file. - -2016-12-03 Bruno Haible - - Make Makefile.devel more useful for the users of the released tarball. - * Makefile.devel (srclib/Makefile.gnulib): Don't force this target. - (gnulib-clean): New target. - (totally-clean): New target. Do the removals from autogen.sh. Also, - remove lib/aliases*.gperf, lib/canonical*.h, man/iconvctl.3.html, - man/iconv_open_into.3.html. - * autogen.sh: Invoke target gnulib-clean before srclib/Makefile.gnulib. - Invoke target totally-clean before all. - * preload/Makefile.devel (totally-clean): New target. - -2016-12-03 Bruno Haible - - Modernize configure.ac. - * configure.ac: Use 2-argument AC_INIT. Avoid an AM_INIT_AUTOMAKE - warning. - * preload/configure.ac: Use 2-argument AC_INIT. Use AC_CONFIG_SRCDIR. - -2016-12-03 Bruno Haible - - Towards reproducible builds. - * Makefile.devel (man/%.html): Remove the CreationDate comment line - from the output. - -2016-12-04 Bruno Haible - - Update to gettext-0.19.8.1. - * ABOUT-NLS: Update through 'gettextize'. - -2016-12-03 Bruno Haible - - Update documentation. - * HACKING: Refer to the Git repository. - -2016-12-03 Bruno Haible - - Avoid compilation warnings in 'genflags' program. - * lib/genflags.c: Avoid warnings from GCC's -Wunused-function option. - -2016-12-02 Bruno Haible - - * relocatable.c: Update from gnulib. - -2016-11-25 Bruno Haible - - Prepare for version 1.15. - * configure.ac: Bump version number to 1.15. - * README: Likewise. - * include/iconv.h.in (_LIBICONV_VERSION): Likewise. - * windows/iconv.rc: Update. - * windows/libiconv.rc: Update. - * Makefile.devel: Update comments. - * lib/Makefile.in (LIBICONV_VERSION_INFO): Bump to 8:0:6. - * src/iconv.c (print_version): Update copyright year. - -2016-11-23 Bruno Haible - - Update installation instructions for Windows. - * README.windows: Assume a 64-bit Windows. Explain both 32-bit and - 64-bit builds. Add instructions for the MS Visual C/C++ tool chain. - Revamp instructions for Cygwin. - -2016-11-23 Bruno Haible - - Drop the nickname "woe32". - * README.windows: Renamed from README.woe32. - -2016-11-22 Bruno Haible - - Update support for building with MSVC. - * Makefile.devel (srclib/Makefile.in): Import 'ar-lib' and 'compile' - from gnulib. - * lib/Makefile.in (install-lib, install): Install the .la file with - $(INSTALL), not $(INSTALL_DATA). Otherwise the native Windows DLL gets - installed without execution permissions, and programs linked to it fail: - in a Cygwin shell with exit code 127, or from a cmd.exe window with a - dialog "The application was unable to start correctly (0xc0000022)." - -2016-11-19 Bruno Haible - - Fix link error when compiling with gcc -O0. - * lib/iconv.c (aliases2_lookup): Make static. - Reported by Chung-Lin Tang - at https://savannah.gnu.org/bugs/?47953 . - -2016-11-17 Bruno Haible - - UTF-8: Reject surrogates and out-of-range code points. - * lib/utf8.h (utf8_mbtowc, utf8_wctomb): Reject code points in the - range 0xD800..0xDFFF and >= 0x110000. - * tests/genutf8.c (main): Don't emit mappings for 0xD800..0xDFFF. - -2016-10-22 Bruno Haible - - Switch to libtool 2.4.6. - * m4/libtool.m4: Update from libtool-2.4.6, with modifications: - 2008-04-06 Bruno Haible - * m4/libtool.m4 (LT_INIT): When setting LIBTOOL, use - CONFIG_SHELL; don't assume that the Makefile.in will set SHELL - to ${CONFIG_SHELL}.. - * m4/ltoptions.m4: Likewise. - * m4/ltversion.m4: Likewise. - * build-aux/ltmain.sh: Likewise. - -2016-10-14 Bruno Haible - - Use 'size_t', not 'int', for the length of a string. - * lib/iconv.c: Include . - * lib/genflags.c: Likewise. - * lib/converters.h (struct mbtowc_funcs, struct wctomb_funcs): Change - 'int n' parameter to 'size_t n'. - (RET_COUNT_MAX): New macro. - * lib/*.h: Use 'size_t n' instead of 'int n'. - * lib/ucs2.h (ucs2_mbtowc): Make sure 'count' does not cause an 'int' - overflow. - * lib/ucs4.h (ucs4_mbtowc): Likewise. - * lib/utf16.h (utf16_mbtowc): Likewise. - * lib/utf32.h (utf32_mbtowc): Likewise. - * tools/8bit_tab_to_h.c: Generate function signatures with 'size_t n'. - * tools/cjk_tab_to_h.c: Likewise. - * NEWS: Mention the change. - -2016-10-04 Bruno Haible - - Extend CP1255 mapping. - * lib/cp1255.h (cp1255_2uni, cp1255_page05): Map 0xCA to U+05BA. - * tests/CP1255.TXT: Likewise. - This matches https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit1255.txt - and what the native Windows converter does since at least Windows XP. - -2016-10-01 Ben Noordhuis (tiny change) - Bruno Haible - - Remove large stack requirement from gentranslit. - * lib/gentranslit.c (main): Heap-allocate large arrays. - * Makefile.devel (lib/translit.h): Remove 'ulimit -s unlimited' command. - -2015-12-10 Ben Noordhuis (tiny change) - - Remove unused array from gentranslit. - * lib/gentranslit.c (main): Remove unused array. - * Makefile.devel (CC): Add -Wall option. - Reported in https://savannah.gnu.org/bugs/?46663 . - -2016-10-01 Bruno Haible - - Fix bug #41187. - * src/iconv.c (main): Increment i after parsing the --silent option. - Reported in https://savannah.gnu.org/bugs/?41187 . - -2016-10-01 Bruno Haible - - Update to current gnulib. - * Makefile.devel (GNULIB_MODULES): Remove memmove. - * tests/Makefile.in (INCLUDES): Make sure to include the top-level - "config.h". Needed for the 'binary-io' module. - -2016-10-01 Bruno Haible - - Switch to automake 1.15. - * autogen.sh: Update comment. - * Makefile.devel (AUTOMAKE, ACLOCAL): Switch to version 1.15. - (srclib/Makefile.in): Don't remove auxiliary files brought in by - automake. - * preload/Makefile.devel (ACLOCAL): Switch to version 1.15. - * srclib/Makefile.am (AUTOMAKE_OPTIONS): Add subdir-objects. - * build-aux/missing: Update from automake-1.15. - -2016-10-01 Bruno Haible - - Remove autogenerated doc files from version control. - * man/iconvctl.3.html: Remove file. - * man/iconv_open_into.3.html: Remove file. - -2012-12-06 Bruno Haible - - Change copyright holder of man pages. - * man/*.[13]: Replace myself with FSF. - -2012-06-30 Bruno Haible - - Make it possible to run 'genaliases2' on native Windows. - * lib/genaliases2.c (main): Expect 3 arguments. Open the output files - explicitly. Complain if they don't exist. - * Makefile.devel (lib/aliases_*.h): Pass the output filenames as - arguments to genaliases. - Reported at . - - Make it possible to run 'genaliases' on native Windows. - * lib/genaliases.c (main): Expect 3 arguments. Open the output files - explicitly. Complain if they don't exist. Improve error checking. - * Makefile.devel (lib/aliases*.h): Pass the output filenames as - arguments to genaliases. - Reported at . - -2012-05-13 Bruno Haible - - Tweak the GB18030 converter to map 0x8135F437 to U+E7C7. - * lib/gb18030.h (gb18030_pua2charset, gb18030_wctomb): Remove mapping - from U+E7C7 to 0xA8BC. - * lib/gb18030uni.h (gb18030uni_mbtowc): Treat 0x8135F437 as a special - case. - (gb18030uni_wctomb): Treat U+E7C7 as a special case. - * tests/GB18030-BMP.TXT: Map 0x8135F437 to U+E7C7, not U+1E3F. - * tests/GB18030.IRREVERSIBLE.TXT: Remove irreversible mappings for - 0x8135F437 and U+E7C7. - -2012-04-28 Bruno Haible - - Switch to autoconf 2.69 and automake 1.12. - * autogen.sh: Update comment. - * Makefile.devel (AUTOCONF, AUTOHEADER): Switch to version 2.69. - (AUTOMAKE, ACLOCAL): Switch to version 1.12. - * preload/Makefile.devel (AUTOCONF): Switch to version 2.69. - (ACLOCAL): Switch to version 1.12. - -2012-03-24 Bruno Haible - - Avoid a GCC warning. - * lib/isoir165.h (isoir165_mbtowc): Don't shadow the 'ret' variable. - -2012-01-26 Bruno Haible - - Modernize quoting. - * README: Quote 'like this', not `like this', as per the recent change - to the GNU coding standards. - * NOTES: Likewise. - * gnulib-local/lib/xmalloc.c: Likewise. - * lib/config.h.in: Likewise. - * src/iconv.c (usage): Likewise. - * tests/uniq-u.c: Likewise. - * tools/cjk_tab_to_h.c (output_uni2charset_sparse, do_jisx0213): - Likewise. - * lib/big5.h: Update accordingly. - * lib/cns11643_inv.h: Likewise. - * lib/cp932ext.h: Likewise. - * lib/cp950ext.h: Likewise. - * lib/gb12345ext.h: Likewise. - * lib/gb2312.h: Likewise. - * lib/gbkext_inv.h: Likewise. - * lib/hkscs1999.h: Likewise. - * lib/hkscs2001.h: Likewise. - * lib/hkscs2004.h: Likewise. - * lib/hkscs2008.h: Likewise. - * lib/isoir165ext.h: Likewise. - * lib/jisx0208.h: Likewise. - * lib/jisx0212.h: Likewise. - * lib/jisx0213.h: Likewise. - * lib/ksc5601.h: Likewise. - * lib/uhc_1.h: Likewise. - * lib/uhc_2.h: Likewise. - -2012-01-15 Bruno Haible - - Support for MSVC 9. - * lib/config.h.in (inline, mode_t, ssize_t): Copy snippets from top - config.h.in. - * tests/genutf8.c: Include config.h. - * tests/gengb18030z.c: Likewise. - * woe32dll/export.h (VARIABLE): Define to empty if not using GCC. - -2011-01-28 Bruno Haible - - Add a comment. - * woe32dll/export.h: Add a reference to the woe32dll writeup. - -2012-01-06 Bruno Haible - - Update after gnulib changed. - * gnulib-local/lib/error.h.diff: Update. - -2012-01-06 Bruno Haible - - Talk about "native Windows API", not "Woe32". - * lib/relocatable.c: Update comments to mention native Windows. - -2012-01-04 Bruno Haible - - Talk about "native Windows API", not "Win32". - * lib/relocatable.c: Update comments to mention native Windows. - (WINDOWS_NATIVE): Renamed from WIN32_NATIVE. - -2011-10-27 Bruno Haible - - Fix bug with error handling in UCS-2, UCS-4, UTF-32 decoders. - * lib/ucs2.h (ucs2_mbtowc): Increment count only after validating wc. - * lib/ucs4.h (ucs4_mbtowc): Likewise. - * lib/utf32.h (utf32_mbtowc): Likewise. - Reported at . - -2012-06-30 Bruno Haible - - Improve ISO-2022-CP-MS versus CP932. - * lib/iso2022_jpms.h (iso2022_jpms_mbtowc): Recognize characters from - the rows 0x79..0x7C as rows from CP932. - * tests/ISO-2022-JP-MS-snippet.alt: New file, renamed from - tests/ISO-2022-JP-MS-snippet. - * tests/ISO-2022-JP-MS-snippet.UTF-8: Update the rows that correspond - to ESC $ B 0x79..0x7C. - * tests/ISO-2022-JP-MS-snippet: Likewise. - * tests/check-stateful: Also test the *-snippet.alt file if it exists. - * tests/check-stateful.bat: Likewise. - -2012-06-30 Bruno Haible - - Improve ISO-2022-CP-MS versus CP932. - * lib/cp50221_0208_ext.h (cp50221_0208_ext_page30): Map U+301D like - U+301E. - * lib/iso2022_jpms.h (iso2022_jpms_wctomb): Map U+663B to JISX0208 - 0x7A 0x36, U+FFE2 to 0x7C 0x7B, U+FFE4 to 0x7C 0x7C. - Reported by Jeff Diehl . - -2011-10-23 Bruno Haible - - New encoding ISO-2022-CP-MS. - * NOTES: Mention ISO-2022-JP-MS. - * tools/CP50221-0208-EXT.TXT: New file. - * tools/CP50221-0212-EXT.TXT: New file. - * tools/8bit_tab_to_h.c: Add comments about how to generate - cp50221_0208_ext.h, cp50221_0212_ext.h. - * tools/Makefile: Add rules for generating cp50221_0208_ext.h, - cp50221_0212_ext.h. - * lib/cp50221_0208_ext.h: New file, mostly generated. - * lib/cp50221_0212_ext.h: New file, mostly generated. - * lib/iso2022_jpms.h: New file. - * lib/converters.h: Include it. - * lib/encodings.def: Add ISO-2022-JP-MS. - * README, man/iconv_open.3: Add ISO-2022-JP-MS. - * tests/ISO-2022-JP-MS-snippet: New file. - * tests/ISO-2022-JP-MS-snippet.UTF-8: New file. - * tests/Makefile.in (check): Also test ISO-2022-JP-MS. - Reported by Jeff Diehl . - -2011-10-23 Bruno Haible - - * lib/encodings.def: Add comments about Windows names of encodings. - -2011-10-18 Bruno Haible - - * m4/libtool.m4: Update from libtool-2.4.2, with modifications: - 2008-04-06 Bruno Haible - * m4/libtool.m4 (LT_INIT): When setting LIBTOOL, use - CONFIG_SHELL; don't assume that the Makefile.in will set SHELL - to ${CONFIG_SHELL}.. - * m4/ltoptions.m4: Likewise. - * m4/ltversion.m4: Likewise. - * build-aux/ltmain.sh: Likewise. - -2011-10-03 Bruno Haible - - * lib/relocatable.c: Update from gnulib. - -2011-09-02 Bruno Haible - - Fix "make check" failure when $(srcdir) != $(builddir). - * tests/Makefile.in (check): When $(srcdir) != ., temporarily copy - GB18030.IRREVERSIBLE.TXT into the build directory. - Reported by Christian Weisgerber . - -2011-08-07 Bruno Haible - - Ensure all HTML-formatted man pages are up-to-date. - * Makefile.devel (all): Depend on man/iconvctl.3.html and - man/iconv_open_into.3.html. - -2011-08-07 Bruno Haible - - * Version 1.14 released. - -2011-08-07 Bruno Haible - - * configure.ac: Bump version number to 1.14. - * README: Likewise. - * include/iconv.h.in (_LIBICONV_VERSION): Likewise. - * windows/iconv.rc: Update. - * lib/Makefile.in (LIBICONV_VERSION_INFO): Bump to 7:1:5. - * src/iconv.c (print_version): Update copyright year. - -2011-08-07 Bruno Haible - - Avoid a test failure on Solaris 2.6 and HP-UX 11.00. - * tests/test-to-wchar.c (main): Skip the test if conversion to wchar_t - is not supported. - -2011-08-07 Bruno Haible - - * tests/check-subst: Add comments about OSF/1. - -2011-08-07 Bruno Haible - - * lib/relocatable.c: Update from gnulib. - -2011-08-06 Bruno Haible - - Upgrade the GB18030 converter to the version from 2005. - * lib/gb18030ext.h (gb18030ext_2uni_pagefe): Change element type to - 'unsigned int'. Change values for 0xFE51..0xFE53, 0xFE59, 0xFE61, - 0xFE66, 0xFE67, 0xFE6C, 0xFE6D, 0xFE76, 0xFE7E, 0xFE90, 0xFE91, 0xFEA0. - (gb18030ext_mbtowc): Change type of wc to 'unsigned int'. Change values - for 0xA6D9..0xA6DF, 0xA6EC..0xA6ED, 0xA6F3, 0xA8BC. - (gb18030ext_page9f, gb18030ext_pagefe): New constant arrays. - (gb18030ext_wctomb): Change values for U+1E3F, U+9FB4..U+9FBB, - U+FE10..U+FE19, U+20087, U+20089, U+200CC, U+215D7, U+2298F, U+241FE. - * tests/GB18030-BMP.TXT: Change values for 0xA6D9..0xA6DF, - 0xA6EC..0xA6ED, 0xA6F3, 0xA8BC, 0xFE51..0xFE53, 0xFE59, 0xFE61, 0xFE66, - 0xFE67, 0xFE6C, 0xFE6D, 0xFE76, 0xFE7E, 0xFE90, 0xFE91, 0xFEA0, to map - to now-assigned Unicode codepoints. - * tests/GB18030.IRREVERSIBLE.TXT: New file. - -2011-08-06 Bruno Haible - - Fix conversion bug in CP1258 converter. - * lib/vietcomb.h (viet_comp_table_data): Remove entry for - U+00A5 U+0301. Fix entry for U+00A8 U+0301. - (viet_decomp_table): Fix entry for U+0385. - * tests/CP1258.IRREVERSIBLE.TXT: Update. - Reported by Gertjan Halkes . - -2011-07-03 Bruno Haible - - Improve interactive behaviour of iconv program. - * src/iconv.c (convert): Flush the output before starting a possibly - blocking safe_read call. - -2011-07-03 Bruno Haible - - Fix interactive behaviour of iconv program. - * Makefile.devel (GNULIB_MODULES): Add safe-read. - * src/iconv.c: Include safe-read.h. - (convert): Take the infile as a file descriptor, not as a FILE stream. - Use safe_read() instead of fread(). - (main): Update. - Reported by Xavier Pucel . - -2011-05-02 Bruno Haible - - Update after gnulib changed. - * autogen.sh (GNULIB_MODULES): Remove exit, add stdlib. - -2011-06-02 Bruno Haible - - Update after gnulib changed. - * gnulib-local/m4/alloca.m4 (gl_FUNC_ALLOCA): Update. - -2011-06-04 Bruno Haible - - Work around bug on OSF/1 5.1. - * lib/loop_wchar.h: Before including , include and - some other includes. - -2011-03-27 KO Myung-Hun - - Fix installation on OS/2. - * src/Makefile.in (all, iconv_no_i18n): Add $(EXEEXT) suffix to - iconv_no_i18n. This is the recommended way to use libtool, see - . - -2011-03-31 Bruno Haible - - gentranslit: Fix buffer overrun. - * lib/gentranslit.c (main): Allocate more room for the suffix strings - of the translit pages. - Reported by Ben Noordhuis . - -2011-02-28 Bruno Haible - - * lib/relocatable.h: Update from gnulib. - * lib/relocatable.c: Likewise. - -2011-01-29 Corinna Vinschen - Bruno Haible - - Simplify "wchar_t" handling on Cygwin 1.7.x. - * lib/iconv.c (iconv_canonicalize): On Cygwin >= 1.7, map - ei_local_wchar_t to ei_utf16le or ei_utf16be, not ei_ucs2internal. - * lib/iconv_open1.h: Likewise. - Rationale: . - -2011-01-29 Bruno Haible - - Adjust the meaning of "wchar_t" on native Windows systems. - * lib/iconv.c (iconv_canonicalize): On native Windows, map - ei_local_wchar_t to ei_utf16le or ei_utf16be, not ei_ucs2internal. - * lib/iconv_open1.h: Likewise. - Reported by Corinna Vinschen - in . - -2010-11-23 Bruno Haible - - Implement newer release of BIG5-HKSCS. - * tools/Makefile (ALL): Add hkscs2008.h. - (hkscs2008.h): New rule. - * tools/cjk_tab_to_h.c (main): Recognize hkscs2008. - * lib/encodings.def: Add BIG5-HKSCS:2008. Change BIG5-HKSCS alias to be - equivalent to BIG5-HKSCS:2008. - * lib/hkscs2008.h: New file, autogenerated. - * lib/big5hkscs2008.h: New file, based on lib/big5hkscs2004.h. - * lib/converters.h: Include the new file. - * README, man/iconv_open.3: Add BIG5-HKSCS:2004. - * tests/BIG5-HKSCS-2008.TXT: New file, based on - tests/BIG5-HKSCS-2004.TXT. - * tests/BIG5-HKSCS-2008.IRREVERSIBLE.TXT: New file, copied from - tests/BIG5-HKSCS-2004.IRREVERSIBLE.TXT - * tests/BIG5-HKSCS-2008-snippet: New file, based on - tests/BIG5-HKSCS-2004-snippet. - * tests/BIG5-HKSCS-2008-snippet.UTF-8: New file, based on - tests/BIG5-HKSCS-2004-snippet.UTF-8. - * tests/Makefile.in (check): Check also BIG5-HKSCS:2008. - Reported by oCameLo . - -2010-11-23 Bruno Haible - - Make cjk_tab_to_h 64-bit clean. - * tools/cjk_tab_to_h.c (do_jisx0213): Add a cast from size_t to int. - (output_title): Update copyright year. - -2010-09-23 Bruno Haible - - Switch to autoconf 2.68. - * autogen.sh: Update comment. - * configure.ac: Fix AC_COMPILE_IFELSE invocation. - * Makefile.devel (AUTOCONF, AUTOHEADER): Switch to version 2.68. - * preload/Makefile.devel (AUTOCONF): Likewise. - -2010-09-23 Bruno Haible - - * m4/libtool.m4: Update from libtool-2.4, with modifications: - 2008-04-06 Bruno Haible - * m4/libtool.m4 (LT_INIT): When setting LIBTOOL, use - CONFIG_SHELL; don't assume that the Makefile.in will set SHELL - to ${CONFIG_SHELL}. - * m4/ltversion.m4: Update from libtool-2.4. - * build-aux/ltmain.sh: Likewise. - -2010-09-23 Bruno Haible - - Simplify use of gnulib-tool now that gnulib-tool --import works better. - * autogen.sh: Don't remove gnulib-cache.m4 before running gnulib-tool. - * Makefile.devel (srclib/Makefile.gnulib): Depend on 'force'. - -2010-07-31 Bruno Haible - - * Makefile.devel (AUTOCONF, AUTOHEADER): Switch to version 2.67. - * preload/Makefile.devel (AUTOCONF): Likewise. - -2010-07-03 Bruno Haible - - * Makefile.devel (AUTOCONF, AUTOHEADER): Switch to version 2.66. - * preload/Makefile.devel (AUTOCONF): Likewise. - -2010-06-04 Bruno Haible - - Addendum to 2009-10-18 commit. - * m4/fcntl-o.m4: New file, from gnulib. - * configure.ac: Invoke gl_FCNTL_O_FLAGS. - * lib/config.h.in (HAVE_WORKING_O_NOFOLLOW): New macro. - -2010-06-04 Bruno Haible - - * m4/libtool.m4: Update from libtool-2.2.8, with modifications: - 2008-04-06 Bruno Haible - * m4/libtool.m4 (LT_INIT): When setting LIBTOOL, use - CONFIG_SHELL; don't assume that the Makefile.in will set SHELL - to ${CONFIG_SHELL}. - * m4/ltoptions.m4: Update from libtool-2.2.8. - * m4/ltversion.m4: Likewise. - * m4/lt~obsolete.m4: Likewise. - * build-aux/ltmain.sh: Likewise. - -2010-04-06 Bruno Haible - - Avoid a compilation error of gnulib's test-iconv-h-c++.cc on mingw. - * include/iconv.h.in: Restrict the extern "C" { ... } scope so that it - doesn't contains #include directives. - -2010-03-30 Bruno Haible - - * README.woe32: Update for Cygwin 1.7.x. - -2009-12-26 Bruno Haible - - * windows/libiconv.rc: Update. - * windows/iconv.rc: Update. - -2009-12-11 Bruno Haible - - * include/iconv.h.in: Untabify. - * gnulib-local/lib/xalloc.h: Untabify. - * woe32dll/export.h: Untabify. - * tests/uniq-u.c: Untabify. - -2009-12-11 Bruno Haible - - * srclib/Makefile.am (MOSTLYCLEANDIRS): New macro. - -2009-12-11 Bruno Haible - - * Makefile.devel (AUTOCONF, AUTOHEADER): Switch to version 2.65. - * preload/Makefile.devel (AUTOCONF): Likewise. - -2009-11-22 Bruno Haible - - * tests/check-subst: Add reference to the Solaris printf bug. - Reported by Dagobert Michelsen . - -2009-09-01 Bruno Haible - - * README.woe32: Put the -mno-cygwin option into CC and CXX. - Recommended by Paolo Bonzini and Eric Blake. - -2009-08-15 Bruno Haible - - * Makefile.devel (AUTOCONF, AUTOHEADER): Switch to version 2.64. - * preload/Makefile.devel (AUTOCONF): Likewise. - -2009-08-15 Bruno Haible - - Use .git/info/exclude, not .gitignore, for imported or generated files. - * Makefile.devel (srclib/Makefile.gnulib): Pass option --no-vc-files to - gnulib-tool. - -2009-07-07 Bruno Haible - - Fix an endless loop. - * lib/loop_wchar.h (wchar_to_loop_convert): Handle the case of - incomplete input correctly. - * tests/test-to-wchar.c: New file. - * tests/Makefile.in (tests-to-wchar, tests-to-wchar.o): New rules. - (check): Depend on and run tests-to-wchar. - (clean): Add tests-to-wchar. - Reported by Tristan Gingold . - -2009-06-30 Bruno Haible - - * Version 1.13.1 released. - -2009-06-30 Bruno Haible - - * configure.ac: Bump version number to 1.13.1. - * README: Likewise. - -2009-06-04 Bruno Haible - - * preload/Makefile.devel (AUTOCONF): Switch to version 2.63. - (ACLOCAL): Switch to version 1.11. - -2009-05-19 Bruno Haible - - * Makefile.devel (AUTOMAKE, ACLOCAL): Switch to version 1.11. - * autogen.sh: Update comments. - -2009-04-24 Bruno Haible - - Fix a compilation error on HP-UX 11.00, introduced on 2008-09-16. - * src/iconv_open2.h: Don't initialize nonexistent field if - !(HAVE_WCRTOMB || HAVE_MBRTOWC). - Patch by Joel Brobecker . - -2009-04-15 Bruno Haible - - * src/Makefile.in (install, uninstall): Append the $(EXEEXT) suffix - explicitly. Needed on Cygwin. - -2009-04-11 Bruno Haible - - * configure.ac: Move the statements for WOE32 and WINDRES. - -2009-03-26 Bruno Haible - - * Version 1.13 released. - -2009-03-26 Bruno Haible - - * src/iconv.c: Update copyright header to GPLv3+. - (print_version): Update license info. - -2009-03-26 Bruno Haible - - * src/iconv.c (print_version): Bump year. - -2009-03-25 Bruno Haible - - * build-aux/config.guess: Update to GNU version 2009-02-03. - * build-aux/config.sub: Likewise. - -2009-03-25 Bruno Haible - - * configure.ac: Bump version number to 1.13. - * README: Likewise. - * include/iconv.h.in (_LIBICONV_VERSION): Likewise. - * windows/iconv.rc: Update. - * lib/Makefile.in (LIBICONV_VERSION_INFO): Bump to 7:0:5. - -2009-03-25 Bruno Haible - - Fix the handling of Windows resources in shared libraries. - * configure.ac: Invoke LT_LANG for 'Windows Resource'. - * lib/Makefile.in (RC): New variable. - (WINDRES): Remove variable. - (OBJECTS_RES_yes): Add .lo suffix. - (libiconv.res.lo): Renamed from libiconv.res. Use libtool --tag=RC. - (clean): Simplify. - Based on a patch by Roumen Petrov . - -2009-03-14 Bruno Haible - - * autogen.sh: Checkout gnulib using 'git' instead of 'cvs'. - -2009-01-24 Bruno Haible - - * tools/Makefile (ALL): Add cp1131.h. - (cp1131.h): New rule. - * lib/encodings.def: Add CP1131. - * lib/cp1131.h: New file. - * lib/converters.h: Include it. - * README, man/iconv_open.3: Add CP1131. - * NOTES: Mention CP1131. - * tests/CP1131.TXT: New file. - * tests/Makefile.in (check): Also test CP1131. - -2009-01-17 Bruno Haible - - Add support for "make install-strip". - * configure.ac: Search for 'strip'. Invoke AM_PROG_INSTALL_STRIP. - * Makefile.in (install-strip): New rule. - * src/Makefile.in (STRIP, INSTALL_STRIP_PROGRAM, install_sh): New - variables. - (install-strip): New rule. - * lib/Makefile.in (install-strip): New target. - * preload/Makefile.in (install-strip): Likewise. - * man/Makefile.in (install-strip): Likewise. - Reported by Alon Bar-Lev . - -2009-01-17 Bruno Haible - - Update after gnulib changed. - * src/Makefile.in (RELOCATABLE_STRIP): New variable. - -2009-01-17 Bruno Haible - - Make --enable-relocatable work on glibc systems. - * src/Makefile.in (host): New variable. - -2009-01-17 Bruno Haible - - * lib/genflags.c: Include . - -2009-01-14 Bruno Haible - - * configure.ac: More consistent m4 quoting. - * preload/configure.ac: Likewise. - -2008-09-28 Bruno Haible - - * build-aux/ltmain.sh (func_emit_cwrapperexe_src): On mingw, - preprocess the argument vector through prepare_spawn. - -2008-09-27 Bruno Haible - - * build-aux/config.guess: Update to GNU version 2008-09-08. - * build-aux/config.sub: Likewise. - -2008-09-26 Bruno Haible - - * tests/test-shiftseq.c (main1, main2): Use ICONV_CONST. - -2008-09-26 Bruno Haible - - * Makefile.devel (GNULIB_MODULES): Add sigpipe, stdio. - * tests/Makefile.in (check, table-from, table-to, test-shiftseq): Link - all programs against libicrt.a. Needed for the stdio function - replacements on mingw. - -2008-09-21 Tadamasa Teranishi - - * lib/encodings_extra.def: Add aliases for EUC-JISX0213, SHIFT_JISX0213, - ISO-2022-JP-3, found on . - -2008-09-20 Bruno Haible - - * man/iconv_open_into.3: New file. - -2008-09-16 Bruno Haible - - New function iconv_open_into. - * include/iconv.h.in: Include and its prerequisites. - (iconv_allocation_t): New type. - (iconv_open_into): New declaration. - * lib/iconv_open1.h: New file, extracted from lib/iconv.c. - * lib/iconv_open2.h: New file, extracted from lib/iconv.c. - * lib/iconv.c (iconv_open): Include iconv_open1.h and iconv_open2.h. - Verify size of iconv_allocation_t. - (iconv_open_into): New function. - * lib/loop_wchar.h (struct wchar_conv_struct): Don't define a state - field if !(HAVE_WCRTOMB || HAVE_MBRTOWC). - * configure.ac: Set and substitute USE_MBSTATE_T, BROKEN_WCHAR_H. - Reported by Roman Rybalko . - -2008-09-16 Bruno Haible - - * Makefile.devel (AUTOCONF, AUTOHEADER): Switch to version 2.63. - -2008-09-16 Bruno Haible - - * include/iconv.h.in: Use Unicode single-quotes in comments. - -2008-09-14 Bruno Haible - - * Makefile.devel (GNULIB_MODULES): Add strerror. - -2008-09-07 Bruno Haible - - Make behaviour when encountering invalid input after a shift sequence - more consistent. - * lib/converters.h (RET_SHIFT_ILSEQ): New macro. - (RET_ILSEQ): Define in terms of RET_SHIFT_ILSEQ. - (RET_TOOFEW): Change to avoid collisions with RET_SHIFT_ILSEQ. - (DECODE_SHIFT_ILSEQ, DECODE_TOOFEW): New macros. - * lib/loop_unicode.h (unicode_loop_convert): Take into account the - shift count contained in the negative return values. - * lib/hz.h (hz_mbtowc): When encountering invalid input, store the - modified state and return RET_SHIFT_ILSEQ. - * lib/iso2022_cn.h (iso2022_cn_mbtowc): Likewise. - * lib/iso2022_cnext.h (iso2022_cn_ext_mbtowc): Likewise. - * lib/iso2022_jp.h (iso2022_jp_mbtowc): Likewise. - * lib/iso2022_jp1.h (iso2022_jp1_mbtowc): Likewise. - * lib/iso2022_jp2.h (iso2022_jp2_mbtowc): Likewise. - * lib/iso2022_jp3.h (iso2022_jp3_mbtowc): Likewise. - * lib/iso2022_kr.h (iso2022_kr_mbtowc): Likewise. - * lib/ucs2.h (ucs2_mbtowc): Likewise. - * lib/ucs4.h (ucs4_mbtowc): Likewise. - * lib/utf16.h (utf16_mbtowc): Likewise. - * lib/utf32.h (utf32_mbtowc): Likewise. - * lib/utf7.h (utf7_mbtowc): Likewise. - * lib/utf16be.h (utf16be_mbtowcutf16be_mbtowc): When encountering - invalid input, return RET_SHIFT_ILSEQ. - * lib/utf16le.h (utf16le_mbtowc): Likewise. - * tests/test-shiftseq.c: New file. - * tests/Makefile.in (check): Run test-shiftseq. - (test-shiftseq, test-shiftseq.@OBJEXT@): New rules. - (clean): Remove test-shiftseq executable. - Reported by Roman Rybalko - at . - -2008-09-07 Bruno Haible - - * man/iconv.3: Clarify the processing of shift-sequences. - -2008-09-07 Bruno Haible - - * m4/libtool.m4: Update from libtool-2.2.6, with modifications: - 2008-04-06 Bruno Haible - * m4/libtool.m4 (LT_INIT): When setting LIBTOOL, use - CONFIG_SHELL; don't assume that the Makefile.in will set SHELL - to ${CONFIG_SHELL}. - * m4/ltoptions.m4: Update from libtool-2.2.6. - * m4/ltsugar.m4: Likewise. - * m4/ltversion.m4: Likewise. - * build-aux/ltmain.sh: Likewise. - -2008-09-06 Bruno Haible - - * lib/gbk.h (gbk_wctomb): Fix an out-of-bounds write. - Reported by Roman Rybalko - at . - -2008-06-30 Bruno Haible - - Fix sed expressions to work with the old sed-3.02 on MSYS. - * windows/windres-options (sed_extract_major, sed_extract_minor, - sed_extract_subminor): Put a semicolon before the closing brace. Use - an i\ command instead of an a\ command. - Reported by Sunil Negi - in - via Keith Marshall . - -2008-05-22 Bruno Haible - - * README.woe32: Update with info from GNU gettext's README.woe32. - -2008-05-18 Bruno Haible - - * m4/libtool.m4: Update from libtool-2.2.4, with modifications: - 2008-04-06 Bruno Haible - * m4/libtool.m4 (LT_INIT): When setting LIBTOOL, use - CONFIG_SHELL; don't assume that the Makefile.in will set SHELL - to ${CONFIG_SHELL}. - * m4/ltoptions.m4: Update from libtool-2.2.4. - * m4/ltversion.m4: Likewise. - * m4/lt~obsolete.m4: Likewise. - * build-aux/ltmain.sh: Likewise. - -2008-04-14 Bruno Haible - - * tests/Makefile.in (check): Remove *.dSYM directories left over by gcc - on MacOS X 10.5. - -2008-04-14 Bruno Haible - - * preload/configure.ac: Invoke AC_USE_SYSTEM_EXTENSIONS instead of - AC_AIX and AC_MINIX. - * Makefile.devel (AUTOCONF, AUTOHEADER): Require autoconf-2.62. - * preload/Makefile.devel (AUTOCONF): Likewise. - * autogen.sh: Likewise. - -2008-04-06 Bruno Haible - - * m4/libtool.m4: Update from libtool-2.2.2, with modifications: - 2008-04-06 Bruno Haible - * m4/libtool.m4 (LT_INIT): When setting LIBTOOL, use - CONFIG_SHELL; don't assume that the Makefile.in will set SHELL - to ${CONFIG_SHELL}. - * m4/ltoptions.m4: New file, from libtool-2.2.2. - * m4/ltsugar.m4: New file, from libtool-2.2.2. - * m4/ltversion.m4: New file, from libtool-2.2.2. - * m4/lt~obsolete.m4: New file, from libtool-2.2.2. - * build-aux/ltmain.sh: New file, from libtool-2.2.2. - * configure.ac: Use LT_INIT instead of AC_PROG_LIBTOOL. - * preload/configure.ac: Likewise. - -2008-04-06 Bruno Haible - - More portable way of building the preloadable library. - * preload/Makefile.devel: New file. - * preload/Makefile.in: New file, based on lib/Makefile.in. - * preload/configure.ac: New file, based on configure.ac. - * Makefile.devel (all): Recurse into preload directory. - * Makefile.in (all, install, installdirs, uninstall, check, - mostlyclean, clean, distclean, maintainer-clean): Recurse into preload - directory. - * configure.ac: Likewise. - (OS, GCC, PLUGLIB): Remove definitions. - * lib/Makefile.in (all): Don't depend on PLUGLIB. - (preloadable_libiconv.so, preloadable_libiconv_linux.so, - preloadable_libiconv_solaris.so, preloadable_libiconv_osf.so): Remove - rules. - (install, uninstall, clean): Don't handle the preloadable library here. - -2008-04-06 Bruno Haible - - Avoid a gcc warning. - * lib/loop_unicode.h (unicode_loop_convert): Add a cast. - -2008-04-06 Bruno Haible - - * src/iconv.c (print_version): Bump year. - -2008-04-06 Bruno Haible - - Support all possible nl_langinfo(CODESET) results on the respective - platforms, according to libcharset/lib/config.charset. - * lib/encodings.def: Add DEFALIAS statements, conditional on - USE_AIX_ALIASES, USE_HPUX_ALIASES, USE_OSF1_ALIASES, - USE_SOLARIS_ALIASES. - * lib/encodings_aix.def: Add DEFALIAS statements, conditional on - USE_AIX_ALIASES. - * lib/encodings_osf1.def: Add DEFALIAS statements, conditional on - USE_OSF1_ALIASES. - * lib/genaliases.c (emit_alias): New function, extracted from - emit_encoding. - (emit_encoding): Use it. - (main): Define DEFALIAS. - * lib/genaliases2.c (counter): New variable, extracted from - emit_encoding. - (emit_alias): New function, extracted from emit_encoding. - (emit_encoding): Use it. - (main): Define DEFALIAS. - * lib/genflags.c (main): Define DEFALIAS. - * lib/iconv.c (all_encodings): Define DEFALIAS. - Include the system dependent variant of aliases.h on the appropriate - systems. - (all_canonical): Include the system dependent variant of canonical.h, - canonical_aix.h, canonical_osf1.h, canonical_local.h on the appropriate - systems. - * lib/aliases2.h: Include the system dependent variant of - aliases_aix.h or aliases_osf1.h on the appropriate systems. - * lib/Makefile.in (iconv.lo): Depend on aliases_sysaix.h, - aliases_syshpux.h, aliases_sysosf1.h, aliases_syssolaris.h, - aliases_aix_sysaix.h, lib/aliases_osf1_sysosf1.h, and also - aliases_extra.h, translit.h. - * Makefile.devel (all): Depend on lib/aliases_sysaix.h, - lib/aliases_syshpux.h, lib/aliases_sysosf1.h, lib/aliases_syssolaris.h, - lib/aliases_aix_sysaix.h, lib/aliases_osf1_sysosf1.h. - (lib/aliases_sysaix.h, lib/aliases_syshpux.h, lib/aliases_sysosf1.h, - lib/aliases_syssolaris.h): New rules. - (lib/aliases_aix_sysaix.h): New rule. - (lib/aliases_osf1_sysosf1.h): New rule. - * autogen.sh: Also remove lib/aliases_sysaix.h, lib/aliases_syshpux.h, - lib/aliases_sysosf1.h, lib/aliases_syssolaris.h, - lib/aliases_aix_sysaix.h, lib/aliases_osf1_sysosf1.h. - -2008-04-06 Bruno Haible - - * build-aux/config.libpath: Remove file, brought in by gnulib-tool. - * build-aux/config.rpath: Remove file, brought in by gnulib-tool. - -2007-11-11 Bruno Haible - - * Version 1.12 released. - -2007-11-11 Bruno Haible - - * Makefile.devel (AUTOCONF, AUTOHEADER): Require version 2.61. - (AUTOMAKE, ACLOCAL): Require version 1.10. - (srclib/Makefile.in): Avoid error from automake. - -2007-10-26 Bruno Haible - - * m4/libtool.m4: Update, based on libtool-1.5.24. - * build-aux/ltmain.sh: Update, based on libtool-1.5.24. - -2007-10-23 Bruno Haible - - * build-aux/config.guess: Update to GNU version 2007-07-22. - * build-aux/config.sub: Likewise. - -2007-10-23 Bruno Haible - - * configure.ac: Bump version number to 1.12. - * README: Likewise. - -2007-10-23 Bruno Haible - - Move relocatability infrastructure to gnulib. - * gnulib-local/lib/relocatable.h: Remove file. - * gnulib-local/lib/relocatable.c: Remove file. - -2007-10-23 Bruno Haible - - Update from GNU gettext. - 2006-11-26 Bruno Haible - * gnulib-local/lib/xalloc.h (xmemdup): Add a typesafe C++ - template variant. - Based on a patch from Paul Eggert in gnulib. - 2006-11-06 Bruno Haible - * gnulib-local/lib/xalloc.h (xcharalloc): New macro. - (xmemdup): New declaration. - * gnulib-local/lib/xstrdup.c (xmemdup): New function. - 2006-11-03 Bruno Haible - * gnulib-local/lib/xalloc.h (XMALLOC, XNMALLOC, XZALLOC, - XCALLOC): New macros. - (xnboundedmalloc): New inline function. - * gnulib-local/lib/xstrdup.c (xstrdup): Use XNMALLOC instead of - xmalloc. - 2006-11-02 Bruno Haible - * lib/xalloc.h (xnmalloc): New declaration. From gnulib - xalloc.h. - * lib/xmalloc.c (fixup_null_alloc): Write NULL, not 0. - (xnmalloc): New function. - -2007-10-23 Bruno Haible - - Moved module xreadlink to gnulib. - * gnulib-local/modules/xreadlink: Remove file. - * gnulib-local/lib/xreadlink.h: Remove file. - * gnulib-local/lib/xreadlink.c: Remove file. - * gnulib-local/m4/xreadlink.m4: Remove file. - -2007-10-07 Bruno Haible - - Update program license to GPLv3. - * COPYING: Replace with GPL 3. - * windows/iconv.rc (Comments): Update. - -2007-10-07 Bruno Haible - - * gnulib-local/lib/alloca.in.h: Renamed from gnulib-local/lib/alloca_.h. - -2007-03-30 Bruno Haible - - * gnulib-local/lib/alloca_.h: Change prefix of double-inclusion guard - macro to _GL_. - -2006-06-19 Paul Eggert - - * gnulib-local/lib/alloca_.h (alloca) [defined alloca]: Don't define or - declare. - -2007-09-29 Bruno Haible - - * autogen.sh (GNULIB_CVS_ROOT): Change to read-only git mirror - valid since 2007-09-19. - -2007-07-07 Bruno Haible - - * autogen.sh: Add an option --skip-gnulib. - -2007-07-07 Bruno Haible - - * gnulib-local/lib/uniwidth.h: Remove file, moved to gnulib. - * gnulib-local/lib/width.c: Remove file, moved to gnulib. - * gnulib-local/lib/cjk.h: Remove file, moved to gnulib. - * gnulib-local/modules/uniwidth: Remove file. - * Makefile.devel (GNULIB_MODULES): Remove uniwidth, add uniwidth/width. - * src/iconv.c: Include uniwidth/cjk.h instead of cjk.h. - -2007-06-30 Bruno Haible - - * src/iconv.c (print_version): Use the standard --version output, see - . - -2007-06-30 Bruno Haible - - * autogen.sh: New file. - * DEPENDENCIES: New file. - * HACKING: New file. - -2007-06-30 Bruno Haible - - * src/iconv.c: Provide translator comments for many messages. - (conversion_error_EILSEQ, conversion_error_EINVAL, - conversion_error_other): New functions, extracted from convert. - (convert): Use them. - Reported by Tim Van Holder . - -2007-06-09 Bruno Haible - - * gnulib-local/lib/relocwrapper.c: Remove file. - -2007-05-27 Bruno Haible - - * windows/libiconv.rc: New file. - * windows/iconv.rc: New file. - * windows/windres-options: New file. - * configure.ac (WOE32): New variable. - (WINDRES) [WOE32]: New variable. - * lib/Makefile.in (WINDRES): New variable. - (PACKAGE_VERSION): New variable. - (OBJECTS_EXP_yes): Renamed from OBJECTS_yes. - (OBJECTS_EXP_no): Renamed from OBJECTS_no. - (OBJECTS_RES_yes, OBJECTS_RES_no): New variables. - (OBJECTS): Add one of them. - (libiconv.res): New rule. - (clean): Remove also libiconv.res. - * src/Makefile.in (WINDRES): New variable. - (PACKAGE_VERSION): New variable. - (OBJECTS_RES_yes, OBJECTS_RES_no): New variables. - (all, iconv_no_i18n, install): Use them. - (iconv.res): New rule. - (clean): Remove also iconv.res. - Suggested and inspired by work by Perry Rapp. - -2007-05-27 Bruno Haible - - Follow broken iconv() prototype in POSIX. - * configure.ac (ICONV_CONST): Set to empty if the system has no iconv. - * lib/config.h.in (ICONV_CONST): Change default value to an empty - comment. - * src/iconv.c (ICONV_CONST): Change default value to empty. - Reported by Andreas Krennmair . - -2007-05-25 Bruno Haible - - * tools/Makefile (ALL): Add rk1048.h. - (rk1048.h): New rule. - * lib/encodings.def: Add RK1048. - * lib/rk1048.h: New file. - * lib/converters.h: Include it. - * README, man/iconv_open.3: Add RK1048. - * NOTES: Mention RK1048. - * tests/RK1048.TXT: New file. - * tests/Makefile.in (check): Also test RK1048. - Suggested by Timur Birsh . - -2007-04-24 Bruno Haible - - * man/iconv_open.3: Tweak explanation of TRANSLIT. - Reported by Perry Rapp. - -2007-04-23 Bruno Haible - - * tests/check-subst: Use the output of 'printf' only if it didn't - crash. Needed to work around a buffer overflow in Solaris /bin/printf. - Reported by Arto C. Nirkko . - -2007-04-23 Bruno Haible - - * lib/iconv.c (iconv_open, iconv_canonicalize): Treat native Woe32 - systems like those which define __STDC_ISO_10646__. - Reported by Keith Marshall . - -2007-03-31 Bruno Haible - - * man/iconv.1: Use HYPHEN-MINUS signs instead of HYPHENs where - appropriate. - * man/iconv_open.3: Likewise. - * man/iconv.3: Likewise. - * man/iconv_close.3: Likewise. - * man/iconvctl.3: Likewise. - -2007-03-31 Bruno Haible - - * man/iconv.1: Mark as POSIX compliant. - * man/iconv_open.3: Likewise. - * man/iconv.3: Likewise. - * man/iconv_close.3: Likewise. - - * man/*.[13]: Syntactic simplifications. - -2007-03-19 Bruno Haible - - Assume that mkinstalldirs also creates the necessary parent directories. - * Makefile.in (install, installdirs): Don't explicitly create the - parent directories. - * lib/Makefile.in (install, installdirs): Likewise. - * src/Makefile.in (install, installdirs): Likewise. - * man/Makefile.in (install, installdirs): Likewise. - Reported by Thomas Klausner . - -2007-03-04 Bruno Haible - - * Makefile.devel (GNULIB_MODULES): Add relocatable-prog. Remove - relocatable, relocwrapper. - * configure.ac: Invoke gl_RELOCATABLE instead of AC_RELOCATABLE. - * gnulib-local/modules/progreloc: Remove file. - * gnulib-local/modules/relocatable: Remove file. - * gnulib-local/modules/relocwrapper: Remove file. - * gnulib-local/m4/relocatable.m4: Remove file. - * gnulib-local/lib/strerror.c.diff: Remove file. - * src/Makefile.in: Remove SET_RELOCATABLE invocation. Instead get - RELOCATABLE_LDFLAGS and INSTALL_PROGRAM_ENV. - -2007-02-19 Bruno Haible - - * gnulib-local/lib/xmalloc.c: Don't include exit.h. - * src/iconv.c: Likewise. - -2007-02-16 Juan Manuel Guerrero - - * djgpp/*: Update. - -2007-02-03 Bruno Haible - - * tools/Makefile (ksc5601.h): Add one extra character. - * lib/ksc5601.h: Regenerated. - * lib/cp949.h (cp949_mbtowc, cp949_wctomb): Exclude the new character. - * tests/EUC-KR.TXT: Add CIRCLED HANGUL IEUNG U. - * tests/JOHAB.TXT: Likewise. - Reported by Jungshik Shin (์‹ ์ •์‹, ็”ณๆ”ฟๆนœ) . - - * lib/euc_kr.h: Update comments. - * lib/johab.h: Likewise. - -2007-02-03 Bruno Haible - - * tools/cjk_tab_to_h.c (output_title): Bump copyright year. - -2007-01-26 Bruno Haible - - Moved streq.h to gnulib. - * gnulib-local/lib/streq.h: Remove file. - * gnulib-local/modules/uniwidth (Files): Remove lib/streq.h. - (Depends-on): Add streq. - (lib_SOURCES): Remove streq.h. - -2007-01-26 Bruno Haible - - Moved unitypes.h to gnulib. - * gnulib-local/lib/unitypes.h: Remove file. - * gnulib-local/modules/uniwidth (Files): Remove lib/unitypes.h. - (Depends-on): Add unitypes. - (lib_SOURCES): Remove unitypes.h. - -2007-01-26 Bruno Haible - - Moved canonicalize to gnulib. - * gnulib-local/modules/canonicalize: Remove file. - * gnulib-local/lib/canonicalize.h: Remove file. - * gnulib-local/lib/canonicalize.c: Remove file. - * gnulib-local/m4/canonicalize.m4: Remove file. - * gnulib-local/modules/progreloc (Depends-on): Replace 'canonicalize' - with 'canonicalize-lgpl'. - -2006-12-20 Bruno Haible - - * lib/Makefile.in (install): On AIX, add the contents of - /lib/libiconv.a to libiconv.a. - -2006-12-20 Bruno Haible - - * Makefile.devel (all): Depend on srclib/Makefile.gnulib, not - srclib/Makefile.am. - (aclocal.m4): Likewise. Touch the resulting file, since aclocal not - always does it. - (srclib/Makefile.gnulib): Renamed from srclib/Makefile.am. Pass - option --makefile-name. - (srclib/Makefile.in): Depend on srclib/Makefile.gnulib too. - * srclib/Makefile.am: New file that includes srclib/Makefile.gnulib. - -2006-10-31 Bruno Haible - - Update from GNU gettext. - 2006-10-29 Bruno Haible - Make it compile in C++ mode. - * gnulib-local/lib/xalloc.h (xrealloc): Define as template - with appropriate return type. - * gnulib-local/lib/xstrdup.c (xstrdup): Cast xmalloc result. - 2006-10-26 Bruno Haible - * gnulib-local/modules/canonicalize (Makefile.am): Remove - EXTRA_DIST. Now done by gnulib-tool. - * gnulib-local/modules/relocatable (Makefile.am): Likewise. - * gnulib-local/modules/relocwrapper (Makefile.am): Likewise. - 2006-10-25 Bruno Haible - * gnulib-local/m4/relocatable.m4 (AC_RELOCATABLE_BODY): - Renamed from AC_RELOCATABLE, without the AC_LIBOBJ invocation. - (AC_RELOCATABLE): New macro. Invoke AC_LIBOBJ here. - * gnulib-local/modules/relocwrapper (configure.ac): Invoke - AC_RELOCATABLE instead of requiring it. - 2006-10-12 Bruno Haible - * gnulib-local/modules/canonicalize (Makefile.am): Distribute - all files in lib/ through EXTRA_DIST. - * gnulib-local/modules/relocatable (Makefile.am): Likewise. - 2006-09-14 Bruno Haible - * gnulib-local/lib/canonicalize.c: Include - unconditionally. - * gnulib-local/lib/relocatable.c: Likewise. - * lib/relocatable.c: Likewise. - * gnulib-local/lib/relocwrapper.c: Likewise. - * gnulib-local/lib/xmalloc.c: Likewise. - * gnulib-local/lib/xreadlink.c: Likewise. - * gnulib-local/lib/xstrdup.c: Likewise. - 2006-08-02 Bruno Haible - * gnulib-local/modules/canonicalize: Put under LGPL. - * gnulib-local/modules/relocatable: Likewise. - 2006-07-18 Bruno Haible - * gnulib-local/xalloc.h (xzalloc): New declaration. - * gnulib-local/xmalloc.c (xzalloc): New function. - -2006-10-24 Bruno Haible - - * man/Makefile.in (PACKAGE): New variable. Needed for docdir. - Reported by Charles Wilson . - -2006-10-14 Bruno Haible - - * COPYING: New file. - * README: Clarify copyright of the iconv program. - Reported by Charles Wilson . - -2006-08-08 Bruno Haible - - * INSTALL.generic: Add a recommendation for Tru64. - Reported by Gary V. Vaughan . - -2006-07-29 Bruno Haible - - * tests/check-subst: Set CHARSETALIASDIR. - Needed so that "make check" works before "make install" on systems - such as NetBSD. - -2006-07-29 Bruno Haible - - * Makefile.devel (aclocal.m4): Depend on srclib/Makefile.am. - (AUTOCONF_FILES): Add the existing *.m4 files. - -2006-07-29 Bruno Haible - - * gnulib-local/lib/xreadlink.c: Assume exists. - * src/iconv.c: Assume exists. - * configure.ac: Remove tests for , , , - . - -2006-07-29 Bruno Haible - - * configure.ac: Remove obsolete calls AC_PROG_GCC_TRADITIONAL, - AC_ISC_POSIX, AC_HEADER_STDC. - -2006-07-29 Bruno Haible - - * configure.ac: Remove macro invocations that are redundant through - gl_EARLY and gl_INIT. - -2006-07-29 Bruno Haible - - * gnulib-local/m4/alloca.m4 (gl_PREREQ_ALLOCA): Add a dummy statement. - Avoids a sh syntax error. - -2006-07-29 Bruno Haible - - * gnulib-local/m4/relocatable.m4: Add comments. - -2006-07-29 Bruno Haible - - * gnulib-local/modules/libiconv-misc: New file. - * Makefile.devel (GNULIB_MODULES): Add libiconv-misc. - - * Makefile.devel (srclib/Makefile.am): Pass --no-libtool. - -2006-07-29 Bruno Haible - - Note: gnulib macros no longer invoke AC_TYPE_SIZE_T nor - AC_CHECK_TYPE([ptrdiff_t], , [AC_DEFINE([ptrdiff_t], [long], ...)]) - because we now assume that the system defines size_t and ptrdiff_t. - -2006-07-29 Bruno Haible - - Switch to using gnulib. - * configure.ac (AC_PREREQ): Require autoconf-2.60. - Invoke gl_EARLY and gl_INIT. - * Makefile.devel (all): Depend on srclib/Makefile.am. - (aclocal.m4): Pass -I srcm4 to aclocal. Simplify dependencies, assuming - GNU make. - (GNULIB_MODULES): New variable. - (srclib/Makefile.am): New rule. - * gnulib-local: New directory. - * gnulib-local/m4/alloca.m4: Moved here from m4/alloca.m4. - * gnulib-local/m4/canonicalize.m4: Moved here from m4/canonicalize.m4. - * gnulib-local/m4/relocatable.m4: Moved here from m4/relocatable.m4. - * gnulib-local/m4/xreadlink.m4: Moved here from m4/xreadlink.m4. - * gnulib-local/lib/alloca_.h: Moved here from srclib/alloca_.h. - * gnulib-local/lib/canonicalize.h: Moved here from srclib/canonicalize.h. - * gnulib-local/lib/canonicalize.c: Moved here from srclib/canonicalize.c. - * gnulib-local/lib/cjk.h: Moved here from srclib/cjk.h. - * gnulib-local/lib/error.h.diff: New file. - * gnulib-local/lib/progname.h.diff: New file. - * gnulib-local/lib/relocatable.h: Moved here from srclib/relocatable.h. - * gnulib-local/lib/relocatable.c: Moved here from srclib/relocatable.c. - * gnulib-local/lib/relocwrapper.c: Moved here from srclib/relocwrapper.c. - * gnulib-local/lib/streq.h: Moved here from srclib/streq.h. - * gnulib-local/lib/strerror.c.diff: New file. - * gnulib-local/lib/unitypes.h: Moved here from srclib/unitypes.h. - * gnulib-local/lib/uniwidth.h: Moved here from srclib/uniwidth.h. - * gnulib-local/lib/width.c: Moved here from srclib/width.c. - * gnulib-local/lib/xalloc.h: Moved here from srclib/xalloc.h. - * gnulib-local/lib/xmalloc.c: Moved here from srclib/xmalloc.c. - * gnulib-local/lib/xstrdup.c: Moved here from srclib/xstrdup.c. - * gnulib-local/lib/xreadlink.h: Moved here from srclib/xreadlink.h. - * gnulib-local/lib/xreadlink.c: Moved here from srclib/xreadlink.c. - * gnulib-local/modules/canonicalize: New file. - * gnulib-local/modules/progreloc: New file. - * gnulib-local/modules/relocatable: New file. - * gnulib-local/modules/relocwrapper: New file. - * gnulib-local/modules/uniwidth: New file. - * gnulib-local/modules/xalloc: New file. - * gnulib-local/modules/xreadlink: New file. - - * m4/allocsa.m4: Remove file. Now taken from gnulib. - * m4/codeset.m4: Likewise. - * m4/eealloc.m4: Likewise. - * m4/error.m4: Likewise. - * m4/extensions.m4: Likewise. - * m4/full-header-path.m4: Likewise. - * m4/gettext.m4: Likewise. - * m4/glibc21.m4: Likewise. - * m4/iconv.m4: Likewise. - * m4/intmax.m4: Likewise. - * m4/inttypes-h.m4: Likewise. - * m4/inttypes_h.m4: Likewise. - * m4/isc-posix.m4: Likewise. - * m4/lcmessage.m4: Likewise. - * m4/lib-ld.m4: Likewise. - * m4/lib-link.m4: Likewise. - * m4/lib-prefix.m4: Likewise. - * m4/longdouble.m4: Likewise. - * m4/longlong.m4: Likewise. - * m4/mbstate_t.m4: Likewise. - * m4/nls.m4: Likewise. - * m4/onceonly.m4: Likewise. - * m4/pathmax.m4: Likewise. - * m4/po.m4: Likewise. - * m4/printf-posix.m4: Likewise. - * m4/progtest.m4: Likewise. - * m4/readlink.m4: Likewise. - * m4/setenv.m4: Likewise. - * m4/signed.m4: Likewise. - * m4/size_max.m4: Likewise. - * m4/ssize_t.m4: Likewise. - * m4/stdbool.m4: Likewise. - * m4/stdint.m4: Likewise. - * m4/stdint_h.m4: Likewise. - * m4/strerror.m4: Likewise. - * m4/strerror_r.m4: Likewise. - * m4/unistd_h.m4: Likewise. - * m4/unlocked-io.m4: Likewise. - * m4/visibility.m4: Likewise. - * m4/wchar_t.m4: Likewise. - * m4/wint_t.m4: Likewise. - - * srclib/allocsa.h: Remove file. Now taken from gnulib. - * srclib/allocsa.c: Likewise. - * srclib/binary-io.h: Likewise. - * srclib/error.h: Likewise. - * srclib/error.c: Likewise. - * srclib/exit.h: Likewise. - * srclib/gettext.h: Likewise. - * srclib/memmove.c: Likewise. - * srclib/pathmax.h: Likewise. - * srclib/progname.h: Likewise. - * srclib/progname.c: Likewise. - * srclib/progreloc.c: Likewise. - * srclib/readlink.c: Likewise. - * srclib/setenv.h: Likewise. - * srclib/setenv.c: Likewise. - * srclib/stdbool_.h: Likewise. - * srclib/stdint_.h: Likewise. - * srclib/strerror.c: Likewise. - * srclib/unlocked-io.h: Likewise. - * srclib/unsetenv.c: Likewise. - * srclib/Makefile.am: Remove file. - -2006-07-27 Bruno Haible - - Remove OS/2 build support that doesn't assume GNU make and GNU bash. - * README.os2: Remove file. - * Makefile.os2: Remove file. - * lib/Makefile.os2: Remove file. - * src/Makefile.os2: Remove file. - * man/Makefile.os2: Remove file. - * tests/Makefile.os2: Remove file. - * tests/check-stateful.cmd: Remove file. - * tests/check-stateless.cmd: Remove file. - * tests/check-translit.cmd: Remove file. - -2006-07-25 Bruno Haible - - Remove MSVC/nmake build support. - * windows: Remove directory. - * Makefile.msvc: Remove file. - * lib/Makefile.msvc: Remove file. - * srclib/Makefile.msvc: Remove file. - * src/Makefile.msvc: Remove file. - * tests/Makefile.msvc: Remove file. - * man/Makefile.msvc: Remove file. - * po/Rules-msvc: Remove file. - * po/Makefile.msvc.sh: Remove file. - * Makefile.devel (config.h.msvc, lib/config.h.msvc): Remove rules. - (include/iconv.h.msvc-static, include/iconv.h.msvc-shared): Remove - rules. - (po/Makefile.msvc): Remove rule. - (all): Update. - -2006-07-25 Bruno Haible - - Remove VMS support. - * vms: Remove directory. - * Makefile.vms: Remove file. - * lib/Makefile.vms: Remove file. - * srclib/Makefile.vms: Remove file. - * src/Makefile.vms: Remove file. - * tests/Makefile.vms: Remove file. - * man/Makefile.vms: Remove file. - * Makefile.devel (config.h_vms, lib/config.h_vms): Remove rules. - (include/iconv.h_vms): Remove rule. - (all): Update. - -2006-07-23 Bruno Haible - - * lib/Makefile.in (libiconv.la): Use the CFLAGS during linking. - * src/Makefile.in (iconv_no_i18n): Likewise. - (install): Likewise. - * tests/Makefile.in (table-from, table-to): Likewise. - Needed because the CFLAGS can e.g. trigger profiling. - Reported by Russell Aspinwall . - -2006-07-19 Bruno Haible - - * Version 1.11 released. - -2006-07-19 Bruno Haible - - * srclib/Makefile.am (libicrt_a_SOURCES): Remove error.h, error.c. - (LIBADD_SOURCE): Add them here. - -2006-07-19 Bruno Haible - - * build-aux/config.guess: Update to GNU version 2006-07-02. - * build-aux/config.sub: Likewise. - -2006-07-14 Bruno Haible - - * lib/Makefile.in (clean): Remove also *.stackdump. - * src/Makefile.in (clean): Likewise. - * tests/Makefile.in (clean): Likewise. - -2006-07-14 Bruno Haible - - * src/Makefile.in (clean): Remove also iconv_no_i18n. Needed for - cygwin or mingw. - * tests/Makefile.in (clean): Remove also the programs, without - EXEEXT. Needed for cygwin or mingw. - * Makefile.in (mostlyclean, clean, distclean, maintainer-clean): - Remove also bin directory. Needed for cygwin and mingw. - -2006-07-03 Bruno Haible - - * src/iconv.c (check_subst_formatstring): Use ngettext. - (subst_wc_to_mb_fallback, subst_mb_to_mb_fallback): Fix error messages - after 2006-01-22 change. - * configure.ac: Require a gettext version with ngettext. - -2006-06-28 Bruno Haible - - * m4/gettext.m4: Update from GNU gettext. - * m4/po.m4: Update from GNU gettext. - -2006-06-27 Bruno Haible - - * Makefile.devel (AUTOCONF, AUTOHEADER): Use autoconf-2.60. - * Makefile.in (datarootdir): New variable. - (install, installdirs, uninstall): Also pass datarootdir. - * configure.ac (mandir): Remove customization. - * man/Makefile.in (datarootdir): New variable. - (docdir, htmldir): Use autoconf-substituted value. - * src/Makefile.in (datarootdir): New variable. - (localedir): Use autoconf-substituted value. - -2006-06-27 Bruno Haible - - * m4/stdint.m4: Update from gnulib. - * srclib/stdint_.h: Update from gnulib. - * srclib/Makefile.am: Update. - -2006-06-17 Bruno Haible - - * srclib/unsetenv.c: Update from GNU gettext. - * srclib/xreadlink.c: Likewise. - -2006-06-16 Bruno Haible - - * m4/full-header-path.m4: New file, from gnulib. - * m4/size_max.m4: New file, from gnulib. - * m4/stdint.m4: Update from gnulib. - * srclib/stdint_.h: Update from gnulib. - * srclib/Makefile.am (stdint.h): Likewise. - * Makefile.devel (aclocal.m4): Update dependencies. - -2006-06-16 Bruno Haible - - * m4/ssize_t.m4: Update from GNU gettext. - -2006-06-12 Bruno Haible - - * m4/gettext.m4: Update from GNU gettext. - * m4/inttypes-h.m4: New file, from GNU gettext. - * m4/inttypes.m4: Remove file. - * m4/stdint.m4 (gl_STDINT_H): Update. - * Makefile.devel (aclocal.m4): Update dependencies. - -2006-06-10 Bruno Haible - - * src/iconv.c (error) [NO_I18N]: Define here instead of including - error.h. Fixes link failure introduced on 2006-01-22. - -2006-03-28 Ralf Wildenhues - - * m4/libtool.m4 (_LT_SYS_DYNAMIC_LINKER) [ linux ]: Avoid warning when - "parsing" /etc/ld.so.conf and empty /etc/ld.so.conf.d. - -2006-05-20 Bruno Haible - - * tests/BIG5-HKSCS-1999-snippet: New file. - * tests/BIG5-HKSCS-1999-snippet.UTF-8: New file. - * tests/BIG5-HKSCS-2001-snippet: New file. - * tests/BIG5-HKSCS-2001-snippet.UTF-8: New file. - * tests/BIG5-HKSCS-2004-snippet: New file. - * tests/BIG5-HKSCS-2004-snippet.UTF-8: New file. - * tests/Makefile.in (check): Test also the stateful parts of - BIG5-HKSCS:1999, BIG5-HKSCS:2001, BIG5-HKSCS:2004. - -2006-05-17 Bruno Haible - - Implement newer releases of BIG5-HKSCS. - * tools/Makefile (ALL): Remove hkscs.h, add hkscs1999.h, hkscs2001.h, - hkscs2004.h. - (hkscs.h): Remove rule. - (hkscs1999.h, hkscs2001.h, hkscs2004.h): New rules. - * tools/cjk_tab_to_h.c (output_title): Update year. - (main): Recognize hkscs1999, hkscs2001, hkscs2004. - * lib/encodings.def: Rename BIG5-HKSCS to BIG5-HKSCS:1999. Add - BIG5-HKSCS:2001, BIG5-HKSCS:2004. Make all three stateful. - * lib/hkscs.h: Remove file. - * lib/hkscs1999.h: New file. - * lib/hkscs2001.h: New file. - * lib/hkscs2004.h: New file. - * lib/big5hkscs.h: Remove file. - * lib/big5hkscs1999.h: New file. - * lib/big5hkscs2001.h: New file. - * lib/big5hkscs2004.h: New file. - * lib/converters.h: Include the new files. - * README, man/iconv_open.3: Add BIG5-HKSCS:1999, BIG5-HKSCS:2001. - * tests/BIG5-HKSCS.TXT: Remove file. - * tests/BIG5-HKSCS.IRREVERSIBLE.TXT: Remove file. - * tests/BIG5-HKSCS-1999.TXT: New file. - * tests/BIG5-HKSCS-1999.IRREVERSIBLE.TXT: New file. - * tests/BIG5-HKSCS-2001.TXT: New file. - * tests/BIG5-HKSCS-2001.IRREVERSIBLE.TXT: New file. - * tests/BIG5-HKSCS-2004.TXT: New file. - * tests/BIG5-HKSCS-2004.IRREVERSIBLE.TXT: New file. - * tests/check-stateless: Convert colon in the charset name to a dash in - the file name. - * tests/Makefile.in (check): Check BIG5-HKSCS:1999, BIG5-HKSCS:2001, - BIG5-HKSCS:2004 instead of just BIG5-HKSCS. - * tests/Makefile.msvc (check): Don't check BIG5-HKSCS. - * tests/Makefile.os2 (check): Likewise. - -2006-05-17 Bruno Haible - - * srclib/progreloc.c: Update from GNU gettext. - -2006-05-16 Bruno Haible - - * src/Makefile.in (clean): Use EXEEXT. - * tests/Makefile.in (check, clean): Likewise. - -2006-05-15 Bruno Haible - - * configure.ac: Move some checks before AC_RELOCATABLE. - -2006-05-15 Bruno Haible - - Support for building shared libraries on mingw and Cygwin. - * configure.ac (WOE32DLL, DLL_VARIABLE): New variables. - * include/iconv.h.in (_libiconv_version): Mark as DLL_VARIABLE. - * woe32dll/export.h: New file, from GNU gettext. - * woe32dll/iconv-exports.h: New file. - * Makefile.devel (include/iconv.h_vms, include/iconv.h.msvc-static, - include/iconv.h.msvc-shared): Remove the DLL_VARIABLE annotation. - * lib/Makefile.in (INCLUDES): Add -I for parent directory. - (LDFLAGS): Add WOE32DLL dependent flags. - (LDFLAGS_yes, LDFLAGS_no): New variables. - (OBJECTS): Add WOE32DLL dependent objects. - (OBJECTS_yes, OBJECTS_no): New variables. - (iconv-exports.lo): New rule. - -2006-05-15 Bruno Haible - - * srclib/gettext.h: Update from GNU gettext. - * srclib/pathmax.h: Update from GNU gettext. - * srclib/progreloc.c: Update from GNU gettext. - * srclib/unsetenv.c: Update from GNU gettext. - * srclib/Makefile.am: Add snippet for creation of unistd.h. - * m4/extensions.m4: Update from GNU gettext. - * m4/gettext.m4: Update from GNU gettext. - * m4/lib-ld.m4: Update from GNU gettext. - * m4/lib-link.m4: Update from GNU gettext. - * m4/lib-prefix.m4: Update from GNU gettext. - * m4/longdouble.m4: Update from GNU gettext. - * m4/nls.m4: Update from GNU gettext. - * m4/onceonly.m4: Update from GNU gettext. - * m4/po.m4: Update from GNU gettext. - * m4/relocatable.m4: Update from GNU gettext. - * m4/unistd_h.m4: New file, from GNU gettext. - * Makefile.devel (aclocal.m4): Depend on it. - * configure.ac: Invoke gl_HEADER_UNISTD. - -2006-05-14 Bruno Haible , - Ralf Wildenhues - - * m4/libtool.m4 [ linux ] (AC_LIBTOOL_LANG_CXX_CONFIG) - (AC_LIBTOOL_POSTDEP_PREDEP, AC_LIBTOOL_PROG_COMPILER_PIC) - (AC_LIBTOOL_PROG_LD_SHLIBS): Add support for Sun C 5.9, - Sun C++ 5.9, and Sun Fortran 8.3 on Linux. - -2006-05-06 Charles Wilson - - * m4/libtool.m4: On Cygwin, like on mingw, define DLL_EXPORT when - compiling a shared library object. - -2006-05-15 Bruno Haible - - * build-aux/config.rpath: Add support for Sun C 5.9 on Linux. - -2006-03-31 Juan Manuel Guerrero - - * djgpp/*: Update. - -2006-01-23 Bruno Haible - - * configure.ac: Invoke gl_ALLOCSA. - - * Makefile.devel (aclocal.m4): Depend on $(CONFIGURES_IN). - -2006-01-22 Bruno Haible - - * src/iconv.c (xmalloc, xalloc_die) [NO_I18N]: Define to avoid using - gettext(). - -2006-01-22 Bruno Haible - - * lib/Makefile.in (LIBICONV_VERSION_INFO): Bump to 6:0:4. - -2006-01-22 Bruno Haible - - * src/iconv.c: Include error.h, exit.h. - (print_version): Use EXIT_SUCCESS. - (check_subst_formatstring, subst_mb_to_uc_fallback, - subst_uc_to_mb_fallback, subst_mb_to_wc_fallback, - subst_wc_to_mb_fallback, subst_mb_to_mb_fallback, convert, main): Use - error() instead of fprintf to stderr. - -2006-01-22 Bruno Haible - - New feature: character-dependent substitutions. - * include/iconv.h.in (iconv_unicode_mb_to_uc_fallback, - iconv_unicode_uc_to_mb_fallback, iconv_wchar_mb_to_wc_fallback, - iconv_wchar_wc_to_mb_fallback): New types. - (struct iconv_fallbacks): New structure type. - (ICONV_SET_FALLBACKS): New macro. - * configure.ac: Invoke gt_TYPE_WCHAR_T and substitute HAVE_WCHAR_T. - * Makefile.os2 (all): Also substitute @HAVE_WCHAR_T@ in build/iconv.h. - * Makefile.devel (include/iconv.h_vms, include/iconv.h.msvc-static, - include/iconv.h.msvc-shared): Also substitute @HAVE_WCHAR_T@. - * lib/converters.h (struct conv_struct): Add field 'fallbacks'. - * lib/loop_unicode.h (struct uc_to_mb_fallback_locals): New type. - (uc_to_mb_write_replacement): New function. - (struct mb_to_uc_fallback_locals): New type. - (mb_to_uc_write_replacement): New function. - (unicode_loop_convert): Call mb_to_uc_fallback and uc_to_mb_fallback. - (unicode_loop_reset): Call uc_to_mb_fallback. - * lib/loop_wchar.h (struct wc_to_mb_fallback_locals): New type. - (wc_to_mb_write_replacement): New function. - (wchar_from_loop_convert): Call wc_to_mb_fallback. - (struct mb_to_wc_fallback_locals): New type. - (mb_to_wc_write_replacement): New function. - (wchar_to_loop_convert): Call mb_to_wc_fallback. - * lib/iconv.c (iconv_open): Initialize the 'fallbacks' field. - (iconvctl): Handle ICONV_SET_FALLBACKS. - * lib/genflags.c (struct iconv_fallbacks): New dummy definition. - * src/iconv.c: Include limits.h. - (isdigit, c_isprint): New macros. - (usage): Document long options and new options. - (check_subst_formatstring): New function. - (ilseq_byte_subst, ilseq_wchar_subst, ilseq_unicode_subst): New - variables. - (ilseq_byte_subst_size, ilseq_wchar_subst_size, - ilseq_unicode_subst_size): New variables. - (ilseq_byte_subst_buffer, ilseq_wchar_subst_buffer, - ilseq_unicode_subst_buffer): New variables. - (subst_mb_to_uc_cd, subst_mb_to_uc_temp_buffer): New variables. - (subst_mb_to_uc_fallback): New function. - (subst_uc_to_mb_cd, subst_uc_to_mb_temp_buffer): New variables. - (subst_uc_to_mb_fallback): New function. - (subst_mb_to_wc_cd, subst_mb_to_wc_temp_buffer): New variables. - (subst_mb_to_wc_fallback): New function. - (subst_wc_to_mb_cd, subst_wc_to_mb_temp_buffer): New variables. - (subst_wc_to_mb_fallback): New function. - (subst_mb_to_mb_cd, subst_mb_to_mb_temp_buffer): New variables. - (subst_mb_to_mb_fallback): New function. - (convert): Enlarge the outbuf when the conversion failed with E2BIG. - (main): Handle new options --byte-subst, --widechar-subst, - --unicode-subst. - * man/iconv.1: Document --unicode-subst, --byte-subst, --widechar-subst - options. - * tests/check-subst: New file. - * tests/Makefile.in (check): Also invoke check-subst. - Suggested by James Taylor . - -2006-01-21 Bruno Haible - - * src/iconv.c (print_version): Bump copyright year. - (main): Accept long options --from-code, --to-code, --list, --silent. - Accept abbreviated long options, like getopt() does. - * man/iconv.1: Document long options. - -2005-12-29 Bruno Haible - - * src/iconv.c (print_version): Update copyright year. - -2005-12-29 Bruno Haible - - * configure.ac: Renamed from configure.in. - * Makefile.devel (CONFIGURES_IN, configure, config.h.in): Update. - -2005-12-29 Bruno Haible - - * configure.in: Bump version number. - * include/iconv.h.in (_LIBICONV_VERSION): Likewise. - * windows/iconv.rc: Likewise. - * lib/Makefile.in (LIBICONV_VERSION_INFO): Bump to 5:1:3. - -2005-12-29 Bruno Haible - - * build-aux/config.guess: Update to GNU version 2005-12-23. - * build-aux/config.sub: Likewise. - * build-aux/config.libpath: Update from GNU gettext. - * build-aux/install-sh: Upgrade to automake-1.9.5. - * build-aux/missing: Upgrade to automake-1.9.5. - * build-aux/mkinstalldirs: Upgrade to automake-1.9.5. - -2005-12-29 Bruno Haible - - * m4/alloca.m4: Update from GNU gettext. - * m4/allocsa.m4: Update from GNU gettext. - * m4/canonicalize.m4: Update from GNU gettext. - * m4/codeset.m4: Update from GNU gettext. - * m4/eealloc.m4: Update from GNU gettext. - * m4/error.m4: Update from GNU gettext. - * m4/extensions.m4: Update from GNU gettext. - * m4/gettext.m4: Update from GNU gettext. - * m4/glibc21.m4: Update from GNU gettext. - * m4/iconv.m4: Update from GNU gettext. - * m4/intmax.m4: Update from GNU gettext. - * m4/inttypes_h.m4: New file, from GNU gettext. - * m4/isc-posix.m4: Update from GNU gettext. - * m4/lcmessage.m4: Update from GNU gettext. - * m4/longdouble.m4: Update from GNU gettext. - * m4/longlong.m4: Update from GNU gettext. - * m4/mbstate_t.m4: Update from GNU gettext. - * m4/nls.m4: Update from GNU gettext. - * m4/onceonly.m4: Update from GNU gettext. - * m4/pathmax.m4: Update from GNU gettext. - * m4/po.m4: Update from GNU gettext. - * m4/printf-posix.m4: Update from GNU gettext. - * m4/progtest.m4: Update from GNU gettext. - * m4/readlink.m4: Update from GNU gettext. - * m4/relocatable.m4: Update from GNU gettext. - * m4/setenv.m4: Update from GNU gettext. - * m4/signed.m4: Update from GNU gettext. - * m4/ssize_t.m4: Update from GNU gettext. - * m4/stdbool.m4: Update from GNU gettext. - * m4/stdint_h.m4: New file, from GNU gettext. - * m4/strerror.m4: Update from GNU gettext. - * m4/strerror_r.m4: Update from GNU gettext. - * m4/unlocked-io.m4: Update from GNU gettext. - * m4/wchar_t.m4: Update from GNU gettext. - * m4/wint_t.m4: Update from GNU gettext. - * m4/xreadlink.m4: Update from GNU gettext. - * Makefile.devel (aclocal.m4): Depend on m4/inttypes_h.m4 and - m4/stdint_h.m4 as well. - * configure.in: Invoke AC_TYPE_MBSTATE_T instead of AC_MBSTATE_T. - Invoke gl_FUNC_GLIBC_UNLOCKED_IO instead of jm_FUNC_GLIBC_UNLOCKED_IO. - Invoke gl_ERROR instead of gt_FUNC_ERROR_AT_LINE. - Don't invoke AC_AIX and AC_MINIX, done by gl_USE_SYSTEM_EXTENSIONS. - Temporarily redefine AC_LIBOBJ and AC_REPLACE_FUNCS, so as to fill - SRCLIBOBJS instead of LIBOBJS. - * srclib/alloca_.h: Update from GNU gettext. - * srclib/allocsa.h: Update from GNU gettext. - * srclib/canonicalize.c: Update from GNU gettext. - * srclib/error.h: Update from GNU gettext. - * srclib/error.c: Update from GNU gettext. - * srclib/gettext.h: Update from GNU gettext. - * srclib/memmove.c: Update from GNU gettext. - * srclib/progname.h: Update from GNU gettext. - * srclib/progname.c: Update from GNU gettext. - * srclib/progreloc.c: Update from GNU gettext. - * srclib/readlink.c: Update from GNU gettext. - * srclib/relocatable.c: Update from GNU gettext. - * srclib/relocwrapper.c: Update from GNU gettext. - * srclib/setenv.h: Update from GNU gettext. - * srclib/setenv.c: Update from GNU gettext. - * srclib/stdbool_.h: Update from GNU gettext. - * srclib/stdint_.h: Update from gnulib. - * srclib/strerror.c: Update from GNU gettext. - * srclib/unlocked-io.h: Update from GNU gettext. - * srclib/unsetenv.c: Update from GNU gettext. - * srclib/xalloc.h: Update from GNU gettext. - * srclib/xmalloc.c: Update from GNU gettext. - * srclib/xreadlink.c: Update from GNU gettext. - * srclib/xstrdup.c: Update from GNU gettext. - * srclib/Makefile.am (DEFS): Also define EXEEXT. - (libicrt_a_LIBADD): Use SRCLIBOBJS instead of LIBOBJS. - (libicrt_a_DEPENDENCIES): New variable. - * src/Makefile.in (EXEEXT): New variable. - * build-aux/install-reloc: Update from GNU gettext. - * build-aux/reloc-ldflags: Update from GNU gettext. - * build-aux/config.rpath: Update from GNU gettext. - -2005-12-29 Bruno Haible - - * m4/libtool.m4: Update, based on libtool-1.5.22. - * build-aux/ltmain.sh: Update, based on libtool-1.5.22. - -2005-12-24 Bruno Haible - - Check the whole range of GB18030. - * tests/GB18030-BMP.TXT: Renamed from tests/GB18030.TXT. - * tests/gengb18030z.c: New file. - * tests/table-from.c (main): For GB18030, don't stop at U+10000. - * tests/table-to.c (main): Likewise. - * tests/Makefile.in (check): Generate GB18030.TXT on the fly from - GB18030-BMP.TXT. - (clean): Remove also gengb18030z and GB18030.TXT. - * tests/Makefile.msvc (check): Generate GB18030.TXT on the fly from - GB18030-BMP.TXT. - (clean): Remove also GB18030Z.TXT, GB18030TMP.TXT, GB18030.TXT. - * tests/Makefile.os2 (check): Depend on gengb18030z.exe. Generate - GB18030.TXT on the fly from GB18030-BMP.TXT. - (clean): Remove also GB18030Z.TXT, GB18030TMP.TXT, GB18030.TXT. - -2005-12-20 Bruno Haible - - * tests/table-to.c (main): Test the mappings up to U+10FFFF, not only - up to U+2FFFF. Tolerate that Unicode language tags are silently mapped - to nothing. - -2005-12-22 Bruno Haible - - Extend GB18030 converter to cover the entire Unicode PUA. - * lib/gb18030.h: Update comments, based on second printing. - (gb18030_mbtowc): Add mapping for range U+E000..U+E765. - (gb18030_pua2charset): New array. - (gb18030_wctomb): Add mapping for range U+E000..U+E765 and the two-byte - part of range U+E766..U+E864. - * lib/gb18030ext.h (gb18030ext_2uni_pagefe): Add mappings to private - area. - (gb18030ext_mbtowc): Add mapping for the two-byte part of range - U+E766..U+E864. - * lib/gb18030uni.h (gb18030uni_charset2uni_ranges, - gb18030uni_uni2charset_ranges, gb18030uni_ranges): Add 12 more - intervals. - (gb18030uni_mbtowc, gb18030uni_wctomb): Update. - * tests/GB18030.TXT: Complete mappings to private area. - -2005-12-22 Bruno Haible - - * lib/gbk.h: Update comments. - -2005-12-20 Bruno Haible - - Add private area mappings to CP949. - * lib/cp949.h (cp949_mbtowc, cp949_wctomb): Map U+E000..U+E0BB like - many others do it. - * tests/CP949.TXT: Add mappings for U+E000..U+E0BB. - -2005-12-15 Bruno Haible - - Add private area mappings to CP950. - * lib/cp950.h (cp950_mbtowc, cp950_wctomb): Map U+E000..U+F6B0 like - most others do it. - * tests/CP950.TXT: Add mappings for U+E000..U+F6B0. - -2005-12-15 Bruno Haible - - Make CP936 follow what Microsoft does. - In http://www.microsoft.com/globaldev/reference/dbcs/936.mspx they - added a 0x80 - U+20AC mapping to the code chart, but not to the - tooltips and not to the list of mappings. - * lib/cp936.h: New file. - * lib/gbk.h: Update comments. - * lib/ces_gbk.h: Update comments. - * lib/converters.h: Include cp936.h. - * lib/encodings.def (CP936): New encoding. - (GBK): Remove CP936 aliases. - * README, man/iconv_open.3: Add CP936. - * tests/Makefile.in (check): Check CP936. - * tests/Makefile.msvc (check): Likewise. - * tests/Makefile.os2 (check): Likewise. - * tests/CP936.TXT: New file. - -2005-12-14 Bruno Haible - - * lib/cp932.h (cp932_wctomb): Map U+FF5E, U+2225, U+FF0D, U+FFE0, - U+FFE1 like Microsoft does it. - * lib/CP932.IRREVERSIBLE.TXT: Add these mappings. - Reported by Lei Wang . - -2005-12-14 Bruno Haible - - Follow Euro sign addition done in 1999 in - http://www.microsoft.com/globaldev/reference/dbcs/950/950_A3.mspx - * lib/cp950.h (cp950_mbtowc, cp950_wctomb): Add mapping for 0xA3E1. - * tests/CP950.TXT: Add mapping for 0xA3E1. - -2005-11-11 Bruno Haible - - * lib/euc_jp.h (euc_jp_wctomb): When writing a 3-bytes byte sequence - and only two bytes are available in the output buffer, return - RET_TOOSMALL instead of overrunning the output buffer. - * lib/isoir165.h (isoir165_wctomb): When only one byte is available - in the output buffer, don't overrun the output buffer. - Reported by William Bardwell . - -2005-09-18 Bruno Haible - - * m4/libtool.m4: Update, based on libtool-1.5.20. - * build-aux/ltmain.sh: Update, based on libtool-1.5.20. - -2005-08-12 Bruno Haible - - * lib/big5_2003.h: Map 0xF9FA..0xF9FD differently. - * tests/BIG5-2003.TXT: Likewise. - * tests/BIG5-2003.IRREVERSIBLE.TXT: New file. - Reported by Ping Yeh . - -2005-07-24 Bruno Haible - - Tidy up exported symbols. - * m4/visibility.m4: New file. - * include/export.h: New file. - * configure.in: Invoke gl_VISIBILITY. Use AC_CONFIG_FILES. Arrange to - create also include/iconv.h.inst. - * Makefile.devel (all): Depend on include/iconv.h.build.in. - (aclocal.m4): Depend on m4/visibility.m4. - (include/iconv.h.build.in): New rule. - * Makefile.in (install-lib, install): Install include/iconv.h.inst, - not the include/iconv.h that was used for building. - (distclean, maintainer-clean): Remove also include/iconv.h.inst. - * lib/Makefile.in (CFLAGS): Add @CFLAG_VISIBILITY@. - (DEFS): Also define BUILDING_LIBICONV and BUILDING_DLL. - * lib/config.h.in (HAVE_VISIBILITY): New macro. - * lib/relocatable.h (RELOCATABLE_DLL_EXPORTED) [HAVE_VISIBILITY]: - Define to the gcc visibility attribute. - * srclib/relocatable.h (RELOCATABLE_DLL_EXPORTED) [HAVE_VISIBILITY]: - Likewise. - -2005-07-25 Bruno Haible - - 2003-08-24 Bruno Haible - * lib/relocatable.h: Make this file includable in C++ mode: add extern - "C". - -2005-07-08 Bruno Haible - - * Version 1.10 released. - -2005-07-08 Bruno Haible - - * m4/libtool.m4 (postinstall_cmds) [cygwin,mingw,pw32]: Make DLL - executable after installing it. - -2005-07-08 Bruno Haible - - * configure.in: Bump version number. - * include/iconv.h.in (_LIBICONV_VERSION): Likewise. - * windows/iconv.rc: Likewise. - * lib/Makefile.in (LIBICONV_VERSION_INFO): Bump to 5:0:3. - -2005-07-05 Bruno Haible - - * Makefile.devel (ACLOCAL): New variable. - (aclocal.m4): Use it. - -2005-07-05 Bruno Haible - - * m4/relocatable.m4 (AC_RELOCATABLE): On mingw, simply set - SET_RELOCATABLE to a trivial value. - -2004-08-08 Bruno Haible - - * srclib/progreloc.c (xstrdup): Define as strdup if no xmalloc should - be used. - -2004-04-28 Bruno Haible - - * srclib/progreloc.c (ISSLASH, IS_PATH_WITH_DIR, FILESYSTEM_PREFIX_LEN): - Treat Cygwin like Windows, since it now accepts Windows pathnames. - -2005-06-09 Bruno Haible - - * Makefile.in (mkinstalldirs): Use build-aux/ instead of autoconf/. - * lib/Makefile.in (mkinstalldirs): Likewise. - * src/Makefile.in (mkinstalldirs): Likewise. - * man/Makefile.in (mkinstalldirs): Likewise. - -2005-06-08 Bruno Haible - - * srclib/canonicalize.c (__realpath): Avoid gcc warnings on platforms - that don't support symbolic links. - -2005-06-08 Bruno Haible - - * srclib/binary-io.h (fileno): Undefine before defining it. Avoids a - gcc warning on mingw. - -2005-05-22 Bruno Haible - - Implement and document BIG5-2003. - * lib/big5_2003.h: New file. - * lib/converters.h: Include it. - * lib/encodings_extra.def (BIG5-2003): New encoding. - * README, man/iconv_open.3: Add BIG5-2003. - * tests/Makefile.in (check-extra-yes): Check BIG5-2003. - * tests/BIG5-2003.TXT: New file. - -2005-05-21 Bruno Haible - - Add EURO SIGN to EUC-TW converter. - * lib/cns11643_1.h (cns11643_1_2uni_page42): Add entry for 0x14242. - (cns11643_1_mbtowc): Update. - * lib/cns11643_inv.h (cns11643_inv_2charset): Add entry for 0x20AC. - (cns11643_inv_uni2indx_page*): Update. - * lib/dec_hanyu.h (dec_hanyu_mbtowc, dec_hanyu_wctomb): Consider only - part of row 42. - * tests/EUC-TW.TXT: Add entry for 0x20AC. - * tests/EUC-TW.IRREVERSIBLE.TXT: Likewise. - -2005-05-03 Bruno Haible - - * tools/Makefile (ALL): Add pt154.h. - (pt154.h): New rule. - * lib/encodings.def: Add PT154. - * lib/pt154.h: New file. - * lib/converters.h: Include it. - * README, man/iconv_open.3: Add PT154. - * NOTES: Mention PT154. - * tests/PT154.TXT: New file. - * tests/Makefile.in (check): Also test PT154. - * tests/Makefile.msvc (check): Likewise. - * tests/Makefile.os2 (check): Likewise. - -2005-03-29 Bruno Haible - - Rename libiconv_plug.so to preloadable_libiconv.so. - * configure.in (PLUGLIB): Set to preloadable_libiconv.so instead of - libiconv_plug.so. - * lib/Makefile.in (preloadable_libiconv.so): Renamed from - libiconv_plug.so. - (preloadable_libiconv_linux.so): Renamed from libiconv_plug_linux.so. - (preloadable_libiconv_solaris.so): Renamed from - libiconv_plug_solaris.so. - (preloadable_libiconv_osf.so): Renamed from libiconv_plug_osf.so. - (clean): Update. - * README: Update. - -2005-03-29 Bruno Haible - - Implement and document ATARIST. - * tools/Makefile (ALL): Add atarist.h. - (atarist.h): New rule. - * lib/atarist.h: New file. - * lib/converters.h: Include it. - * lib/encodings_extra.def (ATARIST): New encoding. - * README, man/iconv_open.3: Add ATARIST. - * tests/Makefile.in (check-extra-yes): Check ATARIST. - * tests/ATARIST.TXT: New file. - -2005-03-22 Bruno Haible - - * build-aux: New directory, renamed from autoconf. - * configure.in (AC_CONFIG_AUX_DIR): Use build-aux. - -2005-03-16 Bruno Haible - - * m4/stdint.m4 (gl_STDINT_H): Define HAVE_LONG_LONG_64BIT instead of - HAVE_LONGLONG_64BIT. - * srclib/stdint_.h: Use HAVE_LONG_LONG_64BIT instead of - HAVE_LONGLONG_64BIT. - * srclib/Makefile.am (stdint.h): Likewise. - -2005-03-14 Bruno Haible - - * Makefile.devel (aclocal.m4): Depend also on allocsa.m4, eealloc.m4, - extensions.m4, intmax.m4, inttypes.m4, longdouble.m4, longlong.m4, - printf-posix.m4, readlink.m4, signed.m4, ssize_t.m4, stdint.m4, - wchar_t.m4, wint_t.m4. - -2005-03-13 Bruno Haible - - Make stdout error checking reliable, also when writing to a NFS file. - * src/iconv.c (main): Check the return value of fclose(stdout). - * lib/genaliases.c (main): Likewise. - * lib/genaliases2.c (main): Likewise. - * lib/genflags.c (main): Likewise. - * lib/gentranslit.c (main): Likewise. - * tests/genutf8.c (main): Likewise. - * tests/table-from.c (main): Likewise. - * tests/table-to.c (main): Likewise. - -2005-03-13 Bruno Haible - - * src/iconv.c (convert): Before outputting an error message, flush - stdout and output a newline if suitable. - -2005-03-13 Bruno Haible - - Improved error messages. - * srclib/width.c: New file, from GNU clisp. - * srclib/uniwidth.h: New file, from GNU clisp with modifications. - * srclib/unitypes.h: New file, from GNU clisp with modifications. - * srclib/cjk.h: New file, from GNU clisp. - * srclib/streq.h: New file, from GNU clisp. - * srclib/stdint_.h: New file, from gnulib. - * m4/stdint.m4: New file, from gnulib. - * m4/inttypes.m4: New file, from gnulib. - * srclib/Makefile.am: Add gnulib module 'stdint' snippet. - (BUILT_SOURCES): New variable. - (libicrt_a_SOURCES): Add width.c, uniwidth.h, unitypes.h, cjk.h, - streq.h. - * configure.in: Invoke gl_STDINT_H. - * src/iconv.c: Include cjk.h, uniwidth.h. - (line, column, cjkcode): New variables. - (update_line_column): New function. - (convert): Initialize line and column. In all error message, show also - the line and column number. - (main): Initialize cjkcode. Set up hooks to call update_line_column. - -2005-03-13 Bruno Haible - - * include/iconv.h.in (iconv_canonicalize): New declaration. - * lib/genaliases.c (emit_encoding): Take two output streams as - arguments. To the second stream, emit a shell command for extracting - offsets into the gperf generated string pool. - (main): Write the shell commands into file descriptors 3 and 4. - * lib/genaliases2.c (emit_encoding): Take two output streams as - arguments. To the second stream, emit an expression for the offset - into the string pool. - (main): Write the offsets into file descriptor 3. - * Makefile.devel (lib/aliases.gperf): Remove target. - (lib/aliases.h): Generate lib/aliases.gperf temporarily. Generate also - lib/canonical.h and lib/canonical_local.h. - (lib/aliases_aix.h): Generate also lib/canonical_aix.h. - (lib/aliases_osf1.h): Generate also lib/canonical_osf1.h. - (lib/aliases_dos.h): Generate also lib/canonical_dos.h. - (lib/aliases_extra.h): Generate also lib/canonical_extra.h. - * lib/iconv.c (stringpool2): Provide default definition when it doesn't - exist. - (all_canonical): New array. - (iconv_canonicalize): New function. - -2005-03-13 Bruno Haible - - * include/iconv.h.in (iconv_unicode_char_hook, iconv_wide_char_hook, - iconv_hooks): New types. - (ICONV_SET_HOOKS): New macro. - * lib/converters.h (struct conv_struct): Add field 'hooks'. - * lib/iconv.c (iconv_open): Initialize hooks to NULL. - (iconvctl): Handle ICONV_SET_HOOKS. - * lib/loop_unicode.h (unicode_loop_convert, unicode_loop_reset): After - conversion of a character, call the uc_hook. - * lib/loop_wchar.h (wchar_id_loop_convert): After every character, call - the wc_hook. - * lib/genflags.c (iconv_hooks): Provide a dummy definition. - -2005-02-05 Bruno Haible - - * src/iconv.c (main): In case of unsupported encodings, show a hint - towards "iconv -l". - -2005-01-06 Bruno Haible - - * lib/Makefile.msvc (CFLAGS): Define also INSTALLPREFIX. - * lib/Makefile.vms (DEFS): Likewise. - Reported by Troels Walsted Hansen . - -2005-01-05 Bruno Haible - - * autoconf/config.rpath: Update from GNU gettext. - -2005-01-05 Bruno Haible - - Assume automake-1.9. - * Makefile.devel (AUTOMAKE): Assume automake-1.9. - -2005-01-05 Bruno Haible - - * m4/libtool.m4: Update from GNU gettext, based on libtool-1.5.10. - * autoconf/ltmain.sh: Update from GNU gettext, based on libtool-1.5.10. - -2004-11-11 Bruno Haible - - * lib/iconv.c (iconv_open): Accept the suffixes //TRANSLIT and //IGNORE - in arbitrary order. - Reported by Lukas Gebauer . - -2004-09-21 Juan Manuel Guerrero - - * djgpp/config.bat: Update. - * djgpp/config.sed: Update. - * djgpp/config.site: Update. - * djgpp/edtest.bat: Update. - * djgpp/fnchange.in: Update. - * djgpp/Makefile.maint: Update. - * djgpp/makefile.sed: Update. - * djgpp/README.in: Update. - * djgpp/sources.sed: Update. - * djgpp/translit-check.sed: Update. - -2004-08-25 Bruno Haible - - * m4/libtool.m4: Update from GNU gettext, based on libtool-1.5.6. - * autoconf/ltmain.sh: Update from GNU gettext, based on libtool-1.5.6. - -2004-07-31 Bruno Haible - - Update to JISX 0213 plane 1 to 2004 version (ISO-IR-233). - * tools/Makefile (jisx0213.h): Bump version number. - * tools/JISX0213.TXT: Change mappings U+2015 -> U+2014, - U+2299 -> U+29BF, and add 10 new characters. - * tools/cjk_tab_to_h.c (output_title): Bump year. - (do_jisx0213): Update comments. Emit a conditional 'inline'. - * lib/jisx0213.h: Regenerated. - * lib/iso2022_jp3.h (iso2022_jp3_mbtowc): Accept escape sequence - ESC $ ( Q as a synonym of ESC $ ( O. - (iso2022_jp3_wctomb): Emit ESC $ ( Q instead of ESC $ ( O. - * tests/EUC-JISX0213.TXT: Change mappings U+2015 -> U+2014, - U+2299 -> U+29BF, and add 10 new characters. - * tests/SHIFT_JISX0213.TXT: Likewise. - * tests/ISO-2022-JP-3-snippet: Update. - * tests/ISO-2022-JP-3-snippet.UTF-8: Update. - -2004-07-22 Bruno Haible - - * lib/encodings.def (ISO-8859-7): Add alias ISO_8859-7:2003. - * tools/Makefile (iso8859_7.h): Use conversion table from 2003. - * lib/iso8859_7.h: Add mappings for 0xa4, 0xa5, 0xaa. - * tests/ISO-8859-7.TXT: Update to ISO_8859-7:2003. - -2004-07-22 Bruno Haible - - * tools/Makefile (ALL): Add iso8859_11.h. - (iso8859_11.h): New rule. - * lib/encodings.def: Add ISO-8859-11. - * lib/iso8859_11.h: New file. - * lib/converters.h: Include it. - * tests/ISO-8859-11.TXT: New file. - * tests/Makefile.in (check): Also test ISO-8859-11. - * tests/Makefile.msvc (check): Likewise. - * tests/Makefile.os2 (check): Likewise. - -2004-07-17 Bruno Haible - - * src/iconv.c (main): Terminate option parsing when option -- is seen. - Reported by Len Lattanzi . - -2004-03-05 Bruno Haible - - * src/Makefile.in (install): Make DESTDIR work on HP-UX. - Reported by Bob Proulx . - -2004-02-19 Bruno Haible - - * lib/vietcomb.h (viet_comp_table_data): Un-uncomment 0x00D5, 0x00F5, - 0x0168, 0x0169. Needed for TCVN-5712 but not for CP1258. - (viet_comp_table0301_len): Increment by 4. - - * lib/cp1255.h (cp1255_mbtowc): Don't delay the handling of characters - which are not entries in cp1255_comp_table_data. - * lib/cp1258.h (cp1258_comp_bases): New array. - (cp1258_mbtowc): Don't delay the handling of characters which are not - relevant entries in viet_comp_table_data. - * lib/tcvn.h (tcvn_comp_bases): New array. - (tcvn_mbtowc): Don't delay the handling of characters which are not - relevant entries in viet_comp_table_data. - Reported by Alain Bench . - -2004-02-02 Perry Rapp - Bruno Haible - - * man/iconvctl.3: New file. - * man/iconv.3: Refer to it in "See also". - * man/iconv_open.3: Likewise. - -2004-01-24 Bruno Haible - - * srclib/progreloc.c (xstrdup): Define as strdup if no xmalloc should - be used. - -2004-01-20 Bruno Haible - - Upgrade from gettext-0.14. - - * configure.in: Call gl_USE_SYSTEM_EXTENSIONS. Call AM_STDBOOL_H - instead of gt_STDBOOL_H. Provide a definition for DLL_VARIABLE. - * srclib/Makefile.am (libicrt_a_SOURCES): Add allocsa.h, allocsa.c, - xalloc.h. Remove xmalloc.h. - (libicrt_a_LIBADD): Remove @ALLOCA@. - * srclib/Makefile.msvc (OBJECTS): Add allocsa.obj. - (allocsa.obj): New rule. - * srclib/Makefile.vms (OBJECTS): Add allocsa.obj. - (allocsa.obj): New rule. - * Makefile.devel (config.h_vms): Set MALLOC_0_IS_NONNULL to 0. - (config.h.msvc): Set MALLOC_0_IS_NONNULL to 1. - - lib/: - - 2003-10-09 Bruno Haible - * lib/relocatable.c: Include xalloc.h instead of xmalloc.h. - - 2003-08-01 Bruno Haible - * lib/relocatable.c (find_shared_library_fullname): Disable the code on - Linux/libc5. Reported by Alain Guibert . - - 2003-06-22 Bruno Haible - * lib/relocatable.c (compute_curr_prefix): Comment out this function in - the case when it is not used. - Reported by Pavel Roskin . - - m4/: - - * m4/gettext.m4: Upgrade from GNU gettext. Many changes. - * m4/po.m4: Likewise. - - * m4/readlink.m4: New file, from GNU gettext. - - 2003-11-30 Bruno Haible - * m4/allocsa.m4: New file. - * m4/eealloc.m4: New file. - * m4/setenv.m4 (gl_PREREQ_SETENV): Require gl_ALLOCSA instead of - AC_FUNC_ALLOCA. - - 2003-10-21 Bruno Haible - * m4/canonicalize.m4 (gl_PREREQ_CANONICALIZE): Also test for - readlink(). - - 2003-08-24 Bruno Haible - * m4/relocatable.m4 (AC_RELOCATABLE): Use $(host) instead of @host@, - since the substitution of @host@ may occur before the substitution of - @SET_RELOCATABLE@. - - 2003-08-23 Bruno Haible - * stdbool.m4: Replace with the version from gnulib, without - AC_HEADER_STDBOOL. - - 2003-08-08 Paul Eggert - * m4/extensions.m4: New file. - * m4/unlocked-io.m4 (jm_FUNC_GLIBC_UNLOCKED_IO): - Require gl_USE_SYSTEM_EXTENSIONS rather than AC_GNU_SOURCE. - - 2003-07-01 Bruno Haible - * m4/ssize_t.m4 (gt_TYPE_SSIZE_T): Don't include . - should be sufficient. - Reported by Paul Eggert. - - 2003-07-01 Bruno Haible - * m4/lib-prefix.m4 (AC_LIB_ARG_WITH): Avoid "duplicated macro" error - from aclocal-1.4-p4. - Reported by Luke Schierer and - Michael C. Toren . - - 2003-07-01 Paul Eggert - * m4/xreadlink.m4 (gl_XREADLINK): Don't check for sys/types.h, since - xreadlink.c now includes it unconditionally. - - 2003-06-17 Paul Eggert - * m4/lib-ld.m4 (AC_LIB_PROG_LD_GNU, AC_LIB_PROG_LD): Don't use egrep, - for portability to POSIX 1003.1-2001. Backported from libtool-1.5. - - 2003-05-28 Paul Eggert - * m4/pathmax.m4 (gl_PATHMAX): Don't check for limits.h. - * m4/xreadlink.m4 (gl_XREADLINK): Likewise. - - 2002-12-24 Bruno Haible - * m4/setenv.m4 (gt_FUNC_SETENV): New macro. - (gt_CHECK_VAR_DECL): Fix quoting error that led to infinite loop in m4 - when invoked twice. - (gt_PREREQ_SETENV, gt_PREREQ_UNSETENV): New macros, replacing old - gt_FUNC_SETENV. - - srclib/: - - 2003-11-30 Bruno Haible - * srclib/alloca.c: Remove file. - - 2003-11-30 Bruno Haible - Safer stack allocation. - * srclib/allocsa.h: New file. - * srclib/allocsa.c: New file. - * canonicalize.c: Include allocsa.h. - (__realpath): Use allocsa instead of alloca. Don't clobber errno right - before returning NULL. - * srclib/relocwrapper.c: Indirectly depends on allocsa. - * srclib/setenv.c: Include allocsa.h. - (alloca): Remove fallback definition. - (freea): Remove macro. - (__add_to_environ) [!_LIBC]: Use allocsa instead of alloca. Use freesa - instead of freea. - - 2003-11-17 Bruno Haible - * srclib/canonicalize.c: #undef realpath after but before - the system includes, so as to avoid a prototype clash on Solaris 2.5.1. - Reported by Warren L. Dodge . - - 2003-10-21 Bruno Haible - * srclib/canonicalize.c (lstat): Define as an alias to 'stat' on - systems without symbolic links. - - 2003-10-17 Bruno Haible - * srclib/binary-io.h: Avoid warnings on Cygwin. - - 2003-10-09 Bruno Haible - * srclib/xalloc.h: Renamed from xmalloc.h. - * srclib/progreloc.c: Include xalloc.h instead of xmalloc.h. - * srclib/relocatable.c: Likewise. - * srclib/xmalloc.c: Likewise. - * srclib/xreadlink.c: Likewise. - * srclib/xstrdup.c: Likewise. - - 2003-09-12 Paul Eggert - * srclib/progreloc.c (get_full_program_name): Define via prototype. - - 2003-09-12 Paul Eggert - * srclib/setenv.c (clearenv): Define via prototype. - - 2003-09-10 Bruno Haible - * srclib/setenv.c: Include and unconditionally. - * srclib/unsetenv.c: Likewise. - - 2003-08-28 Bruno Haible - * srclib/binary-io.h: Undefine O_BINARY before defining it. This avoids - a warning on QNX, which defines O_BINARY to 000000. - - 2003-08-24 Bruno Haible - * srclib/binary-io.h: Include , to avoid a compilation error - when MSVC7 is included later. - - 2003-08-24 Bruno Haible - * srclib/error.h: Use ANSI C "..." declarations when compiling with - MSVC, even though it doesn't define __STDC__ by default. - * srclib/error.c: Use when compiling with MSVC, even though - it doesn't define __STDC__ by default. - - 2003-08-24 Bruno Haible - Support for building DLLs on Windows. - * srclib/error.h (error_print_progname, error_message_count, - error_one_per_line): Add DLL_VARIABLE attribute. - * srclib/progname.h (program_name): Likewise. - - 2003-08-24 Bruno Haible - * srclib/progname.h: Make this file includable in C++ mode: add extern - "C". - * srclib/relocatable.h: Likewise. - * srclib/xmalloc.h: Likewise. - - 2003-08-22 Bruno Haible - * srclib/progname.h (error_with_progname, maybe_print_progname): Remove - declarations. - * srclib/progname.c (error_with_progname): Remove variable. - (maybe_print_progname): Remove function. - - 2003-08-01 Bruno Haible - * srclib/relocatable.c (find_shared_library_fullname): Disable the code - on Linux/libc5. Reported by Alain Guibert . - - 2003-07-01 Paul Eggert - * srclib/xreadlink.c: Include unconditionally, instead of - having it depend on HAVE_SYS_TYPES_H. - - 2003-06-23 Bruno Haible - Avoid compilation units that are empty after preprocessing. - * srclib/canonicalize.c: Add dummy declaration. - * srclib/strerror.c: Likewise. - * srclib/error.c: Include even if there's nothing to be - compiled. - - 2003-06-22 Bruno Haible - * srclib/relocatable.c (compute_curr_prefix): Comment out this function - in the case when it is not used. - Reported by Pavel Roskin . - - 2003-05-28 Paul Eggert - * srclib/pathmax.h: Include without checking for - HAVE_LIMITS_H. - * srclib/xreadlink.c: Likewise. - -2004-01-20 Bruno Haible - - Assume automake-1.8. - * Makefile.devel (AUTOCONF, AUTOHEADER): Assume autoconf-2.59. - (AUTOMAKE): Assume automake-1.8. - * Makefile.in (am--refresh): New target. - -2004-01-23 Bruno Haible - - * Version 1.9.2 released. - -2004-01-23 Bruno Haible - - * tests/table-from.c: Include binary-io.h. - (main): Switch stdout to binary mode. - * tests/table-to.c: Include binary-io.h. - (main): Switch stdout to binary mode. - * tests/genutf8.c: Include binary-io.h. - (main): Switch stdout to binary mode. - * tests/Makefile.in (INCLUDES): Also look in srclib. - (check): Pass INCLUDES when compiling genutf8.c. - * tests/Makefile.os2 (INCLUDES): Also look in srclib. - (genutf8.exe): Pass INCLUDES when compiling genutf8.c. - * tests/Makefile.msvc (INCLUDES): Also look in srclib. - (check): Pass INCLUDES when compiling genutf8.c. - -2004-01-21 Bruno Haible - - * src/iconv.c (force_binary): Remove variable. - (usage): Don't document --binary any more. - (convert, main): Always switch to binary mode. - * tests/check-stateful.bat: Remove --binary option. - * tests/check-translit.bat: Likewise. - * tests/check-stateful.cmd: Likewise. - * tests/check-translit.cmd: Likewise. - * djgpp/stateful-check.sed: Remove MODE variable. - * djgpp/translit-check.sed: Likewise. - -2004-01-21 Bruno Haible - - * man/iconv.3: Fix description of return value in case of error. - Reported by Jonathan Wakely . - -2003-09-12 Paul Eggert - - * srclib/progreloc.c (get_full_program_name): Define via prototype. - -2003-08-15 Bruno Haible - - * Makefile.devel (lib/translit.h): Add ulimit command so that the - gentranslit program gets the stack it needs. Many Linux distributions - allow only 8 MB of stack by default. - -2003-08-01 Bruno Haible - - * lib/relocatable.c (find_shared_library_fullname): Disable the code on - Linux/libc5. - * srclib/relocatable.c (find_shared_library_fullname): Likewise. - Reported by Alain Guibert . - -2003-07-02 Bruno Haible - - * m4/lib-ld.m4: Update from GNU gettext. - * m4/lib-prefix.m4: Update from GNU gettext. - * m4/gettext.m4: Update from GNU gettext. - * m4/intmax.m4: New file, from GNU gettext. - * m4/longdouble.m4: New file, from GNU gettext. - * m4/longlong.m4: New file, from GNU gettext. - * m4/printf-posix.m4: New file, from GNU gettext. - * m4/signed.m4: New file, from GNU gettext. - * m4/wchar_t.m4: New file, from GNU gettext. - * m4/wint_t.m4: New file, from GNU gettext. - * m4/pathmax.m4: Update from GNU gettext and gnulib. - * m4/ssize_t.m4: Update from GNU gettext and gnulib. - * m4/xreadlink.m4: Update from GNU gettext and gnulib. - * m4/readlink.m4: New file, from gnulib. - * autoconf/install-reloc: Update from GNU gettext. - * srclib/stdbool_.h: Renamed from srclib/stdbool.h.in. - * srclib/readlink.c: New file, from GNU gettext and gnulib. - * srclib/Makefile.am (LIBADD_SOURCE): Add readlink.c. - (EXTRA_DIST, stdbool.h): Use stdbool_.h instead of stdbool.h.in. - * configure.in: Invoke gl_FUNC_READLINK. - -2003-06-22 Bruno Haible - - * src/Makefile.in (install): Link with the already installed library. - This fixes a link error on Solaris. - Reported by Paul Eggert. - -2003-06-08 Bruno Haible - - * srclib/canonicalize.c (__getcwd) [VMS]: Pass 3 arguments to getcwd. - -2003-05-02 Bruno Haible - - Support for libtool-1.5. - * srclib/progname.c (set_program_name): Remove a leading - "/.libs/lt-" or "/.libs/", not only "lt-". - -2003-06-23 Bruno Haible - - Avoid compilation units that are empty after preprocessing. - * srclib/canonicalize.c: Add dummy declaration. - * srclib/strerror.c: Likewise. - * srclib/error.c: Include even if there's nothing to be - compiled. - -2003-06-22 Bruno Haible - - Portability to mingw32. - * m4/ssize_t.m4: New file, from GNU gettext. - * m4/xreadlink.m4 (gl_XREADLINK): Require gt_TYPE_SSIZE_T. - Reported by Jeff Bonggren . - -2003-06-22 Bruno Haible - - Portability to mingw32. - * lib/relocatable.c [WIN32]: Include . - * srclib/relocatable.c: Likewise. - Reported by Jeff Bonggren . - -2003-06-22 Bruno Haible - - * lib/relocatable.c (compute_curr_prefix): Comment out this function in - the case when it is not used. - * srclib/relocatable.c (compute_curr_prefix): Likewise. - Reported by Pavel Roskin . - -2003-06-18 Bruno Haible - - * config/install-sh: Update from automake-1.7.5. - -2003-06-16 Bruno Haible - - * lib/encodings.def (ISO-8859-15): Add alias LATIN-9. - (ISO-8859-16): Add aliases ISO_8859-16:2001, LATIN10, L10. Remove alias - ISO_8859-16:2000. - (GBK): Add aliases MS936, WINDOWS-936. - Reported by Guido Flohr . - -2003-05-09 Bruno Haible - - * srclib/canonicalize.c: Add #ifdef around versioned_symbol. Avoids an - "extraneous semicolon" warning from Tru64 cc. - -2003-06-07 Bruno Haible - - * Makefile.devel (config.h_vms): Don't define HAVE_ENVIRON_DECL. - * Makefile.vms (config.h): New rule. - (all, install): Depend on it. - (all, install, installdirs, uninstall, check): Fix typo. - (mostlyclean, clean, distclean, maintainer-clean): Likewise. Remove - config.h. - * lib/Makefile.vms (DEFS): Fix value of INSTALLDIR. - (OBJECTS): Use libiconv.obj instead of iconv.obj. - (libiconv.obj): Renamed from iconv.obj. - * srclib/Makefile.vms (INCLUDES): Add parent directory. - (OBJECTS): Remove strtoul.obj, setenv.obj, unsetenv.obj. - (strtoul.obj, setenv.obj, unsetenv.obj): Remove rules. - (alloca.h): New rule. - (canonicalize.obj): Depend on it. - (clean): Remove alloca.h. - * src/Makefile.vms (datadir, localedir): New variables. - (DEFS): Also define LOCALEDIR. - (iconv.obj): Add flags for relocatability, - (iconv.exe): Link with libicrt. Use link_options. - * vms/link_options.opt: New file. - Reported by Jouk Jansen . - -2003-06-07 Bruno Haible - - Support for relocatable data files even on Woe32. - * lib/Makefile.msvc (PICFLAGS): Also define PIC. - -2003-05-22 Bruno Haible - - * Version 1.9.1 released. - -2003-05-22 Bruno Haible - - * lib/genaliases.c (main): Emit %pic instead of %null-strings. - Change type of 'name' field to 'int'. - * lib/genaliases2.c (emit_encoding): Add a 'tag' argument. Emit an - invocation of macro S(), including the tag and a counter. - (main): Use the command-line argument as tag. - * Makefile.devel (lib/aliases_aix.h, lib/aliases_osf1.h, - lib/aliases_dos.h, lib/aliases_extra.h): Pass a tag to the program. - * lib/iconv.c (stringpool2_t): New type. - (stringpool2_contents): New data table. - (stringpool2): New macro. - (sysdep_aliases): Make position-independent. Move #includes out to - aliases2.h. - (aliases2_lookup): Update. - (nalias): New type. - (compare_by_index): Use 'struct nalias' instead of 'struct alias'. - (iconvlist): Convert 'struct alias' to 'struct nalias' while copying. - * lib/aliases2.h: New file, extracted from lib/iconv.c. - -2003-05-20 Bruno Haible - - * lib/iconv.c (iconvlist): Test p->name against NULL, not against "". - Reported by Muraoka Taro . - -2003-05-19 Bruno Haible - - * windows/iconv.rc: Include . - Reported by Perry Rapp. - -2003-05-18 Bruno Haible - - * Version 1.9 released. - -2003-05-18 Bruno Haible - - * lib/Makefile.in (libiconv_plug_osf.so): Avoid using LIBTOOL_LINK. - -2003-05-18 Bruno Haible - - * lib/Makefile.msvc (DEBUGFLAGS): New variable. - (iconv.lib): Use it. - * src/Makefile.msvc (DEBUGFLAGS): New variable. - * tests/Makefile.msvc (DEBUGFLAGS): New variable. - -2003-05-17 Bruno Haible - - * src/Makefile.msvc (libdir, datadir, localedir): New variables. - (IIlibdir, IIdatadir, IIlocaledir): New variables. - (CFLAGS): Define LOCALEDIR. - (iconv_no_i18n.exe): New rule. - (all): Depend on it. - * tests/check-stateful.bat: Invoke iconv_no_i18n instead of iconv. - * tests/check-translit.bat: Likewise. - -2003-05-16 Bruno Haible - - * lib/genaliases.c (main): Emit declarations for gperf-3.0. - * Makefile.devel (lib/aliases.h): Remove gperf command line options; - add new option "-m 10" for gperf-3.0. - -2003-05-12 Bruno Haible - - * m4/error.m4: Update from gettext. - -2003-05-12 Bruno Haible - - * configure.in: Invoke AC_GNU_SOURCE and jm_FUNC_GLIBC_UNLOCKED_IO. - -2003-05-12 Bruno Haible - - * lib/Makefile.msvc (PICFLAGS, CFLAGS): Move BUILDING_* macros from - CFLAGS to PICFLAGS. - -2003-05-09 Bruno Haible - - * srclib/error.c: Update from gnulib with modifications. - * srclib/unlocked-io.h: New file, from gnulib. - * m4/strerror_r.m4: New file, from gnulib. - * m4/unlocked-io.m4: New file, from gnulib. - * Makefile.devel (aclocal.m4): Depend on them. - -2003-05-08 Bruno Haible - - * Makefile.msvc (IIPREFIX): New variable. - * srclib/Makefile.msvc (INCLUDES): Add -I..\windows. - * src/Makefile.msvc (IIPREFIX, IIprefix, IIexec_prefix, IIbindir, - IIincludedir): New variables. - (INCLUDES): Add -I..\windows. - (iconv.exe): Define INSTALLPREFIX and INSTALLDIR. Link with - ../srclib/icrt.lib. - Patches by Perry Rapp. - -2003-05-07 Bruno Haible - - * README.woe32: Fix instructions for step 1. - * srclib/Makefile.msvc (OBJECTS): Remove strtoul.obj. - (strtoul.obj): Remove rule. - Reported by Perry Rapp. - -2003-05-07 Bruno Haible - - * Makefile.vms: New file. - * lib/Makefile.vms: New file. - * srclib/Makefile.vms: New file. - * src/Makefile.vms: New file. - * man/Makefile.vms: New file. - * tests/Makefile.vms: New file. - * Makefile.devel (config.h_vms, lib/config.h_vms, include/iconv.h_vms): - New rules. - (all): Depend on them. - -2003-05-07 Bruno Haible - - * srclib/Makefile.msvc (OBJECTS): Remove findprog.obj. - (findprog.obj): Remove rule. - * src/Makefile.msvc (includedir): New variable. - -2003-05-06 Bruno Haible - - * lib/translit.def: Upgrade to Unicode 4.0. - -2003-05-06 Bruno Haible - - * srclib/Makefile.am (DEFS): Fix spelling of DEPENDS_ON_LIBICONV. - * srclib/Makefile.msvc (CFLAGS): Likewise. - - * srclib/Makefile.msvc (INCLUDES): Add -I.. . - Reported by Perry Rapp. - - * Makefile.msvc (config.h): New rule. - (all): Depend on it. - (mostlyclean, clean, distclean, maintainer-clean): Erase config.h. - Reported by Perry Rapp. - -2003-05-06 Bruno Haible - - * autoconf/config.guess: Update to GNU version 2003-02-22. - * autoconf/config.sub: Likewise. - -2003-05-06 Bruno Haible - - * m4/lib-link.m4: Update from GNU gettext. - * autoconf/config.rpath: Update from GNU gettext. - - * m4/libtool.m4: Update from GNU gettext, based on libtool-1.5. - * autoconf/ltmain.sh: Update from GNU gettext, based on libtool-1.5. - - * m4/gettext.m4: Update from GNU gettext. - * m4/nls.m4: Update from GNU gettext. - * m4/po.m4: Update from GNU gettext. - * Makefile.devel (aclocal.m4): Depend on m4/nls.m4 and m4/po.m4. - -2003-04-12 Bruno Haible - - Support for OpenVMS 7.3. - * lib/iconv.c (USE_OSF1): Define also on VMS. - -2003-04-12 Bruno Haible - - Better support for FreeBSD. - * lib/encodings.def (ISO8859-{1,2,3,4,5,6,7,8,9,10,13,14,15,16): New - aliases, for compatibility with earlier FreeBSD iconv implementation - by Konstantin Chuguev. - * lib/iconv.c (iconv_open, iconv, iconv_close) [FreeBSD]: Define as - aliases. - * src/Makefile.in (install) [FreeBSD]: Avoid installation problem. - -2003-04-12 Bruno Haible - - * configure.in (mandir): Change default value. - * Makefile.in (datadir): New variable. - (install, installdirs, uninstall): Pass datadir to po and man - directories. - * Makefile.os2 (datadir): New variable. - (mandir): Use it instead of prefix. - (install, uninstall): Pass datadir to man directory. - * Makefile.msvc (mandir, docdir): Use datadir instead of prefix. - * man/Makefile.in (datadir): New variable. - (docdir): Use it instead of prefix. - (install, installdirs): Update. - * man/Makefile.os2 (datadir): New variable. - (mandir): Use it instead of prefix. - * man/Makefile.msvc (datadir): New variable. - (mandir, docdir): Use it instead of prefix. - (install, installdirs): Update. - -2003-04-06 Bruno Haible - - Make it possible to build with or without libintl support on Woe32. - * Makefile.devel (config.h.msvc): Remove ENABLE_NLS. - * Makefile.msvc (NO_NLS): New variable. - * srclib/Makefile.msvc (NO_NLS): New variable. - (CFLAGS, INCLUDES): Use them. - * src/Makefile.msvc (NO_NLS): New variable. - (NLSFLAGS, INCINTL, LIBINTL): New variables. - (CFLAGS, INCLUDES, iconv.exe): Use them. - -2003-04-12 Bruno Haible - - * lib/loop_unicode.h (unicode_transliterate): When the Hangul or - variants transliteration failed with RET_ILUNI, don't return - RET_TOOSMALL. - Reported by the FreeBSD porters. - -2003-04-06 Bruno Haible - - * srclib/binary-io.h: New file, from GNU gettext. - * src/iconv.c: Include it. - (O_BINARY, O_TEXT, SET_BINARY): Remove definitions. - -2003-04-05 Bruno Haible - - Support for relocatable installation. - * m4/alloca.m4: New file, from GNU gettext. - * m4/canonicalize.m4: New file, from GNU gettext. - * m4/error.m4: New file, from GNU gettext. - * m4/onceonly.m4: New file, from GNU gettext. - * m4/pathmax.m4: New file, from GNU gettext. - * m4/relocatable.m4: New file, from GNU gettext. - * m4/setenv.m4: New file, from GNU gettext. - * m4/stdbool.m4: New file, from GNU gettext. - * m4/strerror.m4: New file, from GNU gettext. - * m4/xreadlink.m4: New file, from GNU gettext. - * autoconf/config.libpath: New file, from GNU gettext. - * autoconf/install-reloc: New file, from GNU gettext. - * autoconf/reloc-ldflags: New file, from GNU gettext. - * autoconf/missing: New file, from GNU automake 1.7.3. - * lib/relocatable.h: New file, from GNU gettext. - * lib/relocatable.c: New file, from GNU gettext. - * srclib/alloca.c: New file, from GNU gettext. - * srclib/alloca_.h: New file, from GNU gettext. - * srclib/canonicalize.c: New file, from GNU gettext. - * srclib/canonicalize.h: New file, from GNU gettext. - * srclib/error.c: New file, from GNU gettext. - * srclib/error.h: New file, from GNU gettext. - * srclib/exit.h: New file, from GNU gettext. - * srclib/gettext.h: New file, from GNU gettext. - * srclib/memmove.c: New file, from GNU gettext. - * srclib/pathmax.h: New file, from GNU gettext. - * srclib/progname.c: New file, from GNU gettext. - * srclib/progname.h: New file, from GNU gettext. - * srclib/progreloc.c: New file, from GNU gettext. - * srclib/relocatable.c: New file, from GNU gettext. - * srclib/relocatable.h: New file, from GNU gettext. - * srclib/relocwrapper.c: New file, from GNU gettext. - * srclib/setenv.c: New file, from GNU gettext. - * srclib/setenv.h: New file, from GNU gettext. - * srclib/stdbool.h.in: New file, from GNU gettext. - * srclib/strerror.c: New file, from GNU gettext. - * srclib/unsetenv.c: New file, from GNU gettext. - * srclib/xmalloc.c: New file, from GNU gettext. - * srclib/xmalloc.h: New file, from GNU gettext. - * srclib/xreadlink.c: New file, from GNU gettext. - * srclib/xreadlink.h: New file, from GNU gettext. - * srclib/xstrdup.c: New file, from GNU gettext. - * srclib/Makefile.am: New file. - * srclib/Makefile.msvc: New file. - * windows/alloca.h: New file, from GNU gettext. - * windows/stdbool.h: New file, from GNU gettext. - * configure.in (AC_CONFIG_HEADERS): Replace src/config.h with config.h. - Add AC_RELOCATABLE, AC_HEADER_STDC, AC_CHECK_HEADERS(stddef.h stdlib.h - string.h), AC_CHECK_FUNCS(getc_unlocked), AC_REPLACE_FUNCS(memmove), - AM_LANGINFO_CODESET, gl_FUNC_ALLOCA, gl_CANONICALIZE, - gt_FUNC_ERROR_AT_LINE, gl_PATHMAX, gt_FUNC_SETENV, gt_STDBOOL_H, - gl_FUNC_STRERROR, gl_XREADLINK, AC_OUTPUT(srclib/Makefile). - * lib/config.h.in: Add HAVE_GETC_UNLOCKED, HAVE_LANGINFO_CODESET, - HAVE_SETLOCALE, HAVE_STDDEF_H, HAVE_STDLIB_H, HAVE_STRING_H, for - localcharset.c. Add ENABLE_RELOCATABLE, INSTALLPREFIX, for - relocatable.c. - * lib/Makefile.in (DEFS): New variable. - (SOURCES): Add localcharset.c and relocatable.c. - (OBJECTS): Add localcharset.lo and relocatable.lo. - (LIBCHARSET_OBJECTS): Remove variable. - (libiconv_plug_linux.so, libiconv_plug_solaris.so, - libiconv_plug_osf.so): Use $(DEFS). Don't use $(LIBCHARSET_OBJECTS). - (iconv.lo): Use $(DEFS). - (localcharset.lo, relocatable.lo): New rules. - * lib/Makefile.msvc (CFLAGS): Define HAVE_CONFIG_H, BUILDING_DLL, - ENABLE_RELOCATABLE, IN_LIBRARY, INSTALLDIR, NO_XMALLOC, - set_relocation_prefix, relocate. Remove $(PICFLAGS). - (INCLUDES): Simplify. - (SOURCES): Remove variable. - (OBJECTS): Add localcharset.obj and relocatable.obj. - (LIBCHARSET_OBJECTS): Remove variable. - (iconv.obj): Add $(PICFLAGS). - (localcharset.obj, relocatable.obj): New rules. - (iconv.lib): Drop $(LIBCHARSET_OBJECTS). - * include/iconv.h.in (libiconv_set_relocation_prefix): New declaration. - * src/gettext.h: Remove file. - * src/iconv.c: Include progname.h and relocatable.h. - (ICONV_CONST): Define to const if the system has no iconv. - (main): Invoke set_program_name. Relocate LOCALEDIR. - * src/Makefile.in (top_srcdir): New variable. - (INCLUDES): Add .. and ../srclib. - (iconv_no_i18n, iconv): Link with ../srclib/libicrt.a. - (iconv_no_i18n.@OBJEXT@, iconv.@OBJEXT@): Define INSTALLDIR. - (RELOCATABLE_LIBRARY_PATH, RELOCATABLE_SRC_DIR, RELOCATABLE_BUILD_DIR, - RELOCATABLE_CONFIG_H_DIR, @SET_RELOCATABLE@, iconv_LDFLAGS): New - variables. - (iconv): Use $(iconv_LDFLAGS). - (install): Use $(INSTALL_PROGRAM_ENV). - (distclean): Drop removing config.h. - * src/Makefile.msvc (INCLUDES): Add .., simplify. - * tests/Makefile.msvc (INCLUDES): Simplify. - * Makefile.devel (AUTOHEADER, AUTOMAKE): New variables. - (config.h.in, srclib/Makefile.in, config.h.msvc): New rules. - (all): Depend on them. - (aclocal.m4) Depend also on m4/alloca.m4, m4/canonicalize.m4, - m4/error.m4, m4/onceonly.m4, m4/pathmax.m4, m4/relocatable.m4, - m4/setenv.m4, m4/stdbool.m4, m4/strerror.m4, m4/xreadlink.m4. - (lib/config.h.msvc): Additional processing. - * Makefile.in (all, install, installdirs, uninstall, check): Recurse - into srclib. - (mostlyclean, clean, distclean, maintainerclean): Likewise. Remove - lib/localcharset.h. - (distclean, maintainerclean): Remove also config.h and some stamps. - * Makefile.msvc (all, install, installdirs, uninstall, check, - mostlyclean, clean, distclean, maintainerclean): Recurse into srclib. - * INSTALL.generic: Document --enable-relocatable and - --with-libintl-prefix. Remove the recommendation to set CPPFLAGS and - LDFLAGS. The lib-link.m4 macros make this unnecessary. - -2003-04-05 Bruno Haible - - * configure.in: Bump version number to 1.9. - * include/iconv.h.in (_LIBICONV_VERSION): Bump. - * windows/iconv.rc: Bump version number. - * lib/Makefile.in (LIBICONV_VERSION_INFO): Bump to 4:0:2. - -2003-04-05 Bruno Haible - - * Makefile.msvc (PREFIX): New variable. - (prefix): Use it. - (distclean, maintainer-clean): Drop Unix specific removals. - * lib/Makefile.msvc (PREFIX, IIPREFIX): New variables. - (prefix): Use it. - (IIprefix, IIexec_prefix, IIbindir, IIlibdir): New variables. - (clean): Drop Unix specific removal. - * src/Makefile.msvc (PREFIX): New variable. - (prefix): Use it. - (clean): Drop Unix specific removal. - (distclean): Likewise. - * tests/Makefile.msvc (clean): Drop Unix specific removal. - (distclean): Likewise. - -2003-04-05 Bruno Haible - - * m4/endian.m4 (CL_WORDS_LITTLEENDIAN): Use 3-argument AC_DEFINE. - -2003-04-05 Bruno Haible - - * m4/general.m4 (CL_CONFIG_SUBDIRS, CL_CANONICAL_HOST, - CL_CANONICAL_HOST_CPU, CL_CANONICAL_HOST_CPU_FOR_FFCALL): Remove - macros. - * m4/gettext.m4: Update from GNU gettext. - * m4/iconv.m4: Update from GNU gettext. - * m4/lcmessage.m4: Update from GNU gettext. - * m4/progtest.m4: Update from GNU gettext. - * m4/libtool.m4: Update from GNU gettext. - 2003-02-16 Bruno Haible - Workaround autoconf >= 2.52 breakage. - * libtool.m4 (AC_LIBTOOL_ARG_WITH): New macro. - (_LT_AC_LTCONFIG_HACK, AC_PROG_LD): Use it. - * autoconf/ltmain.sh: Update from GNU gettext. - 2003-02-18 Bruno Haible - Fix the 2002-09-16 fix. - * ltmain.sh (install): If "ln -s -f" fails (this is the case - with /usr/bin/ln on Solaris 2.7), fall back to "rm && ln -s". - -2003-04-05 Bruno Haible - - Start using automake. - * configure.in: Add AM_INIT_AUTOMAKE invocation. - (PACKAGE, VERSION): Remove. - Use AC_CANONICAL_HOST instead of CL_CANONICAL_HOST. - Use AC_PROG_LN_S instead of CL_PROG_LN_S. - Use AC_PROG_RANLIB instead of CL_PROG_RANLIB. - Reorder so that AC_CANONICAL_HOST comes early but still after - AC_PROG_CC. - * m4/ranlib.m4: Remove file. - * m4/libtool.m4: Undo AC_ -> CL_ substitutions. - * Makefile.devel (CLISP_DIR): Comment out. - (AUTOCONF_FILES): Change to aclocal.m4. - (aclocal.m4): Renamed from autoconf/aclocal.m4. Update dependencies. - (configure.in): Drop --include option. - -2003-03-17 Bruno Haible - - Improved MSVC support. - * Makefile.msvc (prefix): Use less Unixy value. - (local_prefix): Remove variable. - (libdir, includedir, mandir): Use backslashes. - (bindir, datadir, localedir, docdir): New variables. - (INSTALL, INSTALL_PROGRAM, INSTALL_DATA): New variables. - (all): Recurse into po/ and man/. - (install, installdirs, uninstall): Rewritten. - (check, mostlyclean, clean, distclean, maintainer-clean): Recurse - into po/ and man/. - * lib/Makefile.msvc (prefix): Use less Unixy value. - (local_prefix): Remove variable. - (libdir): Use backslashes. - (bindir): New variable. - (INSTALL, INSTALL_PROGRAM, INSTALL_DATA): Set to real values. - (RESOURCES): Enable iconv.res. - (install, installdirs, uninstall): New rules. - (clean): Remove config.h. - (distclean): Don't remove config.h here. - * src/Makefile.msvc (prefix, exec_prefix, bindir): New variables. - (INSTALL, INSTALL_PROGRAM, INSTALL_DATA): New variables. - (install, installdirs, uninstall): New rules. - * man/Makefile.msvc: New file. - * tests/Makefile.msvc (install, installdirs, uninstall): New rules. - * Makefile.devel (all): Depend on po/Makefile.msvc. - (po/Makefile.msvc): New rule. - * windows/iconv.rc: Update. - * README.woe32: Mention automatic installation command. - - Rename libcharset.h to localcharset.h. - * lib/iconv.c: Include localcharset.h, not libcharset.h. - * Makefile.in (lib/localcharset.h): Renamed from lib/libcharset.h. - (all, install): Update dependencies. - (all): Create lib/localcharset.h, not lib/libcharset.h. - (mostlyclean, clean, distclean, maintainer-clean): Remove - lib/localcharset.h, not lib/libcharset.h. - * djgpp/README.in, djgpp/README: Update. - * djgpp/config.bat: Update. - * djgpp/config.sed: Update. - * djgpp/fnchange.in, djgpp/fnchange.lst: Update. - -2003-01-31 Bruno Haible - - * src/Makefile.in (all): Don't do the chmod if it has already been - done. - -2003-01-31 Bruno Haible - - * lib/loop_unicode.h (unicode_transliterate): Enable recursive - transliteration. Idea from Perry Rapp. - * lib/gentranslit.c (main): Change bound from 0x10000 to 0x110000. - Change element type of translit_data to 'unsigned int'. - * lib/translit.def: Many new transliterations, mostly taken from glibc. - * lib/translit.h: Regenerated. - * tests/Translit1.ISO-8859-1, tests/Translit1.ASCII: New files. - * tests/Makefile.in (check): Add Translit1 check. - * tests/Makefile.msvc (check): Likewise. - * tests/Makefile.os2 (check): Likewise. - * tests/TranslitFail1.ISO-8859-1: Choose a sentence which the new - improved transliteration cannot do. - -2003-02-14 Bruno Haible - - * Makefile.devel (AUTOCONF): Switch to autoconf-2.57. - (configure): Update rule. - -2003-01-03 Albert Chin - - * autoconf/ltmain.sh: Don't pass -R flags found in a .la's - dependency_libs variable directly down to the linker. - Reported by Tim Mooney . - -2003-01-01 Bruno Haible - - * src/Makefile.in (install): Use libiconv.la in ../lib, not in - $(libdir), so that installing with DESTDIR works. - Reported by Michael Adams . - -2003-01-01 Bruno Haible - - * Makefile.in (mkinstalldirs): New variable. - (install-lib, install, installdirs): Use it instead of mkdir. - * lib/Makefile.in (mkinstalldirs): New variable. - (install-lib, install, installdirs): Use it instead of mkdir. - * man/Makefile.in (mkinstalldirs): New variable. - (install, installdirs): Use it instead of mkdir. - * src/Makefile.in (mkinstalldirs): New variable. - (install, installdirs): Use it instead of mkdir. - -2002-09-27 Bruno Haible - - * autoconf/mkinstalldirs: Upgrade to automake-1.7.2 version. - -2002-11-07 Bruno Haible - - * m4/libtool.m4: Upgrade to libtool-1.4.3. - * autoconf/ltmain.sh: Upgrade to libtool-1.4.3. - -2002-07-14 Bruno Haible - - * m4/libtool.m4 (_LT_AC_LTCONFIG_HACK): Add support for GNU/FreeBSD. - -2002-06-12 Bruno Haible - - * configure.in: Use new AC_* names of libtool macros. Invoke - AC_LIBTOOL_WIN32_DLL. - -2002-12-19 Bruno Haible - - * lib/Makefile.in (libiconv_plug_solaris.so): Change rule if using gcc. - Reported by Henry Nelson . - -2002-11-07 Bruno Haible - - Make "make install" without prior "make" work. - * Makefile.in (lib/libcharset.h): New rule. - (all, install): Depend on it. - Reported by Martin Mokrejลก . - -2002-10-28 Bruno Haible - - * man/Makefile.in (install): Change directory back to the working - directory, so that install-sh (which may be a relative pathname) is - found in the right place. - -2002-09-16 Bruno Haible - - * autoconf/ltmain.sh (install): Use "ln -s -f" instead of - "rm -f && ln -s" to make a symlink for a shared library. - Reported by Nelson H. F. Beebe . - -2002-09-02 Bruno Haible - - * src/iconv.c (main): Don't call bindtextdomain if !ENABLE_NLS. - -2002-08-16 Bruno Haible - - * src/iconv.c (main): Perform fflush before testing ferror(stdout). - -2002-05-29 Bruno Haible - - * Version 1.8 released. - -2002-05-26 Bruno Haible - - * lib/c99.h: New file. - * lib/converters.h: Include it. - * lib/encodings.def (C99): New encoding. - * README, man/iconv_open.3: Document C99 encoding. - -2002-05-26 Bruno Haible - - * lib/java.h (java_mbtowc): Accept 12-byte sequences for non-BMP - characters. - (java_wctomb): Produce 12-byte sequences for non-BMP characters. - -2002-05-29 Bruno Haible - - Fix installation of iconv program when linked with a libintl that was - built against an earlier libiconv. - * src/iconv.c: Conditionally disable NLS. - * src/iconv_no_i18n.c: New file. - * src/Makefile.in (libdir): New variable. - (all): Depend on iconv_no_i18n, iconv.@OBJEXT@ but not iconv. Make - directory writable, so iconv executable can be created during "make - install". - (iconv): Remove rule. - (iconv_no_i18n, iconv_no_i18n.@OBJEXT@): New rules. - (install): Link iconv now, after the new libiconv.so is installed. - (clean): Also remove iconv_no_i18n. - * tests/Makefile.in: (check, check-extra-yes): Depend on iconv_no_i18n, - not iconv. - * tests/check-stateful: Use iconv_no_i18n, not iconv. - * tests/check-translit: LIkewise. - * tests/check-translitfailure: Likewise. - -2002-05-29 Bruno Haible - - * configure.in: Call AC_PROG_INSTALL instead of CL_PROG_INSTALL. - * m4/install.m4: Remove file. - * Makefile.devel (autoconf/aclocal.m4): Don't depend on m4/install.m4. - -2002-05-24 Bruno Haible - - * lib/jisx0213.h: Use 'inline' only conditionally. - -2002-05-18 Bruno Haible - - * configure.in (AC_INIT), include/iconv.h.in (_LIBICONV_VERSION), - README, windows/iconv.rc, djgpp/README, djgpp/fnchange.lst: - Bump version number. - * lib/Makefile.in (LIBICONV_VERSION_INFO): Define to 3:0:1. - -2002-02-06 Bruno Haible - - * autoconf/ltmain.sh: Upgrade from libtool-1.4 to libtool-1.4.2. - -2002-02-02 Bruno Haible - - * autoconf/ltmain.sh: Add DESTDIR support on ELF systems. - -2001-11-03 Bruno Haible - - * autoconf/ltmain.sh: chmod 777 the .libs directory, so that - "make install" succeeds. - -2002-05-18 Bruno Haible - - * src/Makefile.in (iconv): Remove the -liconv dependency of -lintl - from the command line. Needed to ensure that the new libiconv version - is used on FreeBSD. - -2002-05-14 Bruno Haible - - Implement and document CP853, TDS565, RISCOS-LATIN1. - * tools/Makefile (ALL): Add cp853.h, tds565.h, riscos1.h. - (cp853.h, tds565.h, riscos1.h): New rules. - * lib/cp853.h: New file. - * lib/tds565.h: New file. - * lib/riscos1.h: New file. - * lib/converters.h: Include them. - * lib/encodings_dos.def (CP853): New encoding. - * lib/encodings_extra.def (TDS565, RISCOS-LATIN1): New encodings. - * README, man/iconv_open.3: Add CP853, TDS565, RISCOS-LATIN1. - * tests/Makefile.in (check-extra-yes): Check CP853, TDS565, - RISCOS-LATIN1. - * tests/Makefile.msvc (check): Check CP853. - * tests/CP853.TXT: New file. - * tests/TDS565.TXT: New file. - * tests/RISCOS-LATIN1.TXT: New file. - - * lib/cp860.h (cp860_wctomb): Optimize. - -2002-05-12 Bruno Haible - - * tools/Makefile (ksc5601.h): Add two extra characters. - * lib/ksc5601.h: Regenerated. - * tests/EUC-KR.TXT: Add EURO SIGN and REGISTERED SIGN. - * tests/CP949.TXT: Likewise. - * tests/JOHAB.TXT: Likewise. - -2002-05-12 Bruno Haible - - * README: Mention extra encodings. - * man/iconv_open.3: Likewise. Improve formatting in text and html - output formats. - -2002-05-12 Bruno Haible - - * tests/SHIFT_JIS.TXT: Renamed from tests/SHIFT-JIS.TXT. - -2002-05-12 Bruno Haible - - * Makefile.devel (AUTOCONF): New variable. - (AUTOCONF_FILES): Remove autoconf/autoconf.m4f. - (configure): Use the AUTOCONF variable. - * autoconf/autoconf: Remove file. - * autoconf/autoconf.m4: Remove file. - * autoconf/autoconf.m4f: Remove file. - -2002-05-12 Bruno Haible - - * tools/JISX0213.TXT: New file. - * tools/cjk_tab_to_h.c (do_jisx0213): New function. - (main): Accept "jisx0213". - * tools/Makefile (all): Add jisx0213.h. - (jisx0213.h): New rule. - * lib/jisx0213.h: New file, generated by cjk_tab_to_h. - * lib/euc_jisx0213.h: New file. - * lib/shift_jisx0213.h: New file. - * lib/iso2022_jp3.h: New file. - * lib/converters.h: Include them. - * lib/encodings_extra.def (EUC-JISX0213, SHIFT_JISX0213, - ISO-2022-JP-3): New encodings. - * tests/EUC-JISX0213.TXT: New file. - * tests/SHIFT_JISX0213.TXT: New file. - * tests/ISO-2022-JP-3-snippet: New file. - * tests/ISO-2022-JP-3-snippet.UTF-8: New file. - * tests/Makefile.in (check-extra): Also check EUC-JISX0213, - SHIFT_JISX0213, ISO-2022-JP-3. - * tests/check-stateless: Add support for encodings which contain - precomposed Unicode characters, by eliminating precomposed characters - before the comparison. - * tests/table-from.c (main): Fix usage message. - * tests/table-to.c (main): Make it work for encodings for which the - "to" direction is stateful. - -2002-05-09 Bruno Haible - - New configure option --enable-extra-encodings. - * lib/encodings_extra.def: New file. - * lib/converters.h: Handle USE_EXTRA. - * lib/genaliases2.c (main): Handle USE_EXTRA. - * lib/genflags.c: Define USE_EXTRA. - (main): Include encodings_extra.def. - * lib/iconv.c: Handle ENABLE_EXTRA, conditionally set USE_EXTRA. - Handle USE_EXTRA. - * lib/config.h.in (ENABLE_EXTRA): New macro. - * configure.in: Accept option --enable-extra-encodings. - * Makefile.devel (all): Depend on lib/aliases_extra.h. - (lib/aliases_extra.h): New rule. - (lib/flags.h): Depend on lib/encodings_extra.def. - * tests/Makefile.in (check-extra, check-extra-no, check-extra-yes): - New rules. - (check): Invoke check-extra. - * tests/Makefile.msvc (check): Also check the DOS encodings. - - Support for testing the AIX encodings. - * tests/CP856.TXT: New file. - * tests/CP922.TXT: New file. - * tests/CP1046.TXT: New file. - * tests/CP1124.TXT: New file. - * tests/CP1129.TXT: New file. - * tests/CP1161.TXT, tests/CP1161.IRREVERSIBLE.TXT: New files. - * tests/CP1162.TXT: New file. - * tests/CP1163.TXT, tests/CP1163.IRREVERSIBLE.TXT: New files. - - Support for testing the OSF/1 encodings. - * tests/DEC-KANJI.TXT: New file. - * tests/DEC-HANYU.TXT, tests/DEC-HANYU.IRREVERSIBLE.TXT: New files. - - Support for testing the DOS encodings. - * tests/CP437.TXT: New file. - * tests/CP737.TXT: New file. - * tests/CP775.TXT: New file. - * tests/CP852.TXT: New file. - * tests/CP855.TXT: New file. - * tests/CP857.TXT: New file. - * tests/CP858.TXT: New file. - * tests/CP860.TXT: New file. - * tests/CP861.TXT: New file. - * tests/CP863.TXT: New file. - * tests/CP864.TXT: New file. - * tests/CP865.TXT: New file. - * tests/CP869.TXT: New file. - * tests/CP1125.TXT: New file. - -2002-05-09 Bruno Haible - - Implement more ASCII compatible DOS encodings. - * tools/Makefile (ALL): Add cp737.h, cp858.h, cp860.h, cp863.h. - (cp737.h, cp858.h, cp860.h, cp863.h): New rules. - * lib/cp737.h: New file. - * lib/cp858.h: New file. - * lib/cp860.h: New file. - * lib/cp863.h: New file. - * lib/converters.h: Include them. - * lib/encodings_dos.def (CP737, CP858, CP860, CP863): New encodings. - -2002-05-09 Bruno Haible - - Implement new ASCII compatible encodings from IBM. - * tools/Makefile (ALL): Add cp1161.h, cp1162.h, cp1163.h. - (cp1161.h, cp1162.h, cp1163.h): New rules. - * lib/cp1161.h: New file. - * lib/cp1162.h: New file. - * lib/cp1163.h: New file. - * lib/converters.h: Include them. - * lib/encodings_aix.def (CP1161, CP1162, CP1163): New encodings. - -2002-05-09 Bruno Haible - - Implement and document KOI8-T. - * tools/Makefile (ALL): Add koi8_t.h. - (koi8_t.h): New rule. - * lib/koi8_t.h: New file. - * lib/converters.h: Include it. - * lib/encodings.def (KOI8-T): New encoding. - * README, man/iconv_open.3: Add KOI8-T. - * tests/Makefile.in (tests): Check KOI8-T. - * tests/Makefile.os2 (tests): Likewise. - * tests/Makefile.msvc (tests): Likewise. - * tests/KOI8-T.TXT: New file. - -2002-05-09 Bruno Haible - - * tools/8bit_tab_to_h.c (main): Update copyright year. - * tools/cjk_variants.c (main): Likewise. - -2002-05-08 Bruno Haible - - * README.woe32: Renamed from README.win32. - -2002-05-08 Bruno Haible - - * lib/iconv.c: Enable DOS encodings also when compiling for Woe32, - because the Woe32 consoles use them. - -2002-05-04 Bruno Haible - - * lib/loop_unicode.h (unicode_loop_convert): When quitting the loop - without writing an output character, restore cd->istate to its value - before the xxx_mbtowc call. Otherwise we lose some characters during - CP1255/CP1258/TCVN to Unicode conversion. - (unicode_loop_reset): Likewise for the xxx_flushwc call. - * tests/CP1255-snippet, tests/CP1255-snippet.UTF-8: Make the test - files large enough to test against the bug. - * tests/CP1258-snippet, tests/CP1258-snippet.UTF-8: Likewise. - * tests/TCVN-snippet, tests/TCVN-snippet.UTF-8: Likewise. - -2002-04-28 Bruno Haible - - * tools/Makefile (armscii_8.h): Use table from glibc-2.2.90. - * tests/ARMSCII-8.TXT: Update to glibc-2.2.90 version. - * tests/ARMSCII-8.IRREVERSIBLE.TXT: Remove 0x0027. - * lib/armscii_8.h: Regenerated. - -2002-04-28 Bruno Haible - - * src/iconv.c: Include gettext.h. - (_): New macro. - (usage, print_version, convert, main): Internationalize. - (main): Call setlocale, bindtextdomain, textdomain. - * src/gettext.h: New file, from GNU gettext 0.11.2. - * src/config.h.in: New file, needed for ENABLE_NLS. - * src/Makefile.in (datadir, localedir): New variables. - (iconv): Link with @LTLIBINTL@. - (iconv.@OBJEXT@): Define LOCALEDIR. - (distclean): Remove config.h. - * po: New directory. - * Makefile.in (all, install, installdirs, uninstall, check, - mostlyclean, clean, distclean, maintainer-clean): Recurse into the po - directory. - * autoconf/mkinstalldirs: New file, from automake-1.5. - * ABOUT-NLS: New file, from GNU gettext 0.11.2. - * m4/codeset.m4: New file, from GNU gettext 0.11.2. - * m4/gettext.m4: New file, from GNU gettext 0.11.2. - * m4/glibc21.m4: New file, from GNU gettext 0.11.2. - * m4/isc-posix.m4: New file, from GNU gettext 0.11.2. - * m4/lcmessage.m4: New file, from GNU gettext 0.11.2. - * m4/progtest.m4: New file, from GNU gettext 0.11.2. - * configure.in: Require autoconf-2.52, needed for multiple config.h.in - files. Use new form of AC_INIT. Invoke AM_GNU_GETTEXT. - (PACKAGE, VERSION): Define, needed for po/Makefile.in.in. - * lib/config.h.in (HAVE_LOCALE_H, HAVE_SETLOCALE): Remove. - -2002-04-28 gettextize - - * configure.in (AC_OUTPUT): Add po/Makefile.in. - -2002-04-28 Bruno Haible - - * m4/eilseq.m4: Renamed from autoconf/eilseq.m4. - * m4/mbstate_t.m4: Renamed from autoconf/mbstate_t.m4. - * m4/general.m4: New file, from GNU clisp. - * m4/proto.m4: New file, from GNU clisp. - * m4/ranlib.m4: New file, from GNU clisp. - * m4/install.m4: New file, from GNU clisp. - * m4/cp.m4: New file, from GNU clisp. - * m4/ln.m4: New file, from GNU clisp. - * m4/endian.m4: New file, from GNU clisp. - * m4/iconv.m4: New file, from GNU gettext 0.11.2. - * m4/lib-ld.m4: New file, from GNU gettext 0.11.2. - * m4/lib-link.m4: New file, from GNU gettext 0.11.2. - * m4/lib-prefix.m4: New file, from GNU gettext 0.11.2. - * autoconf/config.rpath: New file, from GNU gettext 0.11.2. - * m4/libtool.m4: New file, based on libtool-1.4.2. - * Makefile.devel (ACLOCAL): Remove variable. - (ACSELECT): Remove variable. - (OTHERMACROS): Remove variable. - (m4/*.m4): New rules. - (autoconf/aclocal.m4): Construct using aclocal instead of acselect. - * configure.in: Invoke AM_ICONV instead of CL_ICONV. - -2002-04-06 Bruno Haible - - Upgrade to Unicode 3.2. - * tools/cjk_tab_to_h.c (output_title): Bump copyright year. - (compact_large_charset2uni): Add an argument. Determine optimal shift. - Copy modified enc->charset2uni table. - (output_charset2uni): Deal with shift other than 8. Copy encoding, so - as to not disturb subsequent output_uni2charset[_sparse] call. - * lib/hkscs.h: Regenerated. - * tests/BIG5-HKSCS.TXT: Update. - * tests/BIG5-HKSCS.IRREVERSIBLE.TXT: Update. - -2002-04-06 Bruno Haible - - Upgrade to Unicode 3.2. - * tools/Makefile (cns11643_1.h, cns11643_2.h, cns11643_3.h, - cns11643_4a.h, cns11643_4b.h, cns11643_5.h, cns11643_6.h, - cns11643_7.h, cns11643_15.h, cns11643_inv.h): Use - CNS11643-Unicode32.TXT instead of CNS11643-Unicode31.TXT. - * lib/cns11643_3.h: Regenerated. - * lib/cns11643_4a.h: Regenerated. - * lib/cns11643_4b.h: Regenerated. - * lib/cns11643_5.h: Regenerated. - * lib/cns11643_6.h: Regenerated. - * lib/cns11643_7.h: Regenerated. - * lib/cns11643_15.h: Regenerated. - * lib/cns11643_inv.h: Regenerated. - * tests/EUC-TW.TXT: Update. - -2002-01-17 Bruno Haible - - * lib/tcvn.h (tcvn_2uni_1): Make it smaller. - (tcvn_mbtowc): Small optimization. - -2002-01-13 Bruno Haible - - New options -l, -c, -s. - * src/iconv.c (discard_unconvertible, silent): New variables. - (usage): Document options -l, -c, -s. - (print_one): New function. - (convert): If silent is true, don't print error messages about the - conversion to stderr. If discard_unconvertible is true, set the - iconv descriptor to DISCARD_ILSEQ the first time, but make sure to - return the same return code as when discard_unconvertible is false. - (main): Accept options -l, -c, -s. Implement option -l. - * man/iconv.1: Document options -l, -c, -s. - -2002-01-13 Bruno Haible - - Support for "iconv -c". - * include/iconv.h.in (ICONV_GET_DISCARD_ILSEQ): New macro. - (ICONV_SET_DISCARD_ILSEQ): Likewise. - * lib/converters.h (struct conv_struct): New field discard_ilseq. - * lib/iconv.c (iconv_open): Set discard_ilseq to true if tocode - has an "//IGNORE" suffix, and to false otherwise. - (iconvctl): Implement ICONV_GET_DISCARD_ILSEQ, ICONV_SET_DISCARD_ILSEQ. - * lib/loop_unicode.h (unicode_loop_convert): If discard_ilseq is - true, skip one input character instead of returning EILSEQ. - (unicode_loop_reset): Likewise. - * lib/loop_wchar.h (wchar_from_loop_convert): Likewise. - (wchar_to_loop_convert): Likewise. - -2002-01-13 Bruno Haible - - Support for "iconv -l". - * include/iconv.h.in (iconvlist): New declaration. - * Makefile.devel (lib/aliases.h): Change gperf options. - * lib/iconv.c (compare_by_index, compare_by_name, iconvlist): New - functions. - -2002-01-06 Bruno Haible - - * lib/loop_unicode.h (unicode_transliterate): If the transliteration - fails due to limited output encoding, return RET_ILUNI, not - RET_TOOSMALL. Reported by Nelson H. F. Beebe . - * tests/check-translitfailure: New file. - * tests/TranslitFail1.ISO-8859-1: New file. - * tests/Makefile.in (check): Call check-translitfailure. - -2001-12-15 Bruno Haible - - * lib/euc_jp.h (euc_jp_wctomb): Add irreversible mappings for - Shift_JIS characters 0x5C and 0x7E. - * tests/EUC-JP.IRREVERSIBLE.TXT: New file. - -2001-12-05 Bruno Haible - - * lib/iconv.c (iconv_open): Recognize the empty encoding name. Avoid - endless loop if locale_charset() returns the empty string. - * README, man/iconv_open.3: Add the empty encoding name. - -2001-11-10 Bruno Haible - - * lib/Makefile.in (libiconv_plug_linux.so): Allow building it with a - non-gcc compiler. - -2001-10-23 Bruno Haible - - * tools/Makefile (cp1125.h): New target. - (ALL): Add it. - * lib/cp1125.h: New file. - * lib/converters.h: Include it. - * lib/encodings_dos.def (CP1125): New encoding. - -2001-09-08 Bruno Haible - - * autoconf/eilseq.m4: New file. - * Makefile.devel (OTHERMACROS): Add it. - * configure.in: Call AC_EILSEQ. - * include/iconv.h.in (EILSEQ): Define to the autoconf determined value. - -2001-08-25 Bruno Haible - - Upgrade to autoconf-2.52. - * autoconf/autoconf: Upgrade to autoconf-2.52. - * autoconf/acgeneral.m4: Remove file. - * autoconf/acspecific.m4: Remove file. - * autoconf/autoconf.m4f: New file, from autoconf-2.52. - * autoconf/aclocal.m4: Require autoconf-2.52. - (CL_CANONICAL_HOST): Call AC_CANONICAL_HOST. Don't cache the result, - AC_CANONICAL_HOST does it itself. Add $SHELL in front of - $ac_config_guess and $ac_config_sub. - * Makefile.devel (AUTOCONF_FILES): Remove acgeneral.m4, acspecific.m4. - Add autoconf.m4f. - (configure): Use autoconf options -A, -l instead of -m. - * configure.in: Use AC_CONFIG_SUBDIRS, not AC_OUTPUT_SUBDIRS. - -2001-08-05 Bruno Haible - - * autoconf/acgeneral.m4 (AC_MSG_RESULTPROTO): Remove macro. - (AC_LANG_EXTERN): Move to aclocal.m4. - * autoconf/aclocal.m4 (AC_LANG_EXTERN): Moved here from acgeneral.m4. - (CL_PROTO): Use AC_MSG_RESULT directly, instead of AC_MSG_RESULTPROTO. - (CL_SILENT): No need to pushdef AC_MSG_RESULTPROTO. - -2001-08-05 Bruno Haible - - Make it possible to build libiconv with CC=gcc CFLAGS="-x c++". - * lib/loop_wchar.h (wchar_to_loop_convert): Rename local variable - 'try' to 'incount'. - * lib/Makefile.in (libiconv_plug_linux.so): Add "-x none" option - between sources and libs. - (libiconv_plug_solaris.so) [GCC]: Likewise. - (libiconv_plug_osf.so) [GCC]: Likewise. - * src/Makefile.in (iconv.@OBJEXT@): New rule. - (iconv): Depend on it. - (clean): Erase *.@OBJEXT@, not *.o. - * tests/Makefile.in (table-from.@OBJEXT@): New rule. - (table-from): Depend on it. - (table-to.@OBJEXT@): New rule. - (table-to): Depend on it. - (clean): Erase *.@OBJEXT@, not *.o. - -2001-07-28 Bruno Haible - - * tools/Makefile (iso8859_16.h): Generate from the unicode.org table. - * lib/iso8859_16.h: Regenerated. - * tests/ISO-8859-16.TXT: Swap the values of 0xA5 and 0xAB. - -2001-07-17 Bruno Haible - - * configure.in (VERSION): Define. Needed by djgpp/Makefile.maint. - -2001-07-03 Bruno Haible - - * configure.in: Also check for mbsinit. - * lib/loop_wchar.h (mbsinit): Define to 1 if not defined. - Needed for SCO 3.2v5.0.2. - -2001-06-27 Bruno Haible - - * Version 1.7 released. - -2001-06-27 Bruno Haible - - * INSTALL.generic (Particular Systems): Generalize section about - /usr/local to "most systems". - - * lib/Makefile.in (all): Build @PLUGLIB@ before libiconv.la, because - Solaris cc destroys iconv.o and iconv.lo while building - libiconv_plug_solaris.so. - (clean): Remove so_locations, left there by the OSF/1 linker. - - * lib/cp1255.h (cp1255_decomp): Use 'signed int' instead of 'int'. - - * lib/vietcomb.h (viet_decomp): Use 'unsigned int' instead of - 'unsigned short'. - - * tests/table-from.c: Include string.h. - * tests/table-to.c: Likewise. - -2001-06-26 Bruno Haible - - * tools/Makefile (jisx0208.h): Replace U+005C with U+FF3C. - (jisx0212.h): Replace U+007E with U+FF5E. - * lib/jisx0208.h: Regenerated. - * lib/jisx0212.h: Regenerated. - * tests/EUC-JP.TXT: Map 0xA1C0 to U+FF3C. Map 0x8FA2B7 to U+FF5E. - * tests/EUC-JP.IRREVERSIBLE.TXT: Remove file. - * tests/SHIFT-JIS.TXT: Map 0x815F to U+FF3C. - * tests/CP932.TXT: Likewise. - * tests/CP932.IRREVERSIBLE.TXT: 0x815F mapping is now reversible. - -2001-06-25 Bruno Haible - - * src/Makefile.in (iconv): Mention $(INCLUDES) before $(CFLAGS) and - $(CPPFLAGS). - * src/Makefile.msvc (iconv.exe): Likewise. - * src/Makefile.os2 (iconv.exe): Likewise. - * lib/Makefile.in (libiconv_plug_linux.so): Likewise. - (libiconv_plug_solaris.so): Likewise. - (libiconv_plug_osf.so): Likewise. - (iconv.lo): Likewise. - * lib/Makefile.msvc (iconv.obj): Likewise. - * lib/Makefile.os2 (iconv.obj): Likewise. - * tests/Makefile.in (table-from, table-to): Likewise. - * tests/Makefile.msvc (table-from.exe, table-to.exe): Likewise. - * tests/Makefile.os2 (table-from.exe, table-to.exe): Likewise. - (genutf8.exe): Don't use $(INCLUDES). - -2001-06-25 Bruno Haible - - * include/iconv.h.in (_LIBICONV_VERSION), README, windows/iconv.rc: - Bump version number. - * lib/Makefile.in (LIBICONV_VERSION_INFO): Define to 2:4:0. - -2001-06-25 Bruno Haible - - * Makefile.devel (OTHERMACROS): Use libtool.m4 in libcharset subdir. - -2001-06-25 Bruno Haible - - * lib/encodings.def: Make SHIFT_JIS the primary name of SJIS. - -2001-06-08 Bruno Haible - - * autoconf/ltmain.sh: Upgrade to libtool-1.4. - * autoconf/ltconfig: Remove file. - -2001-06-08 Bruno Haible - - * autoconf/config.guess: Update to GNU version 2001-05-11. - * autoconf/config.sub: Likewise. - -2001-06-03 Bruno Haible - - * lib/loop_unicode.h (unicode_loop_convert): Ignore Unicode 3.1 tag - characters if they cannot be converted. - (unicode_loop_reset): Likewise. - * lib/iso2022_jp2.h (STATE_TAG_NONE, STATE_TAG_LANGUAGE, - STATE_TAG_LANGUAGE_j, STATE_TAG_LANGUAGE_ja, STATE_TAG_LANGUAGE_k, - STATE_TAG_LANGUAGE_ko, STATE_TAG_LANGUAGE_z, STATE_TAG_LANGUAGE_zh): - New macros. - (SPLIT_STATE, COMBINE_STATE): Different differently for wctomb - direction. - (iso2022_jp2_wctomb): Keep track of Unicode 3.1 language tag. - If "ja", prefer conversion to Japanese character sets. If "zh", - prefer conversion to GB2312. If "ko", prefer conversion to KSC5601. - - * lib/converters.h (RET_ILUNI): Change value from 0 to -1. - (RET_TOOSMALL): Change value from -1 to -2. - * lib/loop_unicode.h (unicode_transliterate): Allow xxx_wctomb to - return 0 written bytes. - -2001-06-06 Bruno Haible - - * lib/encodings.def: Align with IANA character-set registry. - (US-ASCII): Add alias "ANSI_X3.4-1986". - (ISO-8859-14): Add alias "ISO-CELTIC". - (JIS_X0208): Add alias "JIS_C6226-1983". - (BIG5HKSCS): Add alias "BIG5-HKSCS". - * README, man/iconv_open.3: Rename BIG5HKSCS to BIG5-HKSCS. - * tests/Makefile.in (check): Likewise. - * tests/Makefile.os2 (check): Likewise. - * tests/Makefile.msvc (check): Likewise. - * tests/BIG5-HKSCS.TXT: Renamed from BIG5HKSCS.TXT. - * tests/BIG5-HKSCS.IRREVERSIBLE.TXT: Renamed from - BIG5HKSCS.IRREVERSIBLE.TXT. - -2001-06-02 Bruno Haible - - * tools/cjk_tab_to_h.c (Encoding): Add fffd field. - (is_charset2uni_large, compact_large_charset2uni): New functions. - (find_charset2uni_pages): Use enc->fffd instead of 0xfffd. - (output_charset2uni): If mapping to more than the Unicode BMP, - use an extra indirection to keep each value in 16 bits. - (invert): Bump limit from U+10000 to U+30000. - (output_uni2charset_dense): Likewise. - (output_uni2charset_sparse): Likewise. If mapping to more than one - CJK plane, use three bytes per value instead of two bytes. - (byte_row_cns11643): Allow more than 3 CJK planes. - (do_cns11643_only_uni2charset): Increase number of rows, to include - plane 15. Remove plane bits hack. - (main): Accept names cns11643_4a,4b,5,6,7,15 as well. - * tools/Makefile (ALL): Add cns11643_4a.h, cns11643_4b.h, cns11643_5.h, - cns11643_6.h, cns11643_7.h, cns11643_15.h. - (cns11643_1.h, cns11643_2.h, cns11643_3.h): Use new Unicode 3.1 - derived table. - (cns11643_4a.h, cns11643_4b.h, cns11643_5.h, cns11643_6.h, - cns11643_7.h, cns11643_15.h): New rules. - (cns11643_inv.h): Change title. - * lib/cns11643_1.h: Regenerated from Unicode 3.1 derived table. - * lib/cns11643_3.h: Likewise. - * lib/cns11643_4a.h: New file. - * lib/cns11643_4b.h: New file. - * lib/cns11643_4.h: New file. - * lib/cns11643_5.h: New file. - * lib/cns11643_6.h: New file. - * lib/cns11643_7.h: New file. - * lib/cns11643_15.h: New file. - * lib/cns11643_inv.h: Regenerated from Unicode 3.1 derived table. - (cns11643_inv_wctomb): Return 3 bytes now. - * lib/cns11643.h: Include cns11643_4.h, cns11643_5.h, cns11643_6.h, - cns11643_7.h, cns11643_15.h. - (cns11643_wctomb): Now a simple alias to cns11643_inv_wctomb. Return - plane number starting at 1, not 0. - * lib/dec_hanyu.h (dec_hanyu_wctomb): Update for cns11643_wctomb - change. - * lib/euc_tw.h (euc_tw_mbtowc): Accept CNS11643 planes 4,5,6,7,15 as - well. - (euc_tw_wctomb): Update for cns11643_wctomb change. - * lib/iso2022_cn.h (iso2022_cn_wctomb): Likewise. - * lib/iso2022_cnext.h (iso2022_cn_ext_mbtowc): Accept CNS11643 planes - 4,5,6,7 as well. - (iso2022_cn_ext_wctomb): Update for cns11643_wctomb change. - Try CNS11643 planes 4,5,6,7 as well. - * tests/EUC-TW.TXT: Many additions, mostly in planes 3,4,5,6,7,15. - * tests/EUC-TW.IRREVERSIBLE.TXT: Reflect additions to CNS11643 plane 1. - Add U+5344. - -2001-06-01 Bruno Haible - - * tests/table-from.c (bmp_only): New variable. - (ucs4_decode): If bmp_only, don't return characters outside Unicode - plane 0. - (main): When testing UTF-8 or GB18030, set bmp_only to 1. Don't print - a conversion line if ucs4_decode returns NULL. - * tests/table-to.c (main): When testing encodings other than UTF-8 and - GB18030, loop upto U+30000 instead of U+10000. - -2001-05-24 Bruno Haible - - * lib/converters.h (mbtowc_funcs): Add flushwc member function. - * lib/flushwc.h: New file. - * lib/cp1255.h: Include flushwc.h. - (cp1255_comp_table_data, cp1255_comp_table): New arrays. - (cp1255_mbtowc): Compose base and combining characters. - (cp1255_flushwc): New macro. - * lib/vietcomb.h (viet_comp_table_data, viet_comp_table): New arrays. - * lib/cp1258.h: Include flushwc.h. - (cp1258_mbtowc): Compose base and combining characters. - (cp1258_flushwc): New macro. - * lib/tcvn.h: Include flushwc.h. - (tcvn_mbtowc): Compose base and combining characters. - (tcvn_flushwc): New macro. - * lib/loop_unicode.h: (unicode_transliterate): New function, extracted - from unicode_loop_convert. - (unicode_loop_convert): Use unicode_transliterate. - (unicode_loop_reset): Call xxx_flushwc and output the resulting - character. - * lib/encodings.def: Add xxx_flushwc member. - * lib/encodings_aix.def: Likewise. - * lib/encodings_dos.def: Likewise. - * lib/encodings_local.def: Likewise. - * lib/encodings_osf1.def: Likewise. - * lib/genaliases.c: Add an argument to the DEFENCODING macro. - * lib/genaliases2.c: Likewise. - * lib/genflags.c: Likewise. - * lib/iconv.c: Likewise. - * tests/table-from.c (try): Reset the iconv descriptor before the main - call, and flush it afterwards. - (ucs4_decode): New function. - (main): Allow up to 3 Unicode characters output. Call ucs4_decode. - * tests/CP1255-snippet: New file. - * tests/CP1255-snippet.UTF-8: New file. - * tests/CP1258-snippet: New file. - * tests/CP1258-snippet.UTF-8: New file. - * tests/TCVN-snippet: New file. - * tests/TCVN-snippet.UTF-8: New file. - * tests/Makefile.in (check): Check combining behaviour of CP1255, - CP1258, TCVN. - * tests/Makefile.msvc (check): Likewise. - * tests/Makefile.os2 (check): Likewise. - -2001-05-22 Bruno Haible - - * lib/converters.h (RET_ILUNI): New macro. - (RET_ILSEQ): Change value to -1. - (RET_TOOFEW): Change value. - * lib/loop_unicode.h (unicode_loop_convert): Write RET_ILUNI instead - of 0. Update handling of xxx_mbtowc return value. - * lib/genflags.c (emit_encoding): Likewise. - * lib/ascii.h (ascii_wctomb): Use RET_ILUNI instead of RET_ILSEQ. - * lib/armscii_8.h (armscii_8_wctomb): Likewise. - * lib/big5.h (big5_wctomb): Likewise. - * lib/big5hkscs.h (big5hkscs_wctomb): Likewise. - * lib/ces_big5.h (ces_big5_wctomb): Likewise. - * lib/ces_gbk.h (ces_gbk_wctomb): Likewise. - * lib/cns11643.h (cns11643_wctomb): Likewise. - * lib/cns11643_inv.h (cns11643_inv_wctomb): Likewise. - * lib/cp437.h (cp437_wctomb): Likewise. - * lib/cp775.h (cp775_wctomb): Likewise. - * lib/cp850.h (cp850_wctomb): Likewise. - * lib/cp852.h (cp852_wctomb): Likewise. - * lib/cp855.h (cp855_wctomb): Likewise. - * lib/cp856.h (cp856_wctomb): Likewise. - * lib/cp857.h (cp857_wctomb): Likewise. - * lib/cp861.h (cp861_wctomb): Likewise. - * lib/cp862.h (cp862_wctomb): Likewise. - * lib/cp864.h (cp864_wctomb): Likewise. - * lib/cp865.h (cp865_wctomb): Likewise. - * lib/cp866.h (cp866_wctomb): Likewise. - * lib/cp869.h (cp869_wctomb): Likewise. - * lib/cp874.h (cp874_wctomb): Likewise. - * lib/cp922.h (cp922_wctomb): Likewise. - * lib/cp932ext.h (cp932ext_wctomb): Likewise. - * lib/cp932.h (cp932_wctomb): Likewise. - * lib/cp936ext.h (cp936ext_wctomb): Likewise. - * lib/cp949.h (cp949_wctomb): Likewise. - * lib/cp950ext.h (cp950ext_wctomb): Likewise. - * lib/cp950.h (cp950_wctomb): Likewise. - * lib/cp1046.h (cp1046_wctomb): Likewise. - * lib/cp1124.h (cp1124_wctomb): Likewise. - * lib/cp1129.h (cp1129_wctomb): Likewise. - * lib/cp1133.h (cp1133_wctomb): Likewise. - * lib/cp1250.h (cp1250_wctomb): Likewise. - * lib/cp1251.h (cp1251_wctomb): Likewise. - * lib/cp1252.h (cp1252_wctomb): Likewise. - * lib/cp1253.h (cp1253_wctomb): Likewise. - * lib/cp1254.h (cp1254_wctomb): Likewise. - * lib/cp1255.h (cp1255_wctomb): Likewise. - * lib/cp1256.h (cp1256_wctomb): Likewise. - * lib/cp1257.h (cp1257_wctomb): Likewise. - * lib/cp1258.h (cp1258_wctomb): Likewise. - * lib/dec_hanyu.h (dec_hanyu_wctomb): Likewise. - * lib/dec_kanji.h (dec_kanji_wctomb): Likewise. - * lib/euc_cn.h (euc_cn_wctomb): Likewise. - * lib/euc_jp.h (euc_jp_wctomb): Likewise. - * lib/euc_kr.h (euc_kr_wctomb): Likewise. - * lib/euc_tw.h (euc_tw_wctomb): Likewise. - * lib/gb12345ext.h (gb12345ext_wctomb): Likewise. - * lib/gb12345.h (gb12345_wctomb): Likewise. - * lib/gb18030ext.h (gb18030ext_wctomb): Likewise. - * lib/gb18030.h (gb18030_wctomb): Likewise. - * lib/gb18030uni.h (gb18030uni_wctomb): Likewise. - * lib/gb2312.h (gb2312_wctomb): Likewise. - * lib/gbkext_inv.h (gbkext_inv_wctomb): Likewise. - * lib/gbk.h (gbk_wctomb): Likewise. - * lib/georgian_academy.h (georgian_academy_wctomb): Likewise. - * lib/georgian_ps.h (georgian_ps_wctomb): Likewise. - * lib/hkscs.h (hkscs_wctomb): Likewise. - * lib/hp_roman8.h (hp_roman8_wctomb): Likewise. - * lib/hz.h (hz_wctomb): Likewise. - * lib/iso2022_cnext.h (iso2022_cn_ext_wctomb): Likewise. - * lib/iso2022_cn.h (iso2022_cn_wctomb): Likewise. - * lib/iso2022_jp1.h (iso2022_jp1_wctomb): Likewise. - * lib/iso2022_jp2.h (iso2022_jp2_wctomb): Likewise. - * lib/iso2022_jp.h (iso2022_jp_wctomb): Likewise. - * lib/iso2022_kr.h (iso2022_kr_wctomb): Likewise. - * lib/iso646_cn.h (iso646_cn_wctomb): Likewise. - * lib/iso646_jp.h (iso646_jp_wctomb): Likewise. - * lib/iso8859_1.h (iso8859_1_wctomb): Likewise. - * lib/iso8859_2.h (iso8859_2_wctomb): Likewise. - * lib/iso8859_3.h (iso8859_3_wctomb): Likewise. - * lib/iso8859_4.h (iso8859_4_wctomb): Likewise. - * lib/iso8859_5.h (iso8859_5_wctomb): Likewise. - * lib/iso8859_6.h (iso8859_6_wctomb): Likewise. - * lib/iso8859_7.h (iso8859_7_wctomb): Likewise. - * lib/iso8859_8.h (iso8859_8_wctomb): Likewise. - * lib/iso8859_9.h (iso8859_9_wctomb): Likewise. - * lib/iso8859_10.h (iso8859_10_wctomb): Likewise. - * lib/iso8859_13.h (iso8859_13_wctomb): Likewise. - * lib/iso8859_14.h (iso8859_14_wctomb): Likewise. - * lib/iso8859_15.h (iso8859_15_wctomb): Likewise. - * lib/iso8859_16.h (iso8859_16_wctomb): Likewise. - * lib/isoir165ext.h (isoir165ext_wctomb): Likewise. - * lib/isoir165.h (isoir165_wctomb): Likewise. - * lib/jisx0201.h (jisx0201_wctomb): Likewise. - * lib/jisx0208.h (jisx0208_wctomb): Likewise. - * lib/jisx0212.h (jisx0212_wctomb): Likewise. - * lib/johab.h (johab_wctomb): Likewise. - * lib/johab_hangul.h (johab_hangul_wctomb, johab_hangul_decompose): - Likewise. - * lib/koi8_r.h (koi8_r_wctomb): Likewise. - * lib/koi8_ru.h (koi8_ru_wctomb): Likewise. - * lib/koi8_u.h (koi8_u_wctomb): Likewise. - * lib/ksc5601.h (ksc5601_wctomb): Likewise. - * lib/mac_arabic.h (mac_arabic_wctomb): Likewise. - * lib/mac_centraleurope.h (mac_centraleurope_wctomb): Likewise. - * lib/mac_croatian.h (mac_croatian_wctomb): Likewise. - * lib/mac_cyrillic.h (mac_cyrillic_wctomb): Likewise. - * lib/mac_greek.h (mac_greek_wctomb): Likewise. - * lib/mac_hebrew.h (mac_hebrew_wctomb): Likewise. - * lib/mac_iceland.h (mac_iceland_wctomb): Likewise. - * lib/mac_roman.h (mac_roman_wctomb): Likewise. - * lib/mac_romania.h (mac_romania_wctomb): Likewise. - * lib/mac_thai.h (mac_thai_wctomb): Likewise. - * lib/mac_turkish.h (mac_turkish_wctomb): Likewise. - * lib/mac_ukraine.h (mac_ukraine_wctomb): Likewise. - * lib/mulelao.h (mulelao_wctomb): Likewise. - * lib/nextstep.h (nextstep_wctomb): Likewise. - * lib/sjis.h (sjis_wctomb): Likewise. - * lib/tcvn.h (tcvn_wctomb): Likewise. - * lib/tis620.h (tis620_wctomb): Likewise. - * lib/ucs2be.h (ucs2be_wctomb): Likewise. - * lib/ucs2.h (ucs2_wctomb): Likewise. - * lib/ucs2internal.h (ucs2internal_wctomb): Likewise. - * lib/ucs2le.h (ucs2le_wctomb): Likewise. - * lib/ucs2swapped.h (ucs2swapped_wctomb): Likewise. - * lib/ucs4.h (ucs4_wctomb): Likewise. - * lib/uhc_1.h (uhc_1_wctomb): Likewise. - * lib/uhc_2.h (uhc_2_wctomb): Likewise. - * lib/utf16be.h (utf16be_wctomb): Likewise. - * lib/utf16.h (utf16_wctomb): Likewise. - * lib/utf16le.h (utf16le_wctomb): Likewise. - * lib/utf32be.h (utf32be_wctomb): Likewise. - * lib/utf32.h (utf32_wctomb): Likewise. - * lib/utf32le.h (utf32le_wctomb): Likewise. - * lib/utf7.h (utf7_wctomb): Likewise. - * lib/utf8.h (utf8_wctomb): Likewise. - * lib/viscii.h (viscii_wctomb): Likewise. - * tools/8bit_tab_to_h.c (main): Likewise. - * tools/cjk_tab_to_h.c (output_uni2charset_dense, - output_uni2charset_sparse, do_gb18030uni): Likewise. - -2001-05-19 Bruno Haible - - * Makefile.devel (all): Add man/{iconv.1,iconv*.3}.html. - (man/%.html): New rule. - * man/Makefile.in (docdir, htmldir): New variables. - (install, installdirs): Install the HTML formatted man pages in - $(htmldir). - (uninstall): Uninstall them. - -2001-05-20 Bruno Haible - - * lib/cp1255.h (cp1255_decomp_table): New array. - (cp1255_comb_table): New array. - (cp1255_wctomb): Decompose Unicode characters. - * tests/CP1255.IRREVERSIBLE.TXT: New file. - -2001-05-13 Bruno Haible - - * lib/vietcomb.h: New file. - * lib/cp1258.h: Include it. - (cp1258_comb_table): New array. - (cp1258_wctomb): Decompose Unicode characters. - * lib/tcvn.h: Include it. - (tcvn_comb_table): New array. - (tcvn_wctomb): Decompose Unicode characters. - * tests/CP1258.IRREVERSIBLE.TXT: New file. - * tests/TCVN.IRREVERSIBLE.TXT: New file. - -2001-05-06 Bruno Haible - - * lib/Makefile.msvc (config.h): Allow the 'del' command to fail. - (iconv.lib): Likewise. - -2001-05-06 Bruno Haible - - * lib/Makefile.in (CPPFLAGS, LDFLAGS): New variables. - (CPP): Remove variable. - (libiconv.la, libiconv_plug_linux.so, libiconv_plug_solaris.so, - libiconv_plug_osf.so): Use LDFLAGS. - (libiconv_plug_linux.so, libiconv_plug_solaris.so, - libiconv_plug_osf.so, iconv.lo): Use CPPFLAGS. - * lib/Makefile.msvc (CPP): Remove variable. - * src/Makefile.in (CPPFLAGS, LDFLAGS): New variables. - (CPP): Remove variable. - (iconv): Use CPPFLAGS and LDFLAGS. - * src/Makefile.msvc (CPP): Remove variable. - * tests/Makefile.in (CPPFLAGS, LDFLAGS): New variables. - (check, table-from, table-to): Use CPPFLAGS and LDFLAGS. - * tests/Makefile.msvc (CPP): Remove variable. - -2001-05-06 Bruno Haible - - * lib/Makefile.in (libiconv_plug_solaris.so): Change rule if not using - gcc. Reported by Paananen Mikko . - -2001-04-11 Bruno Haible - - Implement and document UTF-32, UTF-32BE, UTF-32LE. - * src/utf32.h, src/utf32be.h, src/utf32le.h: New files. - * src/converters.h: Include them. - * src/encodings.def (UTF-32, UTF-32BE, UTF32LE): New encodings. - * README, man/iconv_open.3: Add UTF-32, UTF-32BE, UTF32LE. - * tests/Makefile.in (check): Check UTF-32, UTF-32BE, UTF32LE. - * tests/Makefile.os2 (check): Likewise. - * tests/Makefile.msvc (check): Likewise. - * tests/UTF-32*snippet*: New files. - - * lib/ucs4.h (ucs4_mbtowc): Fix value of other-endian byte order. - (ucs4_wctomb): Allow any 31-bit codepoint. - -2001-04-11 Bruno Haible - - * tests/GB18030.TXT: Add mappings for all of U+0000..U+FFFF, including - unassigned code points. - * tests/table-from.c (main); When dumping GB18030, don't print code - points larger than U+FFFF. - -2001-03-30 Bruno Haible - - * tools/Makefile (GB18030uni.TXT): Use a table source which includes - the unassigned Unicode code points. - * lib/gb18030uni.h: Update. - (gb18030uni_ranges): Remove bitmap_offset field. - (gb18030uni_bitmap): Remove array. - (gb18030uni_mbtowc): Omit gb18030uni_bitmap access. - (gb18030uni_wctomb): Likewise. - * lib/gb18030.h (gb18030_mbtowc): Handle Unicode characters >= 0x10000. - (gb18030_wctomb): Likewise. - -2001-03-21 Bruno Haible - - * INSTALL.generic (Particular Systems): Add recommendations for AIX 3. - -2001-03-21 Bruno Haible - - * src/iconv.c (print_version): Now called GNU libiconv. - -2001-03-20 Bruno Haible - - * README: This package is now called GNU libiconv. - - * tools/8bit_tab_to_h.c (main): Emit copyright notice to the output - file. - * tools/cjk_tab_to_h.c (output_title): Likewise. - * tools/cjk_variants.c (main): Likewise. - * lib/gentranslit.c (main): Likewise. - -2001-03-19 Bruno Haible - - * autoconf/aclocal.m4 (CL_CANONICAL_HOST): Always define - ac_config_guess and ac_config_sub. Then ignore requests for - AC_CONFIG_AUX_DIR_DEFAULT or AC_CANONICAL_HOST. - -2001-03-10 Bruno Haible - - * INSTALL.generic: New section "Particular Systems". - -2001-03-10 Bruno Haible - - * lib/Makefile.in (libiconv.la): Pass flag -no-undefined. Needed on - platforms like BeOS. - - * lib/loop_wchar.h (mbstate_t): Don't typedef if already #defined in - config.h. - -2001-03-06 Bruno Haible - - * Version 1.6 released. - * include/iconv.h.in (_LIBICONV_VERSION), README, windows/iconv.rc: - Bump version number. - * lib/Makefile.in (LIBICONV_VERSION_INFO): Define to 2:3:0. - -2001-03-05 Bruno Haible - - Provide all encodings used by OSF/1 5.1 locales. - * lib/dec_kanji.h: New file. - * lib/dec_hanyu.h: New file. - * lib/converters.h: Include them if USE_OSF1 is defined. - * lib/encodings_osf1.def: New file. - * lib/genflags.c (main): Include it. Define USE_OSF1. - * lib/genaliases2.c (main): Include it conditionally. - * lib/iconv.c: Define USE_OSF1 on OSF/1. - Include encodings_osf1.def and aliases_osf1.h. - * lib/Makefile.in (iconv.lo): Depend on encodings_osf1.def and - aliases_osf1.h. - * Makefile.devel (lib/aliases_osf1.h): New target. - (all): Depend on lib/aliases_osf1.h. - (lib/flags.h): Depend on lib/encodings_osf1.def. - -2001-03-01 Bruno Haible - - * tools/Makefile (cp775.h): New target. - (ALL): Add it. - * lib/cp775.h: New file. - * lib/converters.h: Include it. - * lib/encodings_dos.def (CP775): New encoding. - -2001-02-25 Bruno Haible - - * lib/iconv.c (iconv_open): locale_charset() doesn't return NULL any - more. - -2001-02-24 Bruno Haible - - * src/iconv.c (convert): Use ICONV_CONST. - * tests/table-from.c: Include config.h. - (try): Use ICONV_CONST. - * tests/table-to.c: Include config.h. - (main): Use ICONV_CONST. - * tests/Makefile.in (INCLUDES): Add -I../lib. - * tests/Makefile.os2 (INCLUDES): Likewise. - * tests/Makefile.msvc (INCLUDES): Add -I..\lib. - -2001-02-24 Bruno Haible - - Provide all encodings used by DOS locales. - * tools/Makefile (cp437.h, cp852.h, cp855.h, cp857.h, cp861.h, - cp864.h, cp865.h, cp869.h): New targets. - (ALL): Add them. - * lib/cp437.h: New file. - * lib/cp852.h: New file. - * lib/cp855.h: New file. - * lib/cp857.h: New file. - * lib/cp861.h: New file. - * lib/cp864.h: New file. - * lib/cp865.h: New file. - * lib/cp869.h: New file. - * lib/converters.h: Include them if USE_DOS is defined. - * lib/encodings_dos.def: New file. - * lib/genflags.c (main): Include it. Define USE_DOS. - * lib/genaliases2.c (main): Include it conditionally. - * lib/iconv.c: Define USE_DOS on DJGPP. - Include encodings_dos.def and aliases_dos.h. - * lib/Makefile.in (iconv.lo): Depend on encodings_dos.def and - aliases_dos.h. - * Makefile.devel (lib/aliases_dos.h): New target. - (all): Depend on lib/aliases_dos.h. - (lib/flags.h): Depend on lib/encodings_dos.def. - -2001-02-23 Bruno Haible - - * src/iconv.c [DJGPP]: Include and . - (SET_BINARY) [O_BINARY]: New macro. - (usage): Mention --binary if available. - (convert): Use SET_BINARY instead of setmode. - (main): Likewise. - Reported by Juan Manuel Guerrero . - -2001-02-25 Bruno Haible - - * autoconf/ltconfig: - sed -e 's/reload object files/produce relocatable object files/'. - -2001-02-20 Bruno Haible - - * src/iconv.c (usage, main): Make -f and -t options optional. - * man/iconv.1: Mark them as optional. - -2001-02-20 Bruno Haible - - * tools/Makefile (GB18030ext.TXT, GB18030uni.TXT): Generate from - glibc-2.2.2 table. - * lib/gb18030uni.h, lib/gb18030ext.h: Add mapping 0xA989 -> U+303E, - 0xFE5E -> U+2E97. Shift the entire four-byte range. - * tests/GB18030.TXT: Regenerated. - -2001-02-20 Bruno Haible - - Better support for DOS/Windows platforms. - * autoconf/ltconfig: Upgrade to libtool-1.3.5. - * autoconf/ltmain.sh: Likewise. - * autoconf/aclocal.m4: Likewise. - * autoconf/install-sh: New file. - * configure.in: Call AC_OBJEXT and AC_EXEEXT. Call AC_CONFIG_AUX_DIR. - -2001-02-20 Bruno Haible - - * Makefile.in (libdir, includedir, mandir): Use the autoconf - determined value, in order to respect the configure arguments. - * lib/Makefile.in (libdir): Likewise. - * src/Makefile.in (bindir): Likewise. - * man/Makefile.in (mandir): Likewise. - -2001-02-04 Bruno Haible - - * lib/translit.def: Add all the neutral transliterations from glibc. - * lib/gentranslit.c (main): Allow UTF-8 replacements which are in - UCS-2 but not in ISO-8859-1. Generate a table of 'unsigned short'. - Avoid accessing data[-1]. - * lib/loop_unicode.h (unicode_loop_convert): Change type of pointer - into translit_data. - -2001-01-05 Bruno Haible - - Implement and document CP862. - * tools/Makefile (ALL): Add cp862.h. - (cp862.h): New target. - * lib/cp862.h: New file. - * lib/converters.h: Include it. - * lib/encodings.def (CP862): New encoding. - * README, man/iconv_open.3: Add CP862. - * tests/Makefile.in (check): Check CP862. - * tests/Makefile.msvc (check): Likewise. - * tests/Makefile.os2 (check): Likewise. - * tests/CP862.TXT: New file. - -2000-12-18 Bruno Haible - - * autoconf/mbstate_t.m4: New file, from textutils-2.0.10. - * Makefile.devel (OTHERMACROS): Add it. - * configure.in: Call AC_MBSTATE_T. - * lib/config.h.in (mbstate_t): New definition. - * lib/loop_wchar.h (mbrtowc): For BeOS, declare and define fallback. - -2000-12-12 Bruno Haible - - * Makefile.in: Use $(MAKE) instead of $(MAKE) -r. Needed with Solaris - "make", which doesn't set MAKE as expected by @SET_MAKE@ if -r is - given. Reported by Toshimitsu Fujiwara. - -2000-12-08 Bruno Haible - - * Makefile.in (exec_prefix): Use configure's --exec-prefix argument. - * lib/Makefile.in (exec_prefix): Likewise. - * src/Makefile.in (exec_prefix): Likewise. - * man/Makefile.in (exec_prefix): Likewise. - -2000-12-02 Bruno Haible - - * Version 1.5 released. - * include/iconv.h.in (_LIBICONV_VERSION), README, windows/iconv.rc: - Bump version number. - * lib/Makefile.in (LIBICONV_VERSION_INFO): Define to 2:2:0. - -2000-12-02 Bruno Haible - - * Makefile.in (mostlyclean, clean, distclean, maintainer-clean): - Remove files installed in lib by libcharset. - * Makefile.msvc (mostlyclean): Likewise. - - * Makefile.in (check): Depend on target 'all'. - * Makefile.os2 (check): Likewise. - * Makefile.msvc (check): Depend on target 'force' as well. - - * src/iconv.c (usage): Take an exitcode argument. - (print_version): New function. - (main): Recognize --help and --version command line options. - -2000-12-02 Bruno Haible - - * Makefile.msvc: Replace STATIC with its opposite flag, DLL. - * lib/Makefile.msvc: Likewise. - * src/Makefile.msvc: Likewise. - * tests/Makefile.msvc: Likewise. - -2000-12-01 Bruno Haible - - * src/iconv.c: Include . Define fallbacks for setmode, fileno. - (force_binary): New variable. - (convert): If requested, set the input O_BINARY. - (main): Accept --binary option. If requested, set the output O_BINARY. - * tests/check-stateful.bat: Pass --binary to iconv. - * tests/check-stateful.cmd: Likewise. - * tests/check-translit.bat: Likewise. - * tests/check-translit.cmd: Likewise. - -2000-12-01 Bruno Haible - - * include/iconv.h.in (_libiconv_version): New declaration. - * lib/iconv.c (_libiconv_version): New variable. - -2000-11-30 Bruno Haible - - * Makefile.msvc (all): File now named lib/libcharset.h. - (clean, distclean, maintainer-clean): Likewise. - -2000-11-23 Bruno Haible - - * lib/*: Move here all files from src/*. - * src/*: Move all files to lib. - * lib/Makefile.in (distclean): No need to remove config.status, - config.log, config.cache. - * configure.in: Require lib/iconv.c, not src/iconv.c. Create - lib/config.h, not src/config.h. Also create lib/Makefile. - * Makefile.in (all): Install libcharset into lib, not src. Recurse - into lib and src. - (install-lib): Recurse into lib, not src. - (install): Recurse into libcharset, lib and src. - (installdirs, uninstall): Likewise. - (check, mostlyclean, clean, distclean, maintainer-clean): Likewise. - * Makefile.msvc (all): Recurse into lib and src. - (install): Recurse into libcharset, lib and src. - (installdirs, uninstall): Likewise. - (check, mostlyclean, clean, distclean, maintainer-clean): Likewise. - * Makefile.os2 (all): Recurse into lib and src. - (install-lib): Recurse into lib, not src. - (install, uninstall): Recurse into lib and src. - (check, mostlyclean, clean, distclean, maintainer-clean): Likewise. - * Makefile.devel (lib/config.h.msvc): Renamed from src/config.h.msvc. - (lib/aliases.h): Renamed from src/aliases.h. - (lib/aliases.gperf): Renamed from src/aliases.gperf. - (lib/aliases_aix.h): Renamed from src/aliases_aix.h. - (lib/flags.h): Renamed from src/flags.h. - (lib/translit.h): Renamed from src/translit.h. - * src/iconv.c: Moved here from tests/iconv.c. - * src/Makefile.in: New file. - * src/Makefile.msvc: New file. - * src/Makefile.os2: New file. - * tests/Makefile.in (iconv): Remove target. - (../lib/libiconv.la): Renamed from ../src/libiconv.la. - (clean): No need to remove iconv. - * tests/Makefile.msvc (iconv.exe): Remove target. - * tests/Makefile.os2 (iconv.exe): Likewise. - * tests/check-stateful: iconv is in ../src. - * tests/check-stateful.bat: Likewise. - * tests/check-stateful.cmd: Likewise. - * tests/check-translit: iconv is in ../src. - * tests/check-translit.bat: Likewise. - * tests/check-translit.cmd: Likewise. - * man/iconv.1: New file. - * man/Makefile.in (install, installdirs, uninstall): Also install *.1 - man pages. - * man/Makefile.os2 (MAN3): Renamed from MAN. - (MAN1): New variable. - (install, uninstall): Also install *.1 man pages. - -2000-11-21 Bruno Haible - - * Makefile.msvc (all, check, mostlyclean, clean, distclean, - maintainer-clean): Recurse into libcharset. - (clean, distclean, maintainer-clean): Remove src\libcharset.h. - * src/Makefile.msvc (LIBCHARSET_OBJECTS): New variable. - (iconv.lib): Link with $(LIBCHARSET_OBJECTS). - -2000-11-18 Bruno Haible - - * src/cp950.h (cp950_mbtowc, cp950_wctomb): Change implementation - so that it agrees with Microsoft's definition of CP950. - * tests/CP950.TXT: Likewise. - * tests/CP950.IRREVERSIBLE.TXT: Add 0xA244, 0xA2CC, 0xA2CE. - -2000-11-18 Bruno Haible - - Add support for locale dependent "char" and "wchar_t" encodings. - * libcharset: New subdirectory. - * src/loop_unicode.h: New file, extracted from src/iconv.c. - * src/loop_wchar.h: New file. - * src/loops.h: New file. Include loop_unicode.h and loop_wchar.h. - * src/encodings_local.def: New file. - * src/genaliases.c: Also create aliases for encodings_local.def. - * src/converters.h (conv_struct): Add lfuncs field. - * src/genflags.c: Add dummy definitions of struct loop_funcs. - * src/iconv.c: Include libcharset.h. - (loop_funcs): New structure. - Treat encodings_local.def like encodings.def. - Include loops.h. - (iconv_open): Move the bulk of the code to loop_unicode.h. - (iconv): Likewise. - (iconvctl): Extend determination of TRIVIALP to wchar_t conversion - descriptors. - * src/Makefile.in (PLUG_SOURCES): Remove variable. - (LIBCHARSET_OBJECTS): New variable. - (libiconv.la): Link in the LIBCHARSET_OBJECTS. - (libiconv_plug_linux.so, libiconv_plug_solaris.so, - libiconv_plug_osf.so): Link in the LIBCHARSET_OBJECTS, using - LIBTOOL_LINK. - (iconv.lo): Depend on encodings_local.def. - * src/Makefile.msvc (iconv.obj): Depend on encodings_local.def. - * src/Makefile.os2 (iconv.obj): Likewise. - * configure.in: Add tests for locale.h, mbrtowc, wcrtomb, setlocale. - Recurse into libcharset. - * src/config.h.in (HAVE_LOCALE_H, HAVE_MBRTOWC, HAVE_WCRTOMB, - HAVE_SETLOCALE): New macros. - * tests/iconv.c: Include config.h and locale.h. - (main): Call setlocale. - * tests/Makefile.in (iconv): Search for config.h in ../src. - * tests/Makefile.os2 (iconv.exe): Likewise. - * tests/Makefile.msvc (iconv.exe): Likewise. - * README, man/iconv_open.3: Document "char" and "wchar_t" encodings. - * Makefile.in: After "cd", use "&&" not ";". - (all, check, mostlyclean, clean, distclean, maintainer-clean): - Recurse into libcharset. - * Makefile.devel (all): Recurse into libcharset. - (src/aliases.gperf): Depend on src/encodings_local.def. - -2000-11-18 Bruno Haible - - * src/converters.h (ucs4_t): New type. - (wchar_t): Remove locally defined override. - (mbtowc_funcs, wctomb_funcs): Use ucs4_t instead of wchar_t. - * src/iconv.c (iconv): Likewise. - * src/genflags.c (emit_encoding): Use ucs4_t instead of wchar_t. - * tools/8bit_tab_to_h.c: Use "ucs4_t" instead of "wchar_t". - * tools/cjk_tab_to_h.c: Likewise. - * src/armscii_8.h: Use ucs4_t instead of wchar_t. - * src/ascii.h: Likewise. - * src/big5.h: Likewise. - * src/big5hkscs.h: Likewise. - * src/ces_big5.h: Likewise. - * src/ces_gbk.h: Likewise. - * src/cns11643.h: Likewise. - * src/cns11643_1.h: Likewise. - * src/cns11643_2.h: Likewise. - * src/cns11643_3.h: Likewise. - * src/cns11643_inv.h: Likewise. - * src/cp1046.h: Likewise. - * src/cp1124.h: Likewise. - * src/cp1129.h: Likewise. - * src/cp1133.h: Likewise. - * src/cp1250.h: Likewise. - * src/cp1251.h: Likewise. - * src/cp1252.h: Likewise. - * src/cp1253.h: Likewise. - * src/cp1254.h: Likewise. - * src/cp1255.h: Likewise. - * src/cp1256.h: Likewise. - * src/cp1257.h: Likewise. - * src/cp1258.h: Likewise. - * src/cp850.h: Likewise. - * src/cp856.h: Likewise. - * src/cp866.h: Likewise. - * src/cp874.h: Likewise. - * src/cp922.h: Likewise. - * src/cp932.h: Likewise. - * src/cp932ext.h: Likewise. - * src/cp936ext.h: Likewise. - * src/cp949.h: Likewise. - * src/cp950.h: Likewise. - * src/cp950ext.h: Likewise. - * src/euc_cn.h: Likewise. - * src/euc_jp.h: Likewise. - * src/euc_kr.h: Likewise. - * src/euc_tw.h: Likewise. - * src/gb12345.h: Likewise. - * src/gb12345ext.h: Likewise. - * src/gb18030.h: Likewise. - * src/gb18030ext.h: Likewise. - * src/gb18030uni.h: Likewise. - * src/gb2312.h: Likewise. - * src/gbk.h: Likewise. - * src/gbkext1.h: Likewise. - * src/gbkext2.h: Likewise. - * src/gbkext_inv.h: Likewise. - * src/georgian_academy.h: Likewise. - * src/georgian_ps.h: Likewise. - * src/hkscs.h: Likewise. - * src/hp_roman8.h: Likewise. - * src/hz.h: Likewise. - * src/iso2022_cn.h: Likewise. - * src/iso2022_cnext.h: Likewise. - * src/iso2022_jp.h: Likewise. - * src/iso2022_jp1.h: Likewise. - * src/iso2022_jp2.h: Likewise. - * src/iso2022_kr.h: Likewise. - * src/iso646_cn.h: Likewise. - * src/iso646_jp.h: Likewise. - * src/iso8859_1.h: Likewise. - * src/iso8859_10.h: Likewise. - * src/iso8859_13.h: Likewise. - * src/iso8859_14.h: Likewise. - * src/iso8859_15.h: Likewise. - * src/iso8859_16.h: Likewise. - * src/iso8859_2.h: Likewise. - * src/iso8859_3.h: Likewise. - * src/iso8859_4.h: Likewise. - * src/iso8859_5.h: Likewise. - * src/iso8859_6.h: Likewise. - * src/iso8859_7.h: Likewise. - * src/iso8859_8.h: Likewise. - * src/iso8859_9.h: Likewise. - * src/isoir165.h: Likewise. - * src/isoir165ext.h: Likewise. - * src/java.h: Likewise. - * src/jisx0201.h: Likewise. - * src/jisx0208.h: Likewise. - * src/jisx0212.h: Likewise. - * src/johab.h: Likewise. - * src/johab_hangul.h: Likewise. - * src/koi8_r.h: Likewise. - * src/koi8_ru.h: Likewise. - * src/koi8_u.h: Likewise. - * src/ksc5601.h: Likewise. - * src/mac_arabic.h: Likewise. - * src/mac_centraleurope.h: Likewise. - * src/mac_croatian.h: Likewise. - * src/mac_cyrillic.h: Likewise. - * src/mac_greek.h: Likewise. - * src/mac_hebrew.h: Likewise. - * src/mac_iceland.h: Likewise. - * src/mac_roman.h: Likewise. - * src/mac_romania.h: Likewise. - * src/mac_thai.h: Likewise. - * src/mac_turkish.h: Likewise. - * src/mac_ukraine.h: Likewise. - * src/mulelao.h: Likewise. - * src/nextstep.h: Likewise. - * src/sjis.h: Likewise. - * src/tcvn.h: Likewise. - * src/tis620.h: Likewise. - * src/ucs2.h: Likewise. - * src/ucs2be.h: Likewise. - * src/ucs2internal.h: Likewise. - * src/ucs2le.h: Likewise. - * src/ucs2swapped.h: Likewise. - * src/ucs4.h: Likewise. - * src/ucs4be.h: Likewise. - * src/ucs4internal.h: Likewise. - * src/ucs4le.h: Likewise. - * src/ucs4swapped.h: Likewise. - * src/uhc_1.h: Likewise. - * src/uhc_2.h: Likewise. - * src/utf16.h: Likewise. - * src/utf16be.h: Likewise. - * src/utf16le.h: Likewise. - * src/utf7.h: Likewise. - * src/utf8.h: Likewise. - * src/viscii.h: Likewise. - -2000-11-18 Bruno Haible - - Make transliteration optional. - * src/iconv.c (iconv_open): Strip off //TRANSLIT suffix from names. - Set transliteration on if and only if tocode ends in //TRANSLIT. - * README, man/iconv_open.3: Document how to enable transliteration. - * tests/check-translit: Add //TRANSLIT to iconv's 't' argument. - * tests/check-translit.bat: Likewise. - * tests/check-translit.cmd: Likewise. - -2000-11-18 Bruno Haible - - * man/iconv.3: Fix typo. - -2000-10-31 Bruno Haible - - * README, man/iconv_open.3: Document JOHAB again. - -2000-11-15 Bruno Haible - - * Makefile.msvc: Add support for MFLAGS and DEBUG parameters. - (STATIC): Change default from 0 to 1. - * src/Makefile.msvc: Likewise. - * tests/Makefile.msvc: Likewise. - * tests/check-stateless.bat: Call 'sort' with no arguments. - -2000-11-12 Bruno Haible - - * autoconf/config.guess, autoconf/config.sub: Upgrade to newest - version from GNU CVS. - -2000-10-24 Bruno Haible - - * Version 1.4 released. - * include/iconv.h.in (_LIBICONV_VERSION), README, windows/iconv.rc: - Bump version number. - * src/Makefile.in (LIBICONV_VERSION_INFO): Define to 2:1:0. - -2000-10-23 Bruno Haible - - Implement and document GB18030 and BIG5HKSCS. - * tools/cjk_tab_to_h.c (row_byte_hkscs, byte_row_hkscs, do_hkscs): New - functions. - (do_gb18030uni): New function. - (main): Accept gb18030ext, gb18030uni, hkscs. - * tools/Makefile (ALL): Add gb18030ext.h, gb18030uni.h, hkscs.h. - (gb18030ext.h, GB18030ext.TXT, gb18030uni.h, GB18030uni.TXT, - hkscs.h): New targets. - * src/gb18030ext.h, src/gb18030uni.h, src/gb18030.h: New files. - * src/hkscs.h, src/big5hkscs.h: New files. - * src/converters.h: Include gb18030.h and big5hkscs.h. - * src/encodings.def (GB18030, BIG5HKSCS): New encodings. - * README, man/iconv_open.3: Add GB18030, BIG5HKSCS. - * tests/Makefile.in (check): Check GB18030, BIG5HKSCS. - * tests/Makefile.msvc (check): Likewise. - * tests/Makefile.os2 (check): Likewise. - * tests/GB18030.TXT: New file. - * tests/BIG5HKSCS.TXT, tests/BIG5HKSCS.IRREVERSIBLE.TXT: New files. - -2000-10-23 Bruno Haible - - * tests/table-from.c (try, main): Use UCS-4-INTERNAL instead of - UCS-2-INTERNAL, to avoid problems with UCS-2 surrogate handling. - * tests/table-to.c (main): Likewise. - -2000-10-22 Bruno Haible - - * src/gentranslit.c (main): Read the input in UTF-8 encoding. - -2000-10-09 Bruno Haible - - CPU recognition on OpenBSD. - * autoconf/aclocal.m4 (CL_WORDS_LITTLEENDIAN): Recognize __m68k__, - __mc68020__, __MIPSEB__, __MIPSEL__, __m88k__ as CPU indicators. - -2000-10-03 Bruno Haible - - * src/gentranslit.c (main): Don't output non-ASCII ISO-8859-1 - character literals, use the numeric value instead. - Reported by Shin-Hsien Yeh . - -2000-09-29 Bruno Haible - - * autoconf/aclocal.m4 (CL_CANONICAL_HOST): Fix bug in 2000-05-23 - change. - -2000-09-25 Bruno Haible - - * autoconf/aclocal.m4 (CL_WORDS_LITTLEENDIAN): Recognize __i386__ - as equivalent to __i386. For OpenBSD. - -2000-09-21 Bruno Haible - - * src/utf16.h (utf16_wctomb): Reject single surrogates. - * src/utf16be.h (utf16be_wctomb): Likewise. - * src/utf16le.h (utf16le_wctomb): Likewise. - * src/ucs2.h (ucs2_mbtowc, ucs2_wctomb): Likewise. - * src/ucs2be.h (ucs2be_mbtowc, ucs2be_wctomb): Likewise. - * src/ucs2le.h (ucs2le_mbtowc, ucs2le_wctomb): Likewise. - * src/ucs2internal.h (ucs2internal_mbtowc, ucs2internal_wctomb): - Likewise. - * src/ucs2swapped.h (ucs2swapped_mbtowc, ucs2swapped_wctomb): - Likewise. - -2000-09-15 Bruno Haible - - * Makefile.in (install, installdirs, uninstall): Support DESTDIR. - * src/Makefile.in (install, installdirs, uninstall): Likewise. - * man/Makefile.in (install, installdirs, uninstall): Likewise. - -2000-09-11 Bruno Haible - - * src/utf7.h (utf7_mbtowc): Fix combining of UTF-16 surrogates. - -2000-08-26 Bruno Haible - - * autoconf/acgeneral.m4 (AC_OUTPUT): Use braces in exec_prefix default - value, not parens. - -2000-07-04 Akira Hatakeyama - Bruno Haible - - * os2/iconv.def, README.os2, Makefile.os2, src/Makefile.os2, - tests/Makefile.os2, man/Makefile.os2, tests/check-stateful.cmd, - tests/check-stateless.cmd, tests/check-translit.cmd: New files. - -2000-06-28 Bruno Haible - - * src/ucs2internal.h (ucs2internal_mbtowc): Avoid gcc warning about - cast. - * src/ucs4internal.h (ucs4internal_mbtowc): Likewise. - * src/ucs2swapped.h (ucs2swapped_mbtowc, ucs2swapped_wctomb): Verify - sizeof(unsigned short). - * src/ucs4swapped.h (ucs4swapped_mbtowc, ucs4swapped_mbtowc): Verify - sizeof(unsigned int). - Reported by Franรงois Pinard . - -2000-05-29 Bruno Haible - - * autoconf/aclocal.m4 (CL_PROG_INSTALL): Fix typo. - Reported by Thomas Klausner . - -2000-05-23 Bruno Haible - - * autoconf/aclocal.m4 (CL_CANONICAL_HOST): Determine host_cpu, - host_vendor, host_os correctly if $host has more than two hyphens. - -2000-04-15 Bruno Haible - - * Version 1.3 released. - * include/iconv.h.in (_LIBICONV_VERSION), README, windows/iconv.rc: - Bump version number. - * src/Makefile.in (LIBICONV_VERSION_INFO): Define to 2:0:0. - -2000-04-15 Bruno Haible - - * THANKS: New file. - * INSTALL.generic: New file. - - Implement and document UCS-2BE, UCS-2LE, UCS-4BE, UCS-4LE. - * src/ucs2be.h, src/ucs2le.h, src/ucs4be.h, src/ucs4le.h: New files. - * src/converters.h: Include them. - * src/ucs2swapped.h: Remove #defines for UCS-2-BE, UCS-2-LE. - * src/ucs4swapped.h: Remove #defines for UCS-4-BE, UCS-4-LE. - * src/encodings.def (UCS-2BE): Renamed from UCS-2-BE. - (UCS-2LE): Renamed from UCS-2-LE. - (UCS-4BE): Renamed from UCS-4-BE. - (UCS-4LE): Renamed from UCS-4-LE. - * Makefile.devel (src/aliases.h): Pass option "-i 1" to gperf. - * README, man/iconv_open.3: Add UCS-2BE, UCS-2LE, UCS-4BE, UCS-4LE. - * tests/Makefile.in (check): Check UCS-2BE, UCS-2LE, UCS-4BE, UCS-4LE. - * tests/Makefile.msvc (check): Likewise. - * tests/UCS-*snippet*: New files. - - Allow building as a shared library on Windows. - Allow running the tests on Windows. - * Makefile.devel (include/iconv.h.msvc): Remove rule. - (include/iconv.h.msvc-static, include/iconv.h.msvc-shared): New - rules. - (all): Update. - * windows/dllexport.h: New file. - * include/iconv.h.msvc: Remove file. - * include/iconv.h.msvc-static, include/iconv.h.msvc-shared: New - autogenerated files. - * Makefile.msvc (STATIC, DEBUG): Default to 0. - (all): Choose either include\iconv.h.msvc-static or - include\iconv.h.msvc-shared. - (check): Depend on all. - (all, check, mostlyclean, clean, distclean, maintainer-clean): - Recurse into tests directory. - * src/Makefile.msvc (STATIC, DEBUG): Default to 0. - (WARN_CFLAGS, PICFLAGS, OPTIMFLAGS): New variables. - (CFLAGS): Use them. Add -MD and -DBUILDING_LIBICONV. - (RESOURCES): New variable. - (iconv.lib): Change rule when building DLL. - (clean, distclean): One filename per line. - * tests/Makefile.msvc: New file. - * tests/check-stateful.bat, tests/check-stateless.bat, - tests/check-translit.bat: New files. - * tests/uniq-u.c: New file, taken from GNU textutils. - * README.win32: Update. - Based on patches by Taro Muraoka . - -2000-04-14 Bruno Haible - - Fix an OSF/1 problem. - * configure.in: Define GCC variable for substitution. - * src/Makefile.in (libiconv_plug_osf.so): Change rule if not using - gcc. - -2000-04-13 Bruno Haible - - Fix a SunOS 4 problem. - * include/iconv.h.in: If EILSEQ is not defined by the system, define - it to ENOENT, not EINVAL. - -2000-04-02 Bruno Haible - - Allow building on filesystems lacking symlinks and hard links. - * Makefile.devel (autoconf/aclocal.m4): Replace AC_PROG_LN_S with - CL_PROG_LN_S. - * configure.in: Add CL_PROG_LN, CL_PROG_LN_S. - * src/Makefile.in (LN): Use autoconfigured value @LN@. - (LN_S): Use autoconfigured value @LN_S@. - -2000-03-15 Bruno Haible - - * Version 1.2 released. - * include/iconv.h.in (_LIBICONV_VERSION): Bump version number. - * src/Makefile.in (LIBICONV_VERSION_INFO): Define to 1:1:1. - -2000-03-14 Bruno Haible - - Implement and document UTF-16BE and UTF16LE. - * src/utf16be.h, src/utf16le.h: New files. - * src/converters.h: Include them. - * src/encodings.def (UTF-16BE, UTF16LE): New encodings. - * README, man/iconv_open.3: Add UTF-16BE, UTF16LE. - * tests/Makefile.in (check): Check UTF-16, UTF-16BE, UTF16LE. - * tests/UTF-16*snippet*: New files. - - * src/utf16.h (utf16_wctomb): Output a byte order mark. - -2000-03-13 Bruno Haible - - Provide all encodings used by AIX locales. - * tools/Makefile (all): Add cp856.h, cp922.h, cp1046.h, cp1124.h, - cp1129.h. - (cp856.h, cp922.h, cp1046.h, cp1124.h, cp1129.h): New targets. - * src/cp856.h, src/cp922.h, src/cp943.h, src/cp1046.h, src/cp1124.h, - src/cp1129.h: New files. - * src/converters.h: Include them if USE_AIX is defined. - * src/encodings_aix.def: New file, with CP856, CP922, CP943, CP1046, - CP1124, CP1129. - * src/genflags.c: Define USE_AIX. Include encodings_aix.def. - * src/genaliases2.c: New file. - * src/iconv.c: Define USE_AIX on AIX. - Include encodings_aix.def and aliases_aix.h. - (aliases2_lookup): New function. - (iconv_open): Call aliases2_lookup. - * src/Makefile.in (iconv.lo): Depend on encodings_aix.def and - aliases_aix.h. - * Makefile.devel (all): Add src/aliases_aix.h. - (src/aliases_aix.h): New rule. - (src/flags.h): Depend on src/encodings_aix.def. - -2000-02-24 Bruno Haible - - * src/iconv.c (iconv): Don't write beyond the end of the output buffer. - Reported by Edmund Grimley Evans . - -2000-02-22 Bruno Haible - - * src/utf7.h (direct_tab, xdirect_tab): Treat tab like space. - -2000-02-15 Bruno Haible - - * src/iconv.c (iconv): Add cast in xxx_reset call. - -2000-02-05 Bruno Haible - - * src/tis620.h: Simplify. - -2000-01-27 Bruno Haible - - * Makefile.devel (CLISP_DIR): Change to "..". - -2000-01-24 Bruno Haible - - * Version 1.1 released. - * include/iconv.h.in (_LIBICONV_VERSION): Bump version number. - * src/Makefile.in (LIBICONV_VERSION_INFO): Define to 1:0:1. - -2000-01-23 Bruno Haible - - * src/utf7.h (utf7_wctomb): If base64 encoding is not active, encode - '+' as "+-". - -2000-01-22 Bruno Haible - - * include/iconv.h.in (iconvctl): New declaration. - (ICONV_TRIVIALP, ICONV_GET_TRANSLITERATE, ICONV_SET_TRANSLITERATE): - New macros. - * src/iconv.c (iconvctl): New function. - - * tests/Makefile.in: Add a rule for ../src/libiconv.la. Define $(MAKE). - - Solve a build problem. - * include/iconv.h.in: Renamed from include/libiconv.h.in. - * Makefile.devel: libiconv.h -> iconv.h. - * Makefile.in: Likewise. - * configure.in: Likewise. Remove check for . - * src/iconv.c: Include iconv.h instead of libiconv.h. - * tests/iconv.c, tests/table-from.c, tests/table-to.c: Likewise. - - * README, man/iconv_open.3: Don't document JOHAB any more. - - * man/iconv.3: Clarify return value again. - -2000-01-16 Bruno Haible - - Add aliases. - * src/encodings.def (ISO-8859-14): Add alias ISO-IR-199. - (ISO-8859-15): Add alias ISO-IR-203. - (EUC-CN): Add alias CN-GB, from RFC 1922. - (BIG5): Add alias CN-BIG5, from RFC 1922. - * Makefile.devel (src/aliases.h): Add 8th character to key set. - - Drop X11 aliases. - * src/encodings.def (JIS_X0201): Drop JISX0201.1976-0 alias. - (JIS_X0208): Drop JIS_X0208.1983-0, JIS_X0208.1983-1 aliases. - (KSC_5601): Drop KSC5601.1987-0 alias. - - Improve GB/T 12345 (not used yet). - * tools/Makefile (gb12345ext.h): Use GB12345-more.TXT. - * src/gb12345ext.h: Regenerated. - - Improve and document CP949. - * tools/Makefile (all): Add uhc_1.h and uhc_2.h. - (uhc_1.h, uhc_2.h): New rules. - * tools/cjk_tab_to_h.c (output_charset2uni_noholes_monotonic): New - function. - (output_uni2charset_sparse): Take an additional boolean argument. - All callers changed. - (*_uhc_1, *_uhc_2): New functions. - (main): Treat uhc_1 and uhc_2. - * src/uhc_1.h, src/uhc_2.h: New files. - * src/cp949.h: New file, include them. - * src/converters.h: Include it. - * src/encodings.def (KSC_5601): Remove alias CP949. - (CP949): New encoding. - * README, man/iconv_open.3: Add CP949. - * tests/Makefile.in (check): Check CP949. - * tests/CP949.TXT: New file. - - Document CP932. - * README, man/iconv_open.3: Add CP932. - * tests/Makefile.in (check): Check CP932. - * tests/CP932.TXT, tests/CP932.IRREVERSIBLE.TXT: New files. - - * Makefile.devel (src/flags.h): Depend on src/converters.h. - - * tests/Makefile.in (check): Check JIS_X0201. - * tests/JIS_X0201.TXT: New file. - - * src/euc_kr.h (euc_kr_wctomb): Shrink size of buf. - * src/iso2022_kr.h (iso2022_kr_wctomb): Likewise. - - * src/iso2022_cnext.h (iso2022_cn_ext_mbtowc): Use isoir165_mbtowc. - (iso2022_cn_ext_wctomb): Use isoir165_wctomb. - - Add ISO-IR-165 (undocumented). - * tools/Makefile (all): Add isoir165ext.h. - (isoir165ext.h): New rule. - * tools/cjk_tab_to_h.c (main): Treat isoir165ext like gb2312. - * src/isoir165.h, src/isoir165ext.h: New files. - * src/converters.h: Include it. - * src/encodings.def: Add ISO-IR-165. - * tests/Makefile.in (check): Check ISO-IR-165. - * tests/ISO-IR-165.TXT, tests/ISO-IR-165.IRREVERSIBLE.TXT: New files. - - Add ISO646-CN (undocumented). - * src/iso646_cn.h: New file. - * src/converters.h: Include it. - * src/encodings.def: Add ISO646-CN. - * tests/Makefile.in (check): Check ISO646-CN. - * tests/ISO646-CN.TXT: New file. - - Add ISO646-JP (undocumented). - * src/iso646_jp.h: New file. - * src/converters.h: Include it. - * src/encodings.def: Add ISO646-JP. - * tests/Makefile.in (check): Check ISO646-JP. - * tests/ISO646-JP.TXT: New file. - -2000-01-05 Bruno Haible - - Add ISO-8859-16. - * tools/Makefile (all): Add iso8859_16.h. - (iso8859_16.h): New rule. - * src/iso8859_16.h: New file. - * src/converters.h: Include it. - * src/encodings.def: Add ISO-8859-16. - * README, man/iconv_open.3: Add ISO-8859-16. - * tests/Makefile.in (check): Check ISO-8859-16. - * tests/ISO-8859-16.TXT: New file. - - * man/iconv.3: Clarify what happens *inbuf in case 3. - - * src/iso8859_8.h: Update using newest table from ftp.unicode.org. - * tests/ISO-8859-8.TXT: Likewise. - -2000-01-04 Bruno Haible - - * Version 1.0 released. - * include/libiconv.h.in (_LIBICONV_VERSION): Bump version number. - * src/Makefile.in (LIBICONV_VERSION_INFO): Define to 0:1:0. - (libiconv.la): Use LIBICONV_VERSION_INFO. - -2000-01-03 Bruno Haible - - * tests/Makefile.in: New file. - tests/check-stateless, tests/table-from.c, tests/table-to.c, - tests/*.TXT, tests/genutf8.c: New files, checks for stateless - encodings. - tests/check-stateful, tests/iconv.c, tests/*-snippet*: New files, - checks for stateful encodings. - * Makefile.in (all, check, mostlyclean, clean, distclean, - maintainer-clean): Descend into tests directory. - * configure.in: Add tests/Makefile to AC_OUTPUT duties. - - * src/gentranslit.c: New file. - * Makefile.devel (src/translit.h): New rule. - * src/translit.def, src/translit.h: New files. - * src/iconv.c: Include it. - (iconv): Transliterate using translit.h table. - - * src/genflags.c: New file. - * Makefile.devel (src/flags.h): New rule. - * src/flags.h: New file. - * src/iconv.c: Include it. - (encoding): Add field 'oflags'. - (all_encodings): Initialize the field 'oflags'. - (iconv_open): Copy field 'oflags'. - (iconv): Transliterate quotation marks U+2018, U+2019, U+201A. - * src/Makefile.in (iconv.lo): Update dependencies. - - * src/converters.h: New file, extracted from src/iconv.c. - * src/iconv.c: Include it. - * src/Makefile.in (iconv.lo): Update dependencies. - - * tools/cjk_variants.c: New file. - * tools/Makefile (ALL): Add cjk_variants.h. - (cjk_variants.h, cjk_variants): New rules. - * src/cjk_variants.h: New file. - * src/iconv.c: Include it. - (iconv): Use cjk_variants for transliteration. - - * man/iconv.3: Fix description of return value. - * euc_kr.h (euc_kr_wctomb): Remove Hangul transliteration. - * iso2022_kr.h (iso2022kr_wctomb): Likewise. - * src/iconv.c (iconv): Do Hangul transliteration here and increment - result once for every transliterated character. - * src/johab_hangul.h (johab_hangul_decompose): Change result array - from 'unsigned char*' to 'wchar_t*'. - - * src/cp1258.h (cp1258_mbtowc): Return RET_ILSEQ instead of storing - 0xfffd. - - * src/georgian_ps.h (georgian_ps_wctomb): Accept 0x00e6. - - * src/euc_jp.h (euc_jp_wctomb): Don't treat U+005C and U+007E like - Katakana. - - * src/euc_tw.h (euc_tw_mbtowc): Fix typo. - - * src/cp950.h (cp950_mbtowc, cp950_wctomb): Exclude the range - 0xC6A1..0xC7FE. - - * tools/cjk_tab_to_h.c (read_table_ksc5601): Some Hangul range was - not being excluded. Fix that. - * src/ksc5601.h: Regenerated. - * src/johab.h (johab_mbtowc): Don't accept 0xDA{A1..D3} - this is - valid in KSC5601/KSX1001 but not in JOHAB. - - * src/iconv.c (conv_struct): Add fields iindex, oindex. - (iconv_open): Fill in iindex, oindex. - - * src/encodings.def (UCS-2-BE): Add aliases "UNICODE-1-1" and - "csUnicode11", from IANA charset list. - (MacRoman): Add aliases "MAC" and "csMacintosh" for "MACINTOSH", - from IANA charset list. - (JIS_X0208): Add aliases "X0208", "ISO-IR-87", "csISO87JISX0208", - from IANA charset list. - (GB_2312-80): New encoding, from IANA charset list. - - * README, man/iconv_open.3: Add MacIceland and MacUkraine. - - * Makefile.devel: Add rules for src/aliases.h and src/aliases.gperf. - (all): Depend on src/aliases.h. - * src/Makefile.in: Remove rules for $(srcdir)/aliases.h and - $(srcdir)/aliases.gperf. - (clean): Clean up. - - * src/Makefile.in (libiconv_plug_linux.so): Remove unneeded "-ldl". - -1999-12-31 Bruno Haible - - * Version 0.3 released. - diff --git a/FILELIST b/FILELIST deleted file mode 100644 index babb51aa..00000000 --- a/FILELIST +++ /dev/null @@ -1,536 +0,0 @@ -lang/en_US.langmap -lang/zh_CN.langmap -lib/utf32.h -lib/iso8859_16.h -lib/iso8859_6.h -lib/cp1256.h -lib/ucs4le.h -lib/euc_jisx0213.h -lib/cp1163.h -lib/dec_hanyu.h -lib/cns11643_4b.h -lib/encodings_zos.def -lib/euc_cn.h -lib/cns11643_7.h -lib/gb18030uni.h -lib/cp950.h -lib/cp50221_0208_ext.h -lib/cp855.h -lib/ebcdic1154.h -lib/encodings_aix.def -lib/cns11643_3.h -lib/ebcdic280.h -lib/iso8859_14.h -lib/mac_roman.h -lib/cp850.h -lib/big5_2003.h -lib/isoir165ext.h -lib/cp950ext.h -lib/ebcdic282.h -lib/rk1048.h -lib/sjis.h -lib/georgian_academy.h -lib/iso2022_jp2.h -lib/cns11643.h -lib/cp865.h -lib/gbkext2.h -lib/iso8859_3.h -lib/mac_hebrew.h -lib/gbk.h -lib/mac_croatian.h -lib/ksc5601.h -lib/ebcdic273.h -lib/gb18030ext.h -lib/ebcdic1156.h -lib/ebcdic880.h -lib/atarist.h -lib/ebcdic838.h -lib/iso8859_2.h -lib/ebcdic1142.h -lib/cp1125.h -lib/euc_tw.h -lib/mac_thai.h -lib/koi8_r.h -lib/iso8859_11.h -lib/cp856.h -lib/ebcdic1140.h -lib/iso2022_kr.h -lib/iso2022_jp1.h -lib/utf16be.h -lib/gb18030_2022.h -lib/iso2022_jp3.h -lib/cns11643_5.h -lib/ebcdic285.h -lib/ascii.h -lib/ebcdic924.h -lib/cp922.h -lib/cns11643_inv.h -lib/ebcdic500.h -lib/iconv.cpp -lib/converters.h -lib/cp1252.h -lib/ebcdic1047.h -lib/jisx0213.h -lib/gb12345.h -lib/aliases2.h -lib/c99.h -lib/cp866.h -lib/ebcdic278.h -lib/ucs4internal.h -lib/mulelao.h -lib/ucs4swapped.h -lib/cp1162.h -lib/cns11643_4a.h -lib/flushwc.h -lib/mac_romania.h -lib/utf32le.h -lib/hz.h -lib/cp1255.h -lib/tcvn.h -lib/ebcdic1123.h -lib/ebcdic1158.h -lib/ucs2be.h -lib/ebcdic425.h -lib/cp1253.h -lib/iconv_open1.h -lib/ces_big5.h -lib/cp857.h -lib/cp949.h -lib/ebcdic1137.h -lib/iso8859_10.h -lib/gb2312.h -lib/cp936.h -lib/ebcdic1153.h -lib/mac_cyrillic.h -lib/cns11643_4.h -lib/cp932.h -lib/koi8_u.h -lib/cns11643_15.h -lib/armscii_8.h -lib/ebcdic1097.h -lib/cp775.h -lib/cp50221_0212_ext.h -lib/jisx0201.h -lib/cp737.h -lib/viscii.h -lib/ebcdic870.h -lib/big5hkscs2004.h -lib/euc_jp.h -lib/hkscs2008.h -lib/mac_centraleurope.h -lib/cp1129.h -lib/generated/flags.h -lib/generated/aliases_sysosf1.h -lib/generated/aliases_osf1_sysosf1.h -lib/generated/aliases_aix_sysaix.h -lib/generated/aliases.h -lib/generated/aliases_syssolaris.h -lib/generated/aliases_extra.h -lib/generated/aliases_aix.h -lib/generated/aliases_sysaix.h -lib/generated/aliases_syshpux.h -lib/generated/aliases_zos.h -lib/generated/aliases_dos.h -lib/generated/aliases_osf1.h -lib/ebcdic12712.h -lib/uhc_2.h -lib/iso8859_1.h -lib/cp858.h -lib/iso8859_8.h -lib/cp936ext.h -lib/cp1133.h -lib/mac_iceland.h -lib/ebcdic1149.h -lib/iso2022_cn.h -lib/ebcdic1025.h -lib/johab.h -lib/ucs4.h -lib/cns11643_2.h -lib/pt154.h -lib/ucs4be.h -lib/cp1257.h -lib/big5hkscs2008.h -lib/ebcdic905.h -lib/cns11643_6.h -lib/ebcdic1122.h -lib/isoir165.h -lib/cp864.h -lib/iso8859_15.h -lib/mac_turkish.h -lib/ebcdic424.h -lib/uhc_1.h -lib/cp869.h -lib/iso8859_13.h -lib/utf8.h -lib/ebcdic875.h -lib/iso8859_9.h -lib/ces_gbk.h -lib/ebcdic1155.h -lib/dec_kanji.h -lib/cp1131.h -lib/cp1124.h -lib/java.h -lib/ebcdic1130.h -lib/euc_kr.h -lib/encodings_dos.def -lib/iso8859_7.h -lib/ebcdic1146.h -lib/hkscs2004.h -lib/mac_arabic.h -lib/iso646_jp.h -lib/cp1161.h -lib/ebcdic037.h -lib/ebcdic871.h -lib/ucs2le.h -lib/iso646_cn.h -lib/shift_jisx0213.h -lib/ebcdic1132.h -lib/ebcdic1112.h -lib/cp853.h -lib/big5hkscs1999.h -lib/ebcdic1145.h -lib/cp1254.h -lib/big5.h -lib/cp1046.h -lib/mac_greek.h -lib/ebcdic4971.h -lib/gb18030_2005.h -lib/cp862.h -lib/ebcdic1160.h -lib/jisx0212.h -lib/hkscs1999.h -lib/gbkext_inv.h -lib/cp860.h -lib/hkscs2001.h -lib/koi8_ru.h -lib/utf7.h -lib/cp437.h -lib/ebcdic1141.h -lib/cp874.h -lib/ebcdic284.h -lib/ebcdic297.h -lib/ebcdic277.h -lib/jisx0208.h -lib/cp1250.h -lib/big5hkscs2001.h -lib/ebcdic423.h -lib/georgian_ps.h -lib/ebcdic1165.h -lib/koi8_t.h -lib/cns11643_1.h -lib/hp_roman8.h -lib/tis620.h -lib/iso8859_4.h -lib/loops.h -lib/utf32be.h -lib/encodings_osf1.def -lib/cp943.h -lib/ebcdic1148.h -lib/ebcdic1147.h -lib/cjk_variants.h -lib/johab_hangul.h -lib/utf16le.h -lib/encodings_extra.def -lib/gbkext1.h -lib/ucs2.h -lib/ebcdic1164.h -lib/iso2022_cnext.h -lib/iso8859_5.h -lib/utf16.h -lib/ebcdic1026.h -lib/ebcdic1144.h -lib/iso2022_jp.h -lib/vietcomb.h -lib/mac_ukraine.h -lib/ebcdic1166.h -lib/cp863.h -lib/cp852.h -lib/cp1258.h -lib/cp1251.h -lib/nextstep.h -lib/ebcdic16804.h -lib/iso2022_jpms.h -lib/riscos1.h -lib/iconv_open2.h -lib/ucs2internal.h -lib/loop_unicode.h -lib/ebcdic1143.h -lib/cp861.h -lib/ebcdic1157.h -lib/ucs2swapped.h -lib/encodings.def -lib/tds565.h -lib/cp932ext.h -lib/gb12345ext.h -tests/check-stateless.cpp -tests/table-from.hpp -tests/tests.cmake -tests/uniq-u.hpp -tests/reiconv-test.hpp -tests/table-to.hpp -tests/check-stateful.cpp -tests/data-generator.cpp -tests/data/IBM-284.TXT -tests/data/IBM-1112.TXT -tests/data/IBM-1146.TXT -tests/data/ISO-8859-2.TXT -tests/data/SHIFT_JIS.TXT -tests/data/ISO-8859-9.TXT -tests/data/CP1163.IRREVERSIBLE.TXT -tests/data/UCS-4LE-snippet -tests/data/CP850.TXT -tests/data/CP1161.TXT -tests/data/CP737.TXT -tests/data/IBM-285.TXT -tests/data/UTF-32BE-snippet -tests/data/CP865.TXT -tests/data/IBM-870.TXT -tests/data/ISO-2022-JP-1-snippet -tests/data/CP862.TXT -tests/data/BIG5-HKSCS-2008-snippet.UTF-8 -tests/data/ISO-2022-CN-snippet.UTF-8 -tests/data/GB18030-2005-BMP.TXT -tests/data/NEXTSTEP.TXT -tests/data/MacThai.TXT -tests/data/MuleLao-1.TXT -tests/data/IBM-1155.TXT -tests/data/ISO-2022-JP-3-snippet -tests/data/ISO-2022-KR-snippet.UTF-8 -tests/data/BIG5-2003.TXT -tests/data/CP874.TXT -tests/data/MacIceland.TXT -tests/data/IBM-1148.TXT -tests/data/IBM-037.TXT -tests/data/IBM-1145.TXT -tests/data/MacCyrillic.TXT -tests/data/CP1163.TXT -tests/data/ISO-2022-JP-snippet.UTF-8 -tests/data/JOHAB.TXT -tests/data/IBM-1160.IRREVERSIBLE.TXT -tests/data/BIG5-HKSCS-1999.TXT -tests/data/MacRoman.TXT -tests/data/IBM-12712.TXT -tests/data/ISO-2022-JP-MS-snippet.UTF-8 -tests/data/CP922.TXT -tests/data/CP1255-snippet.UTF-8 -tests/data/EUC-JISX0213.TXT -tests/data/DEC-HANYU.TXT -tests/data/IBM-1147.TXT -tests/data/MacCroatian.TXT -tests/data/IBM-424.TXT -tests/data/IBM-1157.TXT -tests/data/IBM-277.TXT -tests/data/UCS-4BE-snippet.UTF-8 -tests/data/ISO-IR-165.TXT -tests/data/EUC-CN.TXT -tests/data/IBM-871.TXT -tests/data/CP1258.TXT -tests/data/IBM-1160.TXT -tests/data/ISO-8859-6.TXT -tests/data/CP853.TXT -tests/data/IBM-924.TXT -tests/data/IBM-1026.TXT -tests/data/CP861.TXT -tests/data/EUC-JP.TXT -tests/data/CP1253.TXT -tests/data/IBM-1137.TXT -tests/data/MacTurkish.TXT -tests/data/JIS_X0201.TXT -tests/data/CP1255.TXT -tests/data/MacHebrew.TXT -tests/data/EUC-TW.TXT -tests/data/BIG5-HKSCS-2001-snippet -tests/data/CP949.TXT -tests/data/UTF-7-snippet -tests/data/KOI8-R.TXT -tests/data/UTF-16-snippet.UTF-8 -tests/data/CP1131.TXT -tests/data/BIG5-HKSCS-2004-snippet.UTF-8 -tests/data/BIG5-HKSCS-2008.TXT -tests/data/ISO-2022-CN-EXT-snippet -tests/data/IBM-16804.TXT -tests/data/CP858.TXT -tests/data/IBM-1165.TXT -tests/data/IBM-1149.TXT -tests/data/IBM-1097.TXT -tests/data/IBM-280.TXT -tests/data/BIG5-HKSCS-2001.IRREVERSIBLE.TXT -tests/data/IBM-1141.TXT -tests/data/BIG5-HKSCS-2004-snippet -tests/data/ISO-8859-5.TXT -tests/data/BIG5-HKSCS-2001.TXT -tests/data/CP1250.TXT -tests/data/ISO-2022-JP-3-snippet.UTF-8 -tests/data/IBM-1142.TXT -tests/data/ISO-8859-8.TXT -tests/data/ISO-2022-JP-1-snippet.UTF-8 -tests/data/BIG5-HKSCS-2001-snippet.UTF-8 -tests/data/IBM-1156.TXT -tests/data/CP932.IRREVERSIBLE.TXT -tests/data/KOI8-RU.TXT -tests/data/RISCOS-LATIN1.TXT -tests/data/ISO-2022-JP-2-snippet.UTF-8 -tests/data/CP855.TXT -tests/data/CP1161.IRREVERSIBLE.TXT -tests/data/IBM-1166.TXT -tests/data/MacCentralEurope.TXT -tests/data/ISO-IR-165.IRREVERSIBLE.TXT -tests/data/HZ-snippet.UTF-8 -tests/data/ISO-8859-10.TXT -tests/data/UTF-16LE-snippet -tests/data/ISO-8859-15.TXT -tests/data/BIG5-HKSCS-1999.IRREVERSIBLE.TXT -tests/data/Georgian-PS.TXT -tests/data/UCS-2BE-snippet -tests/data/GB18030-2005.IRREVERSIBLE.TXT -tests/data/CP863.TXT -tests/data/ISO-8859-7.TXT -tests/data/TCVN-snippet.UTF-8 -tests/data/IBM-500.TXT -tests/data/ISO-8859-14.TXT -tests/data/MacRomania.TXT -tests/data/PT154.TXT -tests/data/UTF-16-snippet -tests/data/ISO646-JP.TXT -tests/data/IBM-1123.TXT -tests/data/IBM-1164.TXT -tests/data/UTF-16BE-snippet.UTF-8 -tests/data/ISO-2022-KR-snippet -tests/data/DEC-HANYU.IRREVERSIBLE.TXT -tests/data/HP-ROMAN8.TXT -tests/data/IBM-1153.TXT -tests/data/UCS-2LE-snippet -tests/data/ISO-2022-CN-snippet -tests/data/TIS-620.TXT -tests/data/HZ-snippet -tests/data/CP1129.TXT -tests/data/TDS565.TXT -tests/data/MacGreek.TXT -tests/data/ISO-8859-11.TXT -tests/data/ASCII.TXT -tests/data/ISO646-CN.TXT -tests/data/SHIFT_JISX0213.TXT -tests/data/CP1124.TXT -tests/data/UCS-2LE-snippet.UTF-8 -tests/data/EUC-TW.IRREVERSIBLE.TXT -tests/data/UTF-32LE-snippet.UTF-8 -tests/data/CP1255-snippet -tests/data/Translit1.ISO-8859-1 -tests/data/IBM-905.TXT -tests/data/UTF-16BE-snippet -tests/data/UTF-32-snippet.UTF-8 -tests/data/CP950.IRREVERSIBLE.TXT -tests/data/ISO-8859-13.TXT -tests/data/Quotes.ASCII -tests/data/BIG5-HKSCS-1999-snippet -tests/data/ATARIST.TXT -tests/data/IBM-1154.TXT -tests/data/CP1251.TXT -tests/data/CP1258-snippet -tests/data/TCVN.IRREVERSIBLE.TXT -tests/data/CP1125.TXT -tests/data/CP866.TXT -tests/data/UTF-7-snippet.UTF-8 -tests/data/CP1162.TXT -tests/data/CP1254.TXT -tests/data/TCVN.TXT -tests/data/CP950.TXT -tests/data/EUC-JP.IRREVERSIBLE.TXT -tests/data/UCS-4LE-snippet.UTF-8 -tests/data/IBM-1122.TXT -tests/data/CP1252.TXT -tests/data/CP1133.TXT -tests/data/IBM-838.IRREVERSIBLE.TXT -tests/data/IBM-1140.TXT -tests/data/ISO-8859-3.TXT -tests/data/IBM-1025.TXT -tests/data/CP1258-snippet.UTF-8 -tests/data/BIG5.TXT -tests/data/CP852.TXT -tests/data/CP856.TXT -tests/data/EUC-KR.TXT -tests/data/BIG5-HKSCS-2004.IRREVERSIBLE.TXT -tests/data/BIG5-HKSCS-1999-snippet.UTF-8 -tests/data/CP936.TXT -tests/data/KOI8-U.TXT -tests/data/CP932.TXT -tests/data/IBM-4971.TXT -tests/data/IBM-880.TXT -tests/data/DEC-KANJI.TXT -tests/data/UCS-4BE-snippet -tests/data/IBM-875.TXT -tests/data/CP857.TXT -tests/data/Georgian-Academy.TXT -tests/data/CP1256.TXT -tests/data/UTF-32-snippet -tests/data/IBM-838.TXT -tests/data/MacUkraine.TXT -tests/data/UTF-32BE-snippet.UTF-8 -tests/data/ISO-2022-JP-snippet -tests/data/IBM-1130.TXT -tests/data/BIG5-HKSCS-2008-snippet -tests/data/BIG5-HKSCS-2004.TXT -tests/data/ISO-2022-JP-MS-snippet -tests/data/CP775.TXT -tests/data/IBM-425.TXT -tests/data/ARMSCII-8.IRREVERSIBLE.TXT -tests/data/UCS-2BE-snippet.UTF-8 -tests/data/ISO-8859-16.TXT -tests/data/IBM-423.TXT -tests/data/ISO-2022-CN-EXT-snippet.UTF-8 -tests/data/CP1255.IRREVERSIBLE.TXT -tests/data/IBM-1144.TXT -tests/data/IBM-297.TXT -tests/data/ISO-2022-JP-MS-snippet.alt -tests/data/TCVN-snippet -tests/data/CP1257.TXT -tests/data/GBK.TXT -tests/data/BIG5-HKSCS-2008.IRREVERSIBLE.TXT -tests/data/CP864.TXT -tests/data/CP869.TXT -tests/data/ISO-8859-4.TXT -tests/data/Translit1.ASCII -tests/data/Quotes.ISO-8859-1 -tests/data/UTF-32LE-snippet -tests/data/Quotes.UTF-8 -tests/data/RK1048.TXT -tests/data/IBM-282.TXT -tests/data/ISO-2022-JP-2-snippet -tests/data/IBM-273.TXT -tests/data/KOI8-T.TXT -tests/data/MacArabic.TXT -tests/data/VISCII.TXT -tests/data/UTF-16LE-snippet.UTF-8 -tests/data/IBM-1132.TXT -tests/data/CP437.TXT -tests/data/ISO-8859-1.TXT -tests/data/CP860.TXT -tests/data/IBM-1047.TXT -tests/data/CP1046.TXT -tests/data/IBM-1143.TXT -tests/data/IBM-278.TXT -tests/data/CP1258.IRREVERSIBLE.TXT -tests/data/ARMSCII-8.TXT -tests/data/GB18030-2022-BMP.TXT -tests/data/IBM-1158.TXT -tests/data/BIG5-2003.IRREVERSIBLE.TXT -tests/test-shiftseq.cpp -tests/test-to-wchar.cpp -tests/throw_error.hpp -tests/file_utils.hpp -tests/sort.cpp -tests/sort.hpp -tools/genaliases.cpp -tools/genaliases2.cpp -tools/genflags.cpp -COPYING -Makefile.devel -include/cppp/reiconv.hpp.in -CMakeLists.txt -README.md -FILELIST -CPPPPKG -cpppdist.py -ChangeLog -windows/libcppp-reiconv.rc.in -NEWS.md diff --git a/COPYING b/LICENSE similarity index 100% rename from COPYING rename to LICENSE diff --git a/Makefile.devel b/Makefile.devel index ce89822c..5c9ed756 100644 --- a/Makefile.devel +++ b/Makefile.devel @@ -1,29 +1,31 @@ # -*- makefile -*- # This is the developer's makefile. -# It obeys the environment variables CXX, CFLAGS if you have set them. +# It obeys the environment variables CXX, CFLAGS and CXXFLAGS if you have set them. GPERF = gperf CMAKE = cmake CTEST = ctest -MKDIR = mkdir -p -RM = rm -f +MKDIR = mkdir +RM = rm -CXX ?= g++ -Wall +CXX ?= g++ +CFLAGS := $(CFLAGS) CXXFLAGS := $(CXXFLAGS) -Ilib all : lib/generated \ - lib/generated/aliases.h lib/generated/aliases_sysaix.h lib/generated/aliases_syshpux.h lib/generated/aliases_sysosf1.h lib/generated/aliases_syssolaris.h \ - lib/generated/aliases_aix.h lib/generated/aliases_aix_sysaix.h \ - lib/generated/aliases_osf1.h lib/generated/aliases_osf1_sysosf1.h \ - lib/generated/aliases_dos.h \ - lib/generated/aliases_zos.h \ - lib/generated/aliases_extra.h \ - lib/generated/flags.h + lib/generated/check-encodings \ + lib/generated/aliases.h \ + lib/generated/indexes.hpp.shippet \ + lib/generated/indexes.h.shippet lib/generated : - $(MKDIR) lib/generated + $(MKDIR) -p lib/generated + +lib/generated/check-encodings : tools/check-encodings.cpp + $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) $< -o $@ + ./lib/generated/check-encodings lib/generated/genaliases : tools/genaliases.cpp $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) $< -o $@ @@ -32,136 +34,32 @@ lib/generated/aliases.gperf : lib/generated/genaliases ./lib/generated/genaliases $@ lib/generated/aliases.h : lib/generated/aliases.gperf - $(GPERF) -L C++ -Z HashPool -m 10 $< > $@ - - -lib/generated/genaliases_sysaix : tools/genaliases.cpp - $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) -DUSE_AIX_ALIASES $< -o $@ - -lib/generated/aliases_sysaix.gperf : lib/generated/genaliases_sysaix - ./lib/generated/genaliases_sysaix $@ - -lib/generated/aliases_sysaix.h : lib/generated/aliases_sysaix.gperf - $(GPERF) -L C++ -Z HashPool -m 10 $< > $@ - - -lib/generated/genaliases_syshpux : tools/genaliases.cpp - $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) -DUSE_HPUX_ALIASES $< -o $@ - -lib/generated/aliases_syshpux.gperf : lib/generated/genaliases_syshpux - ./lib/generated/genaliases_syshpux $@ - -lib/generated/aliases_syshpux.h : lib/generated/aliases_syshpux.gperf - $(GPERF) -L C++ -Z HashPool -m 10 $< > $@ - - -lib/generated/genaliases_sysosf1 : tools/genaliases.cpp - $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) -DUSE_OSF1_ALIASES $< -o $@ - -lib/generated/aliases_sysosf1.gperf : lib/generated/genaliases_sysosf1 - ./lib/generated/genaliases_sysosf1 $@ - -lib/generated/aliases_sysosf1.h : lib/generated/aliases_sysosf1.gperf - $(GPERF) -L C++ -Z HashPool -m 10 $< > $@ - - -lib/generated/genaliases_syssolaris : tools/genaliases.cpp - $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) -DUSE_SOLARIS_ALIASES $< -o $@ - -lib/generated/aliases_syssolaris.gperf : lib/generated/genaliases_syssolaris - ./lib/generated/genaliases_syssolaris $@ - -lib/generated/aliases_syssolaris.h : lib/generated/aliases_syssolaris.gperf - $(GPERF) -L C++ -Z HashPool -m 10 $< > $@ - - -lib/generated/genaliases2_aix : tools/genaliases2.cpp - $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) -DUSE_AIX $< -o $@ - -lib/generated/aliases_aix.h : lib/generated/genaliases2_aix - ./lib/generated/genaliases2_aix aix $@ + $(GPERF) -L ANSI-C -m 10 $< > $@ - -lib/generated/genaliases2_aix_sysaix : tools/genaliases2.cpp - $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) -DUSE_AIX -DUSE_AIX_ALIASES $< -o $@ - -lib/generated/aliases_aix_sysaix.h : lib/generated/genaliases2_aix_sysaix - ./lib/generated/genaliases2_aix_sysaix aix $@ - - -lib/generated/genaliases2_osf1 : tools/genaliases2.cpp - $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) -DUSE_OSF1 $< -o $@ - -lib/generated/aliases_osf1.h : lib/generated/genaliases2_osf1 - ./lib/generated/genaliases2_osf1 osf1 $@ - - -lib/generated/genaliases2_osf1_sysosf1 : tools/genaliases2.cpp - $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) -DUSE_OSF1 -DUSE_OSF1_ALIASES $< -o $@ - -lib/generated/aliases_osf1_sysosf1.h : lib/generated/genaliases2_osf1_sysosf1 - ./lib/generated/genaliases2_osf1_sysosf1 osf1 $@ - - -lib/generated/genaliases2_dos : tools/genaliases2.cpp - $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) -DUSE_DOS $< -o $@ - -lib/generated/aliases_dos.h : lib/generated/genaliases2_dos - ./lib/generated/genaliases2_dos dos $@ - - -lib/generated/genaliases2_zos : tools/genaliases2.cpp - $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) -DUSE_ZOS $< -o $@ - -lib/generated/aliases_zos.h : lib/generated/genaliases2_zos - ./lib/generated/genaliases2_zos zos $@ - - -lib/generated/genaliases2_extra : tools/genaliases2.cpp - $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) -DUSE_EXTRA $< -o $@ - -lib/generated/aliases_extra.h : lib/generated/genaliases2_extra - ./lib/generated/genaliases2_extra extra $@ - -lib/generated/genflags : tools/genflags.cpp +lib/generated/genindexes : tools/genindexes.cpp $(CXX) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) $< -o $@ -lib/generated/flags.h : lib/generated/genflags - ./lib/generated/genflags > $@ +lib/generated/indexes.hpp.shippet : lib/generated/genindexes + ./lib/generated/genindexes C++ > $@ + +lib/generated/indexes.h.shippet : lib/generated/genindexes + ./lib/generated/genindexes C > $@ test : all - $(RM) -r -f build - $(MKDIR) build - cd build && $(CMAKE) .. -DENABLE_EXTRA=ON -DENABLE_TEST=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=test_install - cd build && $(CMAKE) --build . --config=Release --verbose - cd build && $(CTEST) -C Release --verbose - $(CMAKE) --install build --verbose - ./cpppdist.py - { diff cppp-reiconv-* . --recursive || echo ; } + $(RM) -r -f build tests/data/GB18030-2005.TXT tests/data/GB18030-2022.TXT tests/data/UTF-8.TXT + $(CMAKE) -B build -S . -DCMAKE_BUILD_TYPE=Debug + $(CMAKE) --build build --config Debug --target all -j $(shell nproc) + $(CTEST) --test-dir build --output-on-failure # Alias to test check : test clean : - $(RM) -r build - $(RM) lib/generated/aliases.gperf - $(RM) lib/generated/aliases_sysaix.gperf - $(RM) lib/generated/aliases_syshpux.gperf - $(RM) lib/generated/aliases_sysosf1.gperf - $(RM) lib/generated/aliases_syssolaris.gperf - $(RM) lib/generated/genaliases - $(RM) lib/generated/genaliases2_aix - $(RM) lib/generated/genaliases2_aix_sysaix - $(RM) lib/generated/genaliases2_dos - $(RM) lib/generated/genaliases2_extra - $(RM) lib/generated/genaliases2_osf1 - $(RM) lib/generated/genaliases2_osf1_sysosf1 - $(RM) lib/generated/genaliases2_zos - $(RM) lib/generated/genaliases_sysaix - $(RM) lib/generated/genaliases_syshpux - $(RM) lib/generated/genaliases_sysosf1 - $(RM) lib/generated/genaliases_syssolaris - $(RM) lib/generated/genflags - $(RM) tests/data/GB18030-2005.TXT - $(RM) tests/data/GB18030-2022.TXT - $(RM) tests/data/UTF-8.TXT + $(RM) -r -f build + $(RM) -r -f cppp-reiconv-* + $(RM) -r -f .cache + $(RM) -f lib/generated/aliases.gperf + $(RM) -f lib/generated/genaliases + $(RM) -f tests/data/GB18030-2005.TXT + $(RM) -f tests/data/GB18030-2022.TXT + $(RM) -f tests/data/UTF-8.TXT diff --git a/NEWS.md b/NEWS.md index 55a042eb..0a917741 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,21 @@ +New in 3.0.0: +* Refactor ALL API. Provide C and C++ API. +* Remove `//ZOS_UNIX` support. +* Remove unused code. +* Refactor testing suites. +* Add API documentation. +* Use Rubisco for project manager. +* Enable all encodings by default. +* Add codepage lookup support. +* Add CPack configuration for DEB packages. +* Synchronize with upstream GNU LIBICONV. +* Fix `assert_compare_file()` function issue #5. +* Optimize the project structure. +* Add iconv compatibility support. +* Add locale character set detection support. +* Fix a bug in test suite caused by line feeds. +* Remove NLS support. + New in 2.1.0: * Add NLS support for the include file, only support en_US and zh_CN. * Add CTest support for Windows. @@ -13,7 +31,6 @@ New in 2.1.0: * Move `lib/gen*.c` to `tools/gen*.cpp`. * Optimize `Makefile.devel`. * Fix bugs, warnings, typos. - * Change the 'autodetect' feature of 'iconv_string' to a non extra feature. New in 2.0.0: diff --git a/README.md b/README.md index ca0c1df5..364cd386 100644 --- a/README.md +++ b/README.md @@ -1,153 +1,207 @@ -![cppp-reiconv logo](https://cppp-project.github.io/cppp-res.github.io/images/reiconv-icon.png) - # cppp-reiconv -A character set conversion library based on GNU LIBICONV. -# Instruction -This library provides some charset conversation function for The C++ Plus Project. +C+++ + +A character set conversion library based on GNU LIBICONV. **Supports C and C++20.** + +If your C++ standard is lower than C++20. A few code needs to be modified. + +## Build + +This library requires `build-aux` and `cppp-platform` for building. + +See [docs/](docs/README.md) for full requirements list. + +**We are planning to use [Rubisco](https://github.com/cppp-project/rubisco) to manage submodules. But it is not ready yet. So we don not use git submodule for now. Please clone them manually.** + +Use the following command to fetch source code, or download source package: + +```shell +git clone https://github.com/cppp-project/cppp-reiconv +cd cppp-reiconv +git clone https://github.com/cppp-project/build-aux --depth 1 +git clone https://github.com/cppp-project/cppp-platform --depth 1 +``` + +Use the following command to build and install. + +```shell +mkdir build +cd build +cmake .. -DCMAKE_BUILD_TYPE=[[BUILD_TYPE]] -DCMAKE_INSTALL_PREFIX=[[PREFIX]] +cmake --build . --config=[[BUILD_TYPE]] +cmake --install . --config=[[BUILD_TYPE]] +``` + +## Simple Usage + +```cpp +#include + +#include +#include + +int main() +{ + const std::string_view src = "\xb8\xfc\xcf\xb2\xe1\xba\xc9\xbd\xc7\xa7\xc0\xef\xd1\xa9\xa3\xac\xc8\xfd\xbe\xfc\xb9\xfd\xba\xf3\xbe\xa1\xbf\xaa\xd1\xd5\xa3\xa1"; + + std::string result = reiconv::convert("GB18030", "UTF-8", src); -It provides support for the encodings: + std::cout << result << std::endl; + + const std::string_view correct_result = "\u66f4\u559c\u5cb7\u5c71\u5343\u91cc\u96ea\uff0c\u4e09\u519b\u8fc7\u540e\u5c3d\u5f00\u989c\uff01"; + + if (result == correct_result) + { + std::cout << "Correct!" << std::endl; + } + else + { + // If it happens, please report a bug. + std::cout << "Wrong!" << std::endl; + } + + return EXIT_SUCCESS; +} +``` + +The full documentation can be found in [docs/](docs/README.md). + +## Supported Encodings + +Same as GNU LIBICONV, It provides support for the encodings: + European languages - - ASCII, ISO-8859-{1,2,3,4,5,7,9,10,13,14,15,16}, - - KOI8-R, KOI8-U, KOI8-RU, - - CP{1250,1251,1252,1253,1254,1257}, CP{850,866,1131}, - - Mac{Roman,CentralEurope,Iceland,Croatian,Romania}, - - Mac{Cyrillic,Ukraine,Greek,Turkish}, - - Macintosh + + ASCII, ISO-8859-{1,2,3,4,5,7,9,10,13,14,15,16}, + + KOI8-R, KOI8-U, KOI8-RU, + + CP{1250,1251,1252,1253,1254,1257}, CP{850,866,1131}, + + Mac{Roman,CentralEurope,Iceland,Croatian,Romania}, + + Mac{Cyrillic,Ukraine,Greek,Turkish}, + + Macintosh + Semitic languages - - ISO-8859-{6,8}, CP{1255,1256}, CP862, Mac{Hebrew,Arabic} + + ISO-8859-{6,8}, CP{1255,1256}, CP862, Mac{Hebrew,Arabic} + Japanese - - EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP, ISO-2022-JP-2, ISO-2022-JP-1, - - ISO-2022-JP-MS + + EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP, ISO-2022-JP-2, ISO-2022-JP-1, + + ISO-2022-JP-MS + Chinese - - EUC-CN, HZ, GBK, CP936, GB18030, GB18030:2022, EUC-TW, BIG5, CP950, - - BIG5-HKSCS, BIG5-HKSCS:2004, BIG5-HKSCS:2001, BIG5-HKSCS:1999, - - ISO-2022-CN, ISO-2022-CN-EXT + + EUC-CN, HZ, GBK, CP936, GB18030, GB18030:2022, EUC-TW, BIG5, CP950, + + BIG5-HKSCS, BIG5-HKSCS:2004, BIG5-HKSCS:2001, BIG5-HKSCS:1999, + + ISO-2022-CN, ISO-2022-CN-EXT + Korean - - EUC-KR, CP949, ISO-2022-KR, JOHAB + + EUC-KR, CP949, ISO-2022-KR, JOHAB + Armenian - - ARMSCII-8 + + ARMSCII-8 + Georgian - - Georgian-Academy, Georgian-PS + + Georgian-Academy, Georgian-PS + Tajik - - KOI8-T + + KOI8-T + Kazakh - - PT154, RK1048 + + PT154, RK1048 + Thai - - ISO-8859-11, TIS-620, CP874, MacThai + + ISO-8859-11, TIS-620, CP874, MacThai + Laotian - - MuleLao-1, CP1133 + + MuleLao-1, CP1133 + Vietnamese - - VISCII, TCVN, CP1258 + + VISCII, TCVN, CP1258 + Platform specifics - - HP-ROMAN8, NEXTSTEP + + HP-ROMAN8, NEXTSTEP + Full Unicode - - UTF-8 - - UCS-2, UCS-2BE, UCS-2LE - - UCS-4, UCS-4BE, UCS-4LE - - UTF-16, UTF-16BE, UTF-16LE - - UTF-32, UTF-32BE, UTF-32LE - - UTF-7 - - C99, JAVA + + UTF-8 + + UCS-2, UCS-2BE, UCS-2LE + + UCS-4, UCS-4BE, UCS-4LE + + UTF-16, UTF-16BE, UTF-16LE + + UTF-32, UTF-32BE, UTF-32LE + + UTF-7 + + C99, JAVA + Full Unicode, in terms of 'uint16_t' or 'uint32_t' - - (with machine dependent endianness and alignment) - - UCS-2-INTERNAL, UCS-4-INTERNAL + + UCS-2-INTERNAL, UCS-4-INTERNAL (with machine dependent endianness and alignment) -When configured with the option -DENABLE_EXTRA, it also provides -support for a few extra encodings: +And some extra encodings. These encodings are GNU LIBICONV's extra encodings. + European languages - - CP{437,737,775,852,853,855,857,858,860,861,863,865,869,1125} + + CP{437,737,775,852,853,855,857,858,860,861,863,865,869,1125} + Semitic languages - - CP864 + + CP864 + Japanese - - EUC-JISX0213, Shift_JISX0213, ISO-2022-JP-3 + + EUC-JISX0213, Shift_JISX0213, ISO-2022-JP-3 + Chinese - - BIG5-2003 (experimental) + + BIG5-2003 (experimental) + Turkmen - - TDS565 + + TDS565 + Platform specifics - - ATARIST, RISCOS-LATIN1 + + ATARIST, RISCOS-LATIN1 + EBCDIC compatible (not ASCII compatible, very rarely used) - - European languages - - - IBM-{037,273,277,278,280,282,284,285,297,423,500,870,871,875,880}, - - - IBM-{905,924,1025,1026,1047,1112,1122,1123,1140,1141,1142,1143}, - - - IBM-{1144,1145,1146,1147,1148,1149,1153,1154,1155,1156,1157,1158}, - - - IBM-{1165,1166,4971} - - Semitic languages - - - IBM-{424,425,12712,16804} - - Persian - - - IBM-1097 - - Thai - - - IBM-{838,1160} - - Laotian - - - IBM-1132 - - Vietnamese - - - IBM-{1130,1164} - - Indic languages - - - IBM-1137 + + European languages + + IBM-{037,273,277,278,280,282,284,285,297,423,500,870,871,875,880}, + + IBM-{905,924,1025,1026,1047,1112,1122,1123,1140,1141,1142,1143}, + + IBM-{1144,1145,1146,1147,1148,1149,1153,1154,1155,1156,1157,1158}, + + IBM-{1165,1166,4971} + + Semitic languages + + IBM-{424,425,12712,16804} + + Persian + + IBM-1097 + + Thai + + IBM-{838,1160} + + Laotian + + IBM-1132 + + Vietnamese + + IBM-{1130,1164} + + Indic languages + + IBM-1137 It can convert from any of these encodings to any other, through Unicode conversion. -cppp-reiconv is for you if your application needs to support multiple character -encodings, but that support lacks from your system. - - -# Build and installation +## Build Options We use CMake for build -+ Standard build -```shell -mkdir build -cd build -cmake .. -DCMAKE_INSTALL_PREFIX=[[PREFIX]] -cmake --build . --config=Release -cmake --install . -``` ++ `BUILD_TESTING`: Build tests. Default is ON. -+ Full build ```shell -mkdir build -cd build -cmake .. -DCMAKE_INSTALL_PREFIX=[[PREFIX]] -DENABLE_EXTRA=ON -cmake --build . --config=Release -cmake --install . +cmake .. -DBUILD_TESTING=ON +cmake --build . --config=RelWithDebInfo +ctest -C RelWithDebInfo --output-on-failure ``` -When use full build, extra encodings will be enabled. ++ `ICONV_COMPAT`: Enable compatibility with iconv. Default is OFF. -+ Build with test suite -```shell -mkdir build -cd build -cmake .. -DCMAKE_INSTALL_PREFIX=[[PREFIX]] -DENABLE_EXTRA=ON -DENABLE_TEST=ON -cmake --build . --config=Release -cmake --install . -``` +If `ICONV_COMPAT` is ON, it will install `iconv.h` with basic functions. +But we do not support all features of POSIX:2024. See [TODO](TODO). + +## Install -# Install This library installs: - - a shared library 'libcppp-reiconv'. - - a static library 'libcppp-reiconv.static'. - - a header file ''. -To use it, simply #include and import the lib to use the functions. ++ A shared library `libcppp-reiconv`. ++ A static library `libcppp-reiconv.static`. ++ Header files. + +```text +include +โ”œโ”€โ”€ cppp +โ”‚ โ”œโ”€โ”€ cppp-platform.h +โ”‚ โ”œโ”€โ”€ encodings +โ”‚ โ”‚ โ”œโ”€โ”€ reiconv.h +โ”‚ โ”‚ โ””โ”€โ”€ reiconv.hpp +โ”‚ โ”œโ”€โ”€ reiconv.h +โ”‚ โ””โ”€โ”€ reiconv.hpp +โ””โ”€โ”€ iconv.h # Only if ICONV_COMPAT is ON +``` -# Copyright +## Copyright The cppp-reiconv is under LGPLv3, -see file [COPYING](./COPYING). +see file [LICENSE](./LICENSE). + +## Download -# Download +See -https://github.com/cppp-project/cppp-reiconv/releases +## Homepage -# Homepage + -https://github.com/cppp-project/cppp-reiconv +## Bug reports -# Bug reports - + Create a issue on GitHub [Report now](https://github.com/cppp-project/cppp-reiconv/issues/new/) ++ Create a issue on GitHub [Report now](https://github.com/cppp-project/cppp-reiconv/issues/new/) diff --git a/README.zh_CN.md b/README.zh_CN.md new file mode 100644 index 00000000..530d99d1 --- /dev/null +++ b/README.zh_CN.md @@ -0,0 +1,206 @@ +# cppp-reiconv + +C+++ + +ไธ€ไธชๅŸบไบŽ GNU LIBICONV ็š„ๅญ—็ฌฆ้›†่ฝฌๆขๅบ“ใ€‚**ๆ”ฏๆŒ C ๅ’Œ C++20ใ€‚** + +ๅฆ‚ๆžœไฝ ็š„ C++ ๆ ‡ๅ‡†ไฝŽไบŽ C++20๏ผŒ้œ€่ฆไฟฎๆ”นไธ€ไบ›ไปฃ็ ใ€‚ + +## ๆž„ๅปบ + +ๆญคๅบ“้œ€่ฆ `build-aux` ๅ’Œ `cppp-platform` ไธคไธชๅญๆจกๅ—็”จไบŽๆž„ๅปบใ€‚ + +ๅ‚่ง [docs/](docs/zh_CN/README.md) ่Žทๅ–ๅฎŒๆ•ดไพ่ต–ๅˆ—่กจใ€‚ + +**ๆˆ‘ไปฌๆญฃๅœจไฝฟ็”จ [Rubisco](https://github.com/cppp-project/rubisco) ็ฎก็†ๅญๆจกๅ—ใ€‚ไฝ†ๅฎƒ่ฟ˜ๆฒกๆœ‰ๅ‡†ๅค‡ๅฅฝใ€‚ๆ‰€ไปฅๆˆ‘ไปฌ็Žฐๅœจไธไฝฟ็”จ git submoduleใ€‚่ฏทๆ‰‹ๅŠจๅ…‹้š†ๅฎƒไปฌใ€‚** + +ไฝฟ็”จไปฅไธ‹ๅ‘ฝไปคๅ…‹้š†ๆบไปฃ็ ๏ผŒๆˆ–่€…็›ดๆŽฅไธ‹่ฝฝๆบ็ ๅŒ…๏ผš + +```shell +git clone https://github.com/cppp-project/cppp-reiconv +cd cppp-reiconv +git clone https://github.com/cppp-project/build-aux --depth 1 +git clone https://github.com/cppp-project/cppp-platform --depth 1 +``` + +ไฝฟ็”จไปฅไธ‹ๅ‘ฝไปคๆž„ๅปบๅ’Œๅฎ‰่ฃ…๏ผš + +```shell +mkdir build +cd build +cmake .. -DCMAKE_BUILD_TYPE=[[BUILD_TYPE]] -DCMAKE_INSTALL_PREFIX=[[PREFIX]] +cmake --build . --config=[[BUILD_TYPE]] +cmake --install . --config=[[BUILD_TYPE]] +``` + +## ็ฎ€ๅ•็š„็”จๆณ• + +```cpp +#include + +#include +#include + +int main() +{ + const std::string_view src = "\xb8\xfc\xcf\xb2\xe1\xba\xc9\xbd\xc7\xa7\xc0\xef\xd1\xa9\xa3\xac\xc8\xfd\xbe\xfc\xb9\xfd\xba\xf3\xbe\xa1\xbf\xaa\xd1\xd5\xa3\xa1"; + + std::string result = reiconv::convert("GB18030", "UTF-8", src); + + std::cout << result << std::endl; + + const std::string_view correct_result = "\u66f4\u559c\u5cb7\u5c71\u5343\u91cc\u96ea\uff0c\u4e09\u519b\u8fc7\u540e\u5c3d\u5f00\u989c\uff01"; + + if (result == correct_result) + { + std::cout << "ๆญฃ็กฎ๏ผ" << std::endl; + } + else + { + // ๅฆ‚ๆžœๅ‘็”Ÿไบ†่ฟ™ไธช๏ผŒ่ฏทๆ issue๏ผ + std::cout << "้”™่ฏฏ๏ผ" << std::endl; + } + + return EXIT_SUCCESS; +} +``` + +ๅฎŒๆ•ดๆ–‡ๆกฃๅ‚่ง [docs/](docs/zh_CN/README.md)ใ€‚ + +## ๆ”ฏๆŒ็š„็ผ–็  + +ๅ’Œ GNU LIBICONV ไธ€ๆ ท๏ผŒๅฎƒๆไพ›ไบ†ไปฅไธ‹็ผ–็ ็š„ๆ”ฏๆŒ๏ผš + ++ ๆฌงๆดฒ่ฏญ่จ€ + + ASCII, ISO-8859-{1,2,3,4,5,7,9,10,13,14,15,16}, + + KOI8-R, KOI8-U, KOI8-RU, + + CP{1250,1251,1252,1253,1254,1257}, CP{850,866,1131}, + + Mac{Roman,CentralEurope,Iceland,Croatian,Romania}, + + Mac{Cyrillic,Ukraine,Greek,Turkish}, + + Macintosh ++ ้—ช็ฑณ็‰น่ฏธๆ—่ฏญ่จ€ + + ISO-8859-{6,8}, CP{1255,1256}, CP862, Mac{Hebrew,Arabic} ++ ๆ—ฅๆœฌ่ฏญ + + EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP, ISO-2022-JP-2, ISO-2022-JP-1, + + ISO-2022-JP-MS ++ ไธญๆ–‡ + + EUC-CN, HZ, GBK, CP936, GB18030, GB18030:2022, EUC-TW, BIG5, CP950, + + BIG5-HKSCS, BIG5-HKSCS:2004, BIG5-HKSCS:2001, BIG5-HKSCS:1999, + + ISO-2022-CN, ISO-2022-CN-EXT ++ ้Ÿฉ่ฏญ + + EUC-KR, CP949, ISO-2022-KR, JOHAB ++ ไบš็พŽๅฐผไบš่ฏญ + + ARMSCII-8 ++ ๆ ผ้ฒๅ‰ไบš่ฏญ + + Georgian-Academy, Georgian-PS ++ ๅก”ๅ‰ๅ…‹่ฏญ + + KOI8-T ++ ๅ“ˆ่จๅ…‹่ฏญ + + PT154, RK1048 ++ ๆณฐ่ฏญ + + ISO-8859-11, TIS-620, CP874, MacThai ++ ่€ๆŒ่ฏญ + + MuleLao-1, CP1133 ++ ่ถŠๅ—่ฏญ + + VISCII, TCVN, CP1258 ++ ๅนณๅฐ็‰นๅฎš + + HP-ROMAN8, NEXTSTEP ++ ๅฎŒๆ•ด็š„ Unicode + + UTF-8 + + UCS-2, UCS-2BE, UCS-2LE + + UCS-4, UCS-4BE, UCS-4LE + + UTF-16, UTF-16BE, UTF-16LE + + UTF-32, UTF-32BE, UTF-32LE + + UTF-7 + + C99, JAVA ++ ๅฎŒๆ•ด็š„ Unicode๏ผŒไปฅ 'uint16_t' ๆˆ– 'uint32_t' ่กจ็คบ + + UCS-2-INTERNAL, UCS-4-INTERNAL ๏ผˆๅ…ทๆœ‰่ฎพๅค‡ไพ่ต–็š„ๅญ—่Š‚ๅบๅ’Œๅฏน้ฝ๏ผ‰ + +ไธ€ไบ›้ขๅค–็š„็ผ–็ ใ€‚่ฟ™ไบ›็ผ–็ ๆ˜ฏ GNU LIBICONV ็š„้ขๅค–็ผ–็ ใ€‚ + ++ ๆฌงๆดฒ่ฏญ่จ€ + + CP{437,737,775,852,853,855,857,858,860,861,863,865,869,1125} ++ ้—ช็ฑณ็‰น่ฏธๆ—่ฏญ่จ€ + + CP864 ++ ๆ—ฅๆœฌ่ฏญ + + EUC-JISX0213, Shift_JISX0213, ISO-2022-JP-3 ++ ไธญๆ–‡ + + BIG5-2003 (experimental) ++ ๅœŸๅบ“ๆ›ผ่ฏญ + + TDS565 ++ ๅนณๅฐ็‰นๅฎš + + ATARIST, RISCOS-LATIN1 ++ EBCDIC ๅ…ผๅฎน็ผ–็ ๏ผˆไธๅ…ผๅฎนASCII๏ผŒๅ‡ ไนŽไธไฝฟ็”จ๏ผ‰ + + ๆฌงๆดฒ่ฏญ่จ€ + + IBM-{037,273,277,278,280,282,284,285,297,423,500,870,871,875,880}, + + IBM-{905,924,1025,1026,1047,1112,1122,1123,1140,1141,1142,1143}, + + IBM-{1144,1145,1146,1147,1148,1149,1153,1154,1155,1156,1157,1158}, + + IBM-{1165,1166,4971} + + ้—ช็ฑณ็‰น่ฏธๆ—่ฏญ่จ€ + + IBM-{424,425,12712,16804} + + ๆณขๆ–ฏ่ฏญ + + IBM-1097 + + ๆณฐ่ฏญ + + IBM-{838,1160} + + ่€ๆŒ่ฏญ + + IBM-1132 + + ่ถŠๅ—่ฏญ + + IBM-{1130,1164} + + ๅฐๅบฆ่ฏญ + + IBM-1137 + +ๅฎƒๅฏไปฅ้€š่ฟ‡ Unicode ไปŽ่ฟ™ไบ›็ผ–็ ไธญ็š„ไปปไฝ•ไธ€็ง่ฝฌๆขไธบไปปไฝ•ๅ…ถไป–็ผ–็  +่ฝฌๆขใ€‚ + +## ็ผ–่ฏ‘้€‰้กน + +ไฝฟ็”จ CMake ่ฟ›่กŒๆž„ๅปบ + ++ `BUILD_TESTING`: ็ผ–่ฏ‘ๆต‹่ฏ•ๅทฅๅ…ทใ€‚้ป˜่ฎคไธบ `ON`. + +```shell +cmake .. -DBUILD_TESTING=ON +cmake --build . --config=RelWithDebInfo +ctest -C RelWithDebInfo --output-on-failure +``` + ++ `ICONV_COMPAT`: ๅฏ็”จ iconv ๅ…ผๅฎนใ€‚้ป˜่ฎคไธบ `OFF`. + +ๅฆ‚ๆžœ `ICONV_COMPAT` ๅผ€ๅฏ๏ผŒไผšๅฎ‰่ฃ… `iconv.h` ๅ’ŒๅŸบๆœฌ็š„ๅ‡ฝๆ•ฐใ€‚ +ไฝ†ๆ˜ฏๆˆ‘ไปฌไธๆ”ฏๆŒ POSIX:2024 ็š„ๆ‰€ๆœ‰ๅŠŸ่ƒฝใ€‚ๅ‚่ง [TODO](TODO). + +## ๅฎ‰่ฃ… + +ๆญคๅบ“ๅฎ‰่ฃ…๏ผš + ++ ๅŠจๆ€ๅบ“ `libcppp-reiconv`ใ€‚ ++ ้™ๆ€ๅบ“ `libcppp-reiconv.static`ใ€‚ ++ ๅคดๆ–‡ไปถใ€‚ + +```text +include +โ”œโ”€โ”€ cppp +โ”‚ โ”œโ”€โ”€ cppp-platform.h +โ”‚ โ”œโ”€โ”€ encodings +โ”‚ โ”‚ โ”œโ”€โ”€ reiconv.h +โ”‚ โ”‚ โ””โ”€โ”€ reiconv.hpp +โ”‚ โ”œโ”€โ”€ reiconv.h +โ”‚ โ””โ”€โ”€ reiconv.hpp +โ””โ”€โ”€ iconv.h # ไป…ๅฝ“ ICONV_COMPAT ๅผ€ๅฏๆ‰ๅญ˜ๅœจ +``` + +## ็‰ˆๆƒ + +cppp-reiconv ไฝฟ็”จ LGPLv3๏ผŒๅ‚่ง [LICENSE](./LICENSE). + +## ไธ‹่ฝฝ + +ๅ‚่ง + +## ไธป้กต + + + +## Bug ๅ้ฆˆ + ++ ่ฏทๅœจ GitHub ๅˆ›ๅปบ issue [ๆฅไธ€ไธช](https://github.com/cppp-project/cppp-reiconv/issues/new/) diff --git a/TODO b/TODO new file mode 100644 index 00000000..a1951d25 --- /dev/null +++ b/TODO @@ -0,0 +1,4 @@ +1. Implement the //NON_IDENTICAL_DISCARD suffix from POSIX:2024. +2. Add translit support. +3. Use xmake buildsystem. +4. Fix testing errors on some Windows machine. diff --git a/benchmark/benchmark.cpp b/benchmark/benchmark.cpp new file mode 100644 index 00000000..03253a0f --- /dev/null +++ b/benchmark/benchmark.cpp @@ -0,0 +1,112 @@ +#include "benchmark.hpp" +#include "cppp/reiconv.h" +#include +#include + +#include +#include +#include + +char *test_string_utf8; +std::size_t test_string_utf8_len; + +static void reiconv(benchmark::State &state) +{ + char output[test_string_utf8_len * 4]; + void *cd = reiconv_iconv_open(); + for (auto _ : state) + { + reiconv_convert_static_size(cd, test_string_utf8, test_string_utf8_len, output, test_string_utf8_len * 4); + } +} +BENCHMARK(reiconv); + +static void glibc(benchmark::State &state) +{ + char output[test_string_utf8_len * 4]; + void *cd = glibc_iconv_open(); + for (auto _ : state) + { + glibc_static_size_convert(cd, test_string_utf8, test_string_utf8_len, output, test_string_utf8_len * 4); + } +} +BENCHMARK(glibc); + +static void libiconv(benchmark::State &state) +{ + char output[test_string_utf8_len * 4]; + void *cd = libiconv_iconv_open(); + for (auto _ : state) + { + libiconv_static_size_convert(cd, test_string_utf8, test_string_utf8_len, output, test_string_utf8_len * 4); + } +} +BENCHMARK(libiconv); + +static void libicu(benchmark::State &state) +{ + UErrorCode status{U_ZERO_ERROR}; + char output[test_string_utf8_len * 4]; + + for (auto _ : state) + { + ucnv_convert("GB18030", "UTF-8", output, test_string_utf8_len * 4, test_string_utf8, test_string_utf8_len, + &status); + } +} +BENCHMARK(libicu); + +void init_test_string(std::size_t len) +{ + constexpr const char *const test_string = + "\u6211\u80fd\u541e\u4e0b\u8eab\u4f53\u800c\u4e0d\u4f24\u8eab\u4f53\u30021234567890ABCD"; + constexpr const std::size_t test_string_len = 50; + test_string_utf8 = new char[test_string_len * len]; + test_string_utf8_len = test_string_len * len; + for (std::size_t i = 0; i < len; ++i) + { + std::memcpy(test_string_utf8 + i * test_string_len, test_string, test_string_len); + } +} + +static inline bool isdigit(const std::string_view str) +{ + for (const char c : str) + { + if (!std::isdigit(c)) + { + return false; + } + } + return true; +} + +const char *const_argv_default[2] = {"benchmark", "--benchmark_format=json"}; +int main(int argc, char **argv) +{ + if (argc != 2) + { + std::fputs("Usage: benchmark \n", stderr); + return EXIT_FAILURE; + } + if (!isdigit(argv[1])) + { + std::fputs("Error: test_string_repeat_times must be a number.\n", stderr); + return EXIT_FAILURE; + } + + std::size_t len = std::atoi(argv[1]); + init_test_string(len); + + int argc_default = 2; + ::benchmark::Initialize(&argc_default, const_cast(const_argv_default)); + if (::benchmark::ReportUnrecognizedArguments(argc_default, const_cast(const_argv_default))) + { + return EXIT_FAILURE; + } + ::benchmark::RunSpecifiedBenchmarks(); + ::benchmark::Shutdown(); + + delete[] test_string_utf8; // Not necessary. + return EXIT_SUCCESS; +} diff --git a/benchmark/benchmark.hpp b/benchmark/benchmark.hpp new file mode 100644 index 00000000..0595809b --- /dev/null +++ b/benchmark/benchmark.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include + +#include + +extern void* glibc_iconv_open(); +extern int glibc_static_size_convert(void* cd, const char *input_data, size_t input_length, char *output_data, + size_t output_length); + +extern void* libiconv_iconv_open(); +extern int libiconv_static_size_convert(void* cd, const char *input_data, size_t input_length, char *output_data, + size_t output_length); + +extern void* reiconv_iconv_open(); + diff --git a/benchmark/benchmark.md b/benchmark/benchmark.md new file mode 100644 index 00000000..45ae50e4 --- /dev/null +++ b/benchmark/benchmark.md @@ -0,0 +1,18 @@ +# Benchmark + +## Compile command + +```bash +cd benchmark +g++ *.cpp -I/tmp/inst/include /tmp/inst/lib/libicudata.a /tmp/inst/lib/libicuuc.a /tmp/inst/lib/libiconv.a /tmp/inst/lib/libcharset.a /tmp/inst/lib/libcppp-reiconv.static.a /usr/local/lib/libbenchmark.a /tmp/inst/lib/*.a -O2 -fPIC -Wall -o benchmark +``` + +## GCC version + +```text +gcc (Debian 14.2.0-8) 14.2.0 +``` + +## Benchmark result + +![benchmark result](./benchmark.png) diff --git a/benchmark/benchmark.png b/benchmark/benchmark.png new file mode 100644 index 00000000..694e3793 Binary files /dev/null and b/benchmark/benchmark.png differ diff --git a/benchmark/compile.sh b/benchmark/compile.sh new file mode 100755 index 00000000..ec5c9065 --- /dev/null +++ b/benchmark/compile.sh @@ -0,0 +1,2 @@ +#!/bin/sh +g++ *.cpp /tmp/inst/lib/libcppp-reiconv.static.a /tmp/inst/lib/libcharset.a /tmp/inst/lib/libiconv.a -I/tmp/inst/include /workspaces/benchmark/build/src/libbenchmark.a -licuuc -O3 -fPIC -o benchmark diff --git a/benchmark/glib_iconv.cpp b/benchmark/glib_iconv.cpp new file mode 100644 index 00000000..cdadd6f7 --- /dev/null +++ b/benchmark/glib_iconv.cpp @@ -0,0 +1,48 @@ +#include "benchmark.hpp" + +#include +#include +#include + +extern "C" +{ + typedef void* iconv_t; + void* iconv_open(const char* tocode, const char* fromcode); + int iconv_close(void* cd); + size_t iconv(void* cd, char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft); +} + +void* glibc_iconv_open() +{ + return iconv_open("GB18030", "UTF-8"); +} + +int glibc_static_size_convert(void* cd, const char *input_data, size_t input_length, char *output_data, + size_t output_length) +{ + char *inptr = (char *)input_data; + size_t insize = input_length; + char *outptr = output_data; + size_t outsize = output_length; + while (insize > 0) + { + size_t res = iconv(cd, &inptr, &insize, &outptr, &outsize); + if (res == (size_t)(-1)) + { + if (errno == EINVAL) + { + break; + } + else + { + return -1; + } + } + } + if (iconv(cd, NULL, NULL, &outptr, &outsize) == (size_t)(-1)) + { + return -1; + } + memset(outptr, 0, outsize); // Fill the rest of the buffer with '\0'. + return 0; +} diff --git a/benchmark/libiconv_iconv.cpp b/benchmark/libiconv_iconv.cpp new file mode 100644 index 00000000..3ba779da --- /dev/null +++ b/benchmark/libiconv_iconv.cpp @@ -0,0 +1,52 @@ +#include "benchmark.hpp" +#include +#include +#include + +#define iconv_t libiconv_t +#define iconv_open libiconv_open +#define iconv libiconv +#define iconv_close libiconv_close + +extern "C" +{ + typedef void *iconv_t; + extern int iconv_close(iconv_t cd); + extern iconv_t iconv_open(const char *tocode, const char *fromcode); + extern size_t iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); +} + +void* libiconv_iconv_open() +{ + return iconv_open("GB18030", "UTF-8"); +} + +int libiconv_static_size_convert(void* cd, const char *input_data, size_t input_length, char *output_data, + size_t output_length) +{ + char *inptr = (char *)input_data; + size_t insize = input_length; + char *outptr = output_data; + size_t outsize = output_length; + while (insize > 0) + { + size_t res = iconv(cd, &inptr, &insize, &outptr, &outsize); + if (res == (size_t)(-1)) + { + if (errno == EINVAL) + { + break; + } + else + { + return -1; + } + } + } + if (iconv(cd, NULL, NULL, &outptr, &outsize) == (size_t)(-1)) + { + return -1; + } + memset(outptr, 0, outsize); // Fill the rest of the buffer with '\0'. + return 0; +} diff --git a/benchmark/reiconv_iconv.cpp b/benchmark/reiconv_iconv.cpp new file mode 100644 index 00000000..9d36cf5e --- /dev/null +++ b/benchmark/reiconv_iconv.cpp @@ -0,0 +1,12 @@ +#include "benchmark.hpp" + +#include + +#include +#include +#include + +void* reiconv_iconv_open() +{ + return reiconv_open_from_index(ENCODING_UTF8, ENCODING_GB18030, REICONV_NO_FLAGS); +} diff --git a/benchmark/run.py b/benchmark/run.py new file mode 100755 index 00000000..76d26578 --- /dev/null +++ b/benchmark/run.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python3 + +"""Run the benchmark and plot the results.""" + +from __future__ import annotations + +import json +import sys +from pathlib import Path +from subprocess import PIPE, Popen + +import rich +import rich.progress +from matplotlib import pyplot as plt + +TEST_STRING_LEN = 50 +MAX_REPET_TIME = 100 + +data: dict[str, list[list[float]]] = {} + + +def command(args: list[str] | str) -> str: + """Generate shell command from a list of arguments. + + Args: + args (list[str] | str): The list of arguments. + + Returns: + str: The shell command. + + """ + if isinstance(args, str): + return args + + res_command = "" + for arg in args: + if " " in arg: + if '"' in arg: + arg = arg.replace('"', '\\"') # noqa: PLW2901 + res_command += f'"{arg}" ' + else: + res_command += f"{arg} " + return res_command.strip() + + +def add_data(str_repet_time: int, benchmark_name: str, time: float) -> None: + """Add data to the data dict. + + Args: + str_repet_time (int): The number of times the test string is + repeated. + benchmark_name (str): The name of the test. + time (float): The time taken to run the test. + + """ + if benchmark_name not in data: + data[benchmark_name] = [] + data[benchmark_name].append([str_repet_time * TEST_STRING_LEN, time]) + + +if __name__ == "__main__": + cwd = (Path(sys.argv[0]) / "..").resolve() + executable = cwd / "benchmark" + executable.chmod(0o755) + + with rich.progress.Progress() as progress: + task = progress.add_task("Running", total=MAX_REPET_TIME) + for test_string_repet_time in range(MAX_REPET_TIME): + with Popen( # noqa: S603 + [str(executable), str(test_string_repet_time)], + cwd=cwd, + shell=False, + stdout=PIPE, + ) as proc: + arg1 = command([str(executable)]) + rich.print( + f"Running benchmark: [green]{arg1}[/green] " + f"{test_string_repet_time} ...", + ) + if proc.wait() != 0: + rich.print( + f"[red]Error: Process failed with code " + f"{proc.returncode}[/red]", + ) + sys.exit(1) + proc.stdout.flush() # type: ignore[attr-defined] + test_data = json.loads( + proc.stdout.read().decode( # type: ignore[attr-defined] + "UTF-8", + ), + ) + for unit_data in test_data["benchmarks"]: + add_data( + test_string_repet_time, + unit_data["run_name"], + unit_data["real_time"], + ) + progress.update(task, advance=1) + + rich.print("[green]All benchmarks have been run successfully.[/green]") + rich.print(data) + + for name, values in data.items(): + plt.plot(*zip(*values), label=name) + plt.legend() + plt.xlabel("Test string length (bytes)") + plt.ylabel("Time (ns)") + plt.title("Benchmark") + plt.show() diff --git a/cpack.cmake b/cpack.cmake new file mode 100644 index 00000000..9ee54a15 --- /dev/null +++ b/cpack.cmake @@ -0,0 +1,36 @@ +# Copyright (C) 2024 The C++ Plus Project. +# This file is part of the cppp-reiconv library. +# +# The cppp-reiconv library is free software; you can redistribute it +# and/or modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either version 3 +# of the License, or (at your option) any later version. +# +# The cppp-reiconv library is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with the cppp-reiconv library; see the file LICENSE. +# If not, see . + +include(InstallRequiredSystemLibraries) + +# Set the package generator. +set(CPACK_GENERATOR "DEB") + +# Set package information. +set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME}) +set(CPACK_PACKAGE_VERSION ${CMAKE_PROJECT_VERSION}) +set(CPACK_PACKAGE_DESCRIPTION ${CMAKE_PROJECT_DESCRIPTION}) +set(CPACK_PACKAGE_CONTACT "ChenPi11 ") + +# Configure package-specific settings. +set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT}) +set(CPACK_DEBIAN_PACKAGE_SECTION "devel") +set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${PROJECT_HOMEPAGE_URL}) +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.31), libgcc-s1 (>= 10.2.0), libstdc++6 (>= 10.2.0)") + +# Generate the package. +include(CPack) diff --git a/cpppdist.py b/cpppdist.py deleted file mode 100755 index f65e6bd2..00000000 --- a/cpppdist.py +++ /dev/null @@ -1,195 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright (C) 2023 The C++ Plus Project. -# This file is part of the cppp library. -# -# The cppp library is free software; you can redistribute it -# and/or modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either version 3 -# of the License, or (at your option) any later version. -# -# The cppp library is distributed in the hope that it will be -# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with the cppp library; see the file COPYING. -# If not, see . - -# C++ Plus dist utils. - -import os -import sys -import json -import shutil -import importlib.util - -PACKAGE_INFO = "CPPPPKG" -PROGNAME = "cpppdist.py" - -def import_file(path): - """ - Import a Python file from it's path - - Args: - path (str): Python file's path - - Raises: - ModuleNotFoundError: When module invalid, load error or not found. - - Returns: - ModuleType: module - """ - spec = importlib.util.spec_from_file_location(os.path.basename(path).replace(".py", ""), path) - if(spec == None): - raise ModuleNotFoundError("Invalid module or module not found: " + path) - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - return module - -class Package: - """ - A dist package type - """ - name = "" - version = "" - list_file_path = "" - filelist = [] - subpackages = {} - - def __init__(self, pkginfo_filepath) -> None: - try: - os.chdir(fwd) - with open(pkginfo_filepath, "r", encoding="UTF-8") as info_file: - data = json.load(info_file) - self.name = data["name"] - self.version = data["version"] - self.list_file_path = data["list_file_path"] - try: - _subpackages = data["subpackages"] - for pkgname in _subpackages: - pkgpath = _subpackages[pkgname]["path"] - try: - pkgmodule = import_file(os.path.join(pkgpath, PROGNAME)) - self.subpackages[pkgpath] = pkgmodule.package - except Exception as e: - if(not _subpackages[pkgname]["ignore"]): - raise - else: - print(f"DEBUG: Ignore a subpackage '{pkgname}': {e}", file=sys.stderr) - except KeyError: - pass - self.filelist = self.get_file_list() - finally: - os.chdir(cwd) - - def get_file_list(self) -> list: - """ - Get file list for dist. - """ - try: - os.chdir(fwd) - file_list = [] - with open(self.list_file_path, "rt", encoding="UTF-8") as list_file: - data = list_file.read() - file_list = data.strip().split("\n") - return file_list - finally: - os.chdir(cwd) - - def copy_files(self, dest): - """ - Copy files to dist dest - """ - try: - os.chdir(fwd) - if(os.path.exists(dest)): - shutil.rmtree(dest) - print(f"Copy package '{self.name}' to '{dest}' ... ", file=sys.stderr) - progressbar = ProgressBar(len(self.filelist)) - for file in self.filelist: - relpath = os.path.relpath(file, fwd) - filedir = os.path.abspath(os.path.join(dest, relpath, "..")) - if(not os.path.exists(filedir)): - os.makedirs(filedir) - shutil.copy(file, os.path.join(dest, relpath)) - progressbar.add(1) - progressbar.end() - print("", end="\n", file=sys.stderr) - # Copy subpackages - for (pkgpath, pkg) in self.subpackages.items(): - pkg.copy_files(os.path.join(dest, os.path.join(dest, pkgpath))) - finally: - os.chdir(cwd) - -class ProgressBar: - """ - Progress bar type. - """ - def __init__(self, total): - self.total = total - self.cur = 0 - sys.stderr.write("\n") - self.update() - - def add(self, step): - """ - Add current value and update. - """ - self.cur += step - self.update() - - def set(self, cur): - """ - Set current value and update. - """ - self.cur = cur - self.update() - - def update(self): - """ - Update progress bar. - """ - try: - progress = 0.0 - if(self.cur): - progress = self.cur / self.total - term_width = os.get_terminal_size(sys.stderr.fileno()).columns - part_width = term_width - len("[]100.0%") - if(part_width <= 0): - # Terminal is too small, ignore. - return - sys.stderr.write("\r") - # Part1 is '#' - part1 = int(part_width * progress) * '#' - # Part2 is ' ' - part2 = int(part_width - len(part1)) * ' ' - # Part3 is 'xxx.x%' - part3 = str(int(progress * 1000) / 10) + "%" - sys.stderr.write(f"[{part1}{part2}]{part3}") - sys.stderr.flush() - except: - return - - def end(self): - """ - End this progress bar - """ - self.set(self.total) - sys.stderr.write("\n") - sys.stderr.flush() - -cwd = os.path.abspath(os.curdir) -fwd = os.path.abspath(os.path.join(__file__, "..")) - -package = None -try: - package = Package(PACKAGE_INFO) -except Exception as exc: - print("Getting packge infomation error:", exc, file=sys.stderr) - raise exc - -if __name__ == "__main__": - distdir = f"{package.name}-v{package.version}" - package.copy_files(os.path.abspath(distdir)) diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..2fab3c1b --- /dev/null +++ b/docs/README.md @@ -0,0 +1,47 @@ +# cppp-reiconv documentation + +[[Simplified Chinese]](zh_CN/README.md) + +## Introduction + +These docs is for `cppp-reiconv 3.0.0`. + +It's a unstable version. + +cppp-reiconv is a portable C/C++ library for converting between character +encodings and locale charset detection. + +## Requirements + +### Build + +- A C++ compiler with C++20 support. +- CMake 3.12 or later. + +### Runtime + +- C runtime. +- C++ runtime with C++20 support. + +### Build with data generation + +We need to generate index for encoding, they are stored in `lib/generated`. + +**You can skip this section if you are not interested in it.** +**We already provide generated data in this Git repository and source tarball.** + +- GNU Make. +- GNU Gperf. +- A POSIX system. + +After you have installed these tools, you can use the following command to +generate data: + +```shell +make -f Makefile.devel -B +``` + +## API Reference + +- [C api reference and iconv compatibility](c-api.md) +- [C++ api reference](cpp-api.md) diff --git a/docs/c-api.md b/docs/c-api.md new file mode 100644 index 00000000..bc5dc05f --- /dev/null +++ b/docs/c-api.md @@ -0,0 +1,639 @@ +# cppp-reiconv C API + +Although we have C API, we still require C++20 runtime. + +Header file `cppp/reiconv.h` contains all C API. + +## Version Information API + +### `struct VersionInfo` + +#### Description + +This struct contains version information. + +#### Values + +- `int major`: Major version. +- `int minor`: Minor version. +- `int patch`: Patch version. + +### `reiconv_version` + +#### Description + +It's a variable for version information of current library. + +#### Example + +```c +printf("cppp-reiconv version: %d.%d.%d\n", reiconv_version.major, reiconv_version.minor, reiconv_version.patch); +``` + +## Encoding Names API + +### `reiconv_name_canonicalize()` + +#### Definition + +```c +extern _CPPP_API size_t reiconv_name_canonicalize(const char *name, char *outbuf); +``` + +#### Description + +Canonicalize an encoding name. The `canonical` means the internal name of +encoding. Not the canonical name of IANA. +We will ignore '-' and '_', and uppercase all characters. + +Segment fault if `name` or `outbuf` is `nullptr`. We will not check the +length of `outbuf`. + +**This function is not recommended to use.** + +#### Parameters + +- `name`: The encoding name to be canonicalized. +- `outbuf`: The buffer for storing the canonicalized name. +Must allocated with enough space. + +#### Return + +The length of canonicalized name. + +#### Example + +```c +const char* name = "UCS-4" +char outbuf[256]; +size_t outbuf_size = reiconv_name_canonicalize(name, outbuf); +// outbuf_size == 4, outbuf == "UCS4" +``` + +### `reiconv_lookup_from_name()` + +#### Definition + +```c +extern _CPPP_API int reiconv_lookup_from_name(const char *encoding); +``` + +#### Description + +Lookup an encoding by it's name. + +#### Parameters + +- `encoding`: The encoding name. It's not case sensitive. +**It must be a valid pointer, or it will cause undefined behavior.** + +#### Return + +The encoding index. If the it is not found, `-1` is returned. + +The `encoding index` is the unique ID in cppp-reiconv's internal. +Used in `reiconv_open()` function. + +#### Example + +```c +int encoding_index = reiconv_lookup_from_name("UTF-8"); +``` + +### `reiconv_lookup_from_codepage()` + +#### Definition + +```c +extern _CPPP_API int reiconv_lookup_from_codepage(int codepage); +``` + +#### Description + +Lookup an encoding by it's codepage. + +#### Parameters + +- `codepage`: The codepage. + +#### Return + +The encoding index. If the it is not found, `-1` is returned. + +#### Example + +```c +// Same as reiconv_lookup_from_name("CP936") +int encoding_index = reiconv_lookup_from_codepage(936); +``` + +## Encoding Conversion API + +### `reiconv_t` + +#### Definition + +```c +typedef void* reiconv_t; +``` + +#### Description + +This is our conversion descriptor type. It's a pointer to a internal `conv_struct`. +Although cppp-reiconv is based on GNU LIBICONV, but our `conv_struct` is not +compatible with GNU LIBICONV's. + +### `ConvertFlag` + +#### Definition + +```c +enum ConvertFlag +{ + REICONV_NO_FLAGS = 0, + REICONV_DISCARD_ILSEQ = 1, +}; +``` + +#### Description + +This is a bitmask for conversion flags. + +- `REICONV_NO_FLAGS`: No flags. Pass it by default. +- `REICONV_DISCARD_ILSEQ`: Discard invalid sequence. +It's same as iconv's `//IGNORE` flag. + +### `reiconv_open_from_index()` + +#### Definition + +```c +extern _CPPP_API reiconv_t reiconv_open_from_index(int fromcode, int tocode, enum ConvertFlag flags); +``` + +#### Description + +Open a conversion descriptor from encoding index. +**Indexes MUST BE VALID or the behavior is undefined.** + +#### Parameters + +- `fromcode`: The encoding index of source encoding. +**CAUTION: reiconv's descriptor open function parameters order is `fromcode` -> `tocode`.** +**But iconv's is `tocode` -> `fromcode`!** +- `tocode`: The encoding index of target encoding. We recommend you to use +encodings enum defined in `cppp/encodings/reiconv.h`. It's automatically generated. +See example below. +- `flags`: The conversion flags. +The `flags` is a bitmask. See `ConvertFlag` for more information. + +#### Return + +If the conversion descriptor cannot be created, returns `(reiconv_t)(-1)` +with errno set. It's same as iconv's return value. **NOT NULL!** + + +This function will error only when memory allocation failed. +**It will not check the validity of `fromcode` and `tocode`!** +**You should always pass encoding index from encodings enum!** + +#### Example + +```c +reiconv_t cd = reiconv_open_from_index( + ENCODING_UTF8, /* Encodings enum always starts with ENCODING_ in C API. */ + ENCODING_GB18030, /* See the header file for more information. */ + REICONV_DISCARD_ILSEQ /* This flag means discard invalid sequence. */ +); +if (cd == (reiconv_t)(-1)) +{ + perror("reiconv_open_from_index"); +} +``` + +### `reiconv_open_from_codepage()` + +#### Definition + +```c +extern _CPPP_API reiconv_t reiconv_open_from_codepage(int fromcode, int tocode, enum ConvertFlag flags); +``` + +#### Description + +Open a conversion descriptor from codepage. This is a shortcut for +`reiconv_lookup_from_codepage()` + `reiconv_open_from_index()`. +See `reiconv_open_from_index()` for more information of parameters. + +#### Parameters + +- `fromcode`: The codepage of source encoding. +- `tocode`: The codepage of target encoding. +- `flags`: The conversion flags. + +#### Return + +If the conversion descriptor cannot be created, +returns `(reiconv_t)(-1)` with errno set. +It will check the validity of `fromcode` and `tocode`. + +Some encodings may not have codepage. You should open them by index or name. + +#### Example + +```c +reiconv_t cd = reiconv_open_from_codepage( + 65001, /* UTF-8 */ + 936, /* CP936 */ + REICONV_DISCARD_ILSEQ +); +if (cd == (reiconv_t)(-1)) +{ + perror("reiconv_open_from_codepage"); +} +``` + +CP936 is a little different from GBK instead. See `lib/converters/cp936.h`. + +The comments in `lib/converters/cp936.h` says (from Bruno Haible): + +> The IANA has CP936 as an alias of GBK. But GBK is an official Chinese +> specification, whereas CP936 is de-facto maintained by Microsoft. And, +> of course, Microsoft modified CP936 since 1999. +> +> The differences from GBK are: +> +> - A single character: +> +> | GBK | CP936 | +> | :----: | :----: | +> | 0x80 | 0x20AC # EURO SIGN | +> +> Some variants of CP936 (in JDK, Windows-2000, ICU) also add: +> +> - Private area mappings: +> +> | code | Unicode | +> | :----: | :----: | +> | 0x{A1..A2}{40..7E,80..A0} | U+E4C6..U+E585 | +> | 0x{AA..AF,F8..FE}{A1..FE} | U+E000..U+E4C5 | +> +> We add them too because, although there are backward compatibility problems +> when a character from a private area is moved to an official Unicode code +> point, they are useful for some people in practice. + +### `reiconv_open_from_name()` + +#### Definition + +```c +extern _CPPP_API reiconv_t reiconv_open_from_name(const char *fromcode, const char *tocode, enum ConvertFlag flags); +``` + +#### Description + +Open a conversion descriptor from encoding name. +This is a shortcut for `reiconv_lookup_from_name()` + `reiconv_open_from_index()`. +See `reiconv_open_from_index()` for more information of parameters. + +#### Parameters + +- `fromcode`: The name of source encoding. It can only pass encoding name. +control suffix like `//IGNORE` or `//TRANSLIT` **is not allowed**. +- `tocode`: The name of target encoding. +- `flags`: The conversion flags. + +#### Return + +If the conversion descriptor cannot be created, +returns `(reiconv_t)(-1)` with errno set. +It will check the validity of `fromcode` and `tocode`. + +#### Example + +```c +reiconv_t cd = reiconv_open_from_name( + "UTF-8", + "GB18030", + REICONV_NO_FLAGS +); +if (cd == (reiconv_t)(-1)) +{ + perror("reiconv_open_from_name"); +} +``` + +### `reiconv_result_size()` + +#### Definition + +```c +extern _CPPP_API size_t reiconv_result_size(reiconv_t cd, const char *start, size_t inlength); +``` + +#### Description + +Get the size of converted string. + +#### Parameters + +- `cd`: The conversion descriptor. +- `start`: The start of input string. +- `inlength`: The length of input string. + +#### Return + +The size of converted string. If the conversion failed, returns `(size_t)(-1)`. + +**It's don't support flags now, so `flags` is always `REICONV_NO_FLAGS`. We will** +**support it in the next version. So this API will change in the next version.** + +#### Example + +```c +const char input[] = "Hello, World!"; +size_t result_size = reiconv_result_size(cd, input, strlen(input)); + +if (result_size == (size_t)(-1)) +{ + perror("reiconv_result_size"); +} +``` + +### `reiconv_convert_static_size()` + +#### Definition + +```c +extern _CPPP_API int reiconv_convert_static_size(reiconv_t cd, const char *input_data, size_t input_length, + char *output_data, size_t output_length); +``` + +#### Description + +Converts a string using conversion descriptor `cd`, with a static size output buffer. + +If the output buffer is too small, -1 is returned. + +If the output buffer is too big, the rest of the buffer will not change. + +This function is useful when you want to convert a string to a fixed size buffer +like stack buffer. It's faster than `reiconv_convert`. + +#### Parameters + +- `cd`: The conversion descriptor. +- `input_data`: The input buffer. +- `input_length`: The length of input buffer. +- `output_data`: The output buffer. +- `output_length`: The length of output buffer. + +#### Return + +The length of converted string. If the conversion failed, returns `(size_t)(-1)`. + +#### Example + +```c +const char input[] = "Hello, World!"; +char output[256]; +size_t result_size = reiconv_convert_static_size(cd, input, strlen(input), output, sizeof(output)); +if (result_size == (size_t)(-1)) +{ + perror("reiconv_convert_static_size"); +} +``` + +### `reiconv_convert()` + +#### Definition + +```c +extern _CPPP_API int reiconv_convert(reiconv_t cd, const char *input_data, size_t input_length, char **output_data_ptr, + size_t *output_length_ptr); +``` + +#### Description + +Converts an string from one encoding to another. + +This function is the most convenient function of cppp-reiconv. It will automatically +summary the size of converted string, and allocate memory for you. + +But size summary is always a little slow. If you know the size of converted string, +you should use `reiconv_convert_static_size()` instead. + +This function does not treat zero characters specially. + +Its code comes from `iconv_string()` in GNU LIBICONV's repository. + +See + +Bruno Haible put this file into the public domain. +`iconv_string.h` is not part of the GNU LIBICONV Library. + +#### Parameters + +- `cd`: The conversion descriptor. +- `input_data`: The input buffer. +- `input_length`: The length of input buffer. +- `output_data_ptr`: The output buffer's pointer. If it point to a `NULL` pointer, +we will allocate memory for you and set it to the result buffer. If pointed but +not `NULL`, we will use it as the output buffer but reallocate it. So it must be +a pointer that can be modified. +**But don't let output_data_ptr's value to `NULL`!** +- `output_length_ptr`: The length of output buffer. If NULL, error will be occured. + +#### Return + +We only return `0` if success. If failed, returns `-1` with errno set. +Our output buffer is saved in `output_data_ptr`. + +**NOTE: Please free the output buffer after use it!** +**It's always dynamic allocated!** + +#### Example + +```c +const char input[] = "Hello, World!"; +char *output = NULL; /* NULL means we will allocate memory for you. */ +size_t output_length = 0; +int result = reiconv_convert(cd, input, strlen(input), &output, &output_length); +if (result == -1) +{ + perror("reiconv_convert"); +} +printf("%zu: %s\n", output_length, output); +free(output); +``` + +```c +const char input[] = "Hello, World!"; +char* output = malloc(1); /* We will reallocate it. */ +if (output == NULL) +{ + perror("malloc"); +} +size_t output_length = 0; +int result = reiconv_convert(cd, input, strlen(input), &output, &output_length); +if (result == -1) +{ + perror("reiconv_convert"); +} +printf("%zu: %s\n", output_length, output); +free(output); +``` + +### `reiconv_handle_close()` + +#### Definition + +```c +extern _CPPP_API int reiconv_handle_close(reiconv_t cd); +``` + +#### Description + +Close a conversion descriptor. + +#### Parameters + +- `cd`: The conversion descriptor. + +#### Return + +We only return `0` if success. We always return `0` now. +Because we only need to free the conversion descriptor's memory. + +#### Example + +```c +/* This function need a example??? */ +reiconv_handle_close(cd); +``` + +## Locale charset API + +### `locale_charset()` + +#### Definition + +```c +extern _CPPP_API const char* locale_charset(); +``` + +#### Description + +Determine the current locale's character encoding. But not same as GNU LIBICONV's +implementation, we will not canonicalize the encoding name. But nearly the most of +it's result can be used in `reiconv_open_from_name()`. Except for some VERY RARE +encodings or some OSX specific encodings in old OSX versions. These encodings are +not supported in cppp-reiconv and GNU LIBICONV. + +#### Return + +The current locale's character encoding. + +#### Example + +```c +setlocale(LC_ALL, ""); +const char* charset = locale_charset(); +printf("Your locale charset is: %s\n", charset); +``` + +## Iconv compatibility API + +**This API is not recommended to use in `cppp/reiconv.h`. Use it in our `iconv.h`** +**instead.** + +Iconv compatibility is disabled by default. You can enable it by defining +`-DICONV_COMPAT=ON` when you configure cppp-reiconv. + +### `iconv_t`, aka `reiconv_t` in `cppp/reiconv.h` + +#### Definition + +```c +#define iconv_t reiconv_t +``` + +Same as `reiconv_t` up above. + +### `iconv_open`, aka `reiconv_open()` in `cppp/reiconv.h` + +#### Definition + +In `cppp/reiconv.h`: + +```c +extern _CPPP_API reiconv_t reiconv_open(const char *tocode, const char *fromcode); +``` + +In `iconv.h`: + +```c +#define iconv_open reiconv_open +``` + +#### Description + +Open a conversion descriptor. For iconv compatibility. + +#### Parameters + +- `tocode`: The name of target encoding. **CAUTION: iconv-compatible API's** +**parameters order is `fromcode` -> `tocode`!** +- `fromcode`: The name of source encoding. We support `//IGNORE` now. + +#### Return + +The conversion descriptor. (reiconv_t)(-1) is returned if error occured with +errno set. + +### `iconv`, aka `reiconv_iconv()` in `cppp/reiconv.h` + +#### Definition + +In `cppp/reiconv.h`: + +```c +extern _CPPP_API size_t reiconv_iconv(reiconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, + size_t *outbytesleft); +``` + +In `iconv.h`: + +```c +#define iconv reiconv_iconv +``` + +#### Description + +Do conversion. For iconv compatibility. + +See `man 3 iconv`. + +#### Parameters + +- `cd`: The conversion descriptor. +- `inbuf`: The input buffer. +- `inbytesleft`: The length of input buffer. +- `outbuf`: The output buffer. +- `outbytesleft`: The length of output buffer. + +#### Return + +The length of converted string. + +### `iconv_close`, aka `reiconv_handle_close()` in `cppp/reiconv.h` + +#### Definition + +In `iconv.h`: + +```c +#define iconv_close reiconv_handle_close +``` + +Same as `reiconv_handle_close()` up above. diff --git a/docs/cpp-api.md b/docs/cpp-api.md new file mode 100644 index 00000000..135c0456 --- /dev/null +++ b/docs/cpp-api.md @@ -0,0 +1,240 @@ +# cppp-reiconv C++ API + +C++ API may a bit slower than C API. But it is more convenient to use. + +## Version Information API + +### `struct VersionInfo` + +#### Description + +This struct contains version information. + +#### Values + +- `int major`: Major version. +- `int minor`: Minor version. +- `int patch`: Patch version. + +### `reiconv::version` + +#### Description + +It's a variable for version information of current library. + +#### Example + +```cpp +std::cout << "cppp-reiconv version: " << reiconv::version.major << "." + << reiconv::version.minor << "." << reiconv::version.patch << std::endl; +``` + +## Encoding Conversion API + +### `class reiconv::Encoding` + +Encoding class wraps encoding lookup functions. + +It can convert to a int value, equals to the internal encoding id. + +#### Construct from a encoding name + +Construct an encoding object from a encoding name. + +##### Definition + +```cpp +public: +_CPPP_API Encoding(const char* const name); +_CPPP_API Encoding(const std::string& name); +``` + +##### Parameters + +- `name`: The encoding name. `//` suffix is not allowed. + +##### Return + +- `Encoding`: The encoding object. + +##### Throws + +- `std::invalid_argument`: If the encoding name is not valid. + +#### Construct from a codepage + +Construct an encoding object from a codepage. + +##### Definition + +```cpp +public: +_CPPP_API Encoding(const int codepage); +``` + +##### Parameters + +- `codepage`: The codepage. This cannot open a encoding that do not have a +codepage. + +##### Return + +- `Encoding`: The encoding object. + +##### Throws + +- `std::invalid_argument`: If the codepage is invalid. + +#### Construct from a encoding id + +##### Definition + +```cpp +public: +constexpr Encoding(const Encodings index); +``` + +##### Parameters + +- `index`: The encoding id. Available encoding ids are defined in enum class `reiconv::Encodings`. + +##### Return + +- `Encoding`: The encoding object. + +##### Throws + +noexcept, **but we will not check if the encoding id is valid. So please pass a valid** +**encoding id from `reiconv::Encodings`. Or you will get undefined behavior.** + +#### Convert to int + +##### Definition + +```cpp +public: +operator int() const noexcept; +``` + +##### Return + +- `int`: The encoding id. + +#### Comparation + +##### Definition + +```cpp +public: +bool operator==(const Encoding other) const noexcept; +``` + +##### Parameters + +- `other`: The other encoding object. + +##### Return + +- `bool`: True if the two encoding objects are equal. If equal, they have the +same encoding id. + +#### Example + +```cpp +reiconv::Encoding gb18030(reiconv::Encodings::GB18030); // Open from encoding id. +reiconv::Encoding cp936(936); // Open from codepage. +reiconv::Encoding cp936_2("cp936"); // Open from encoding name. +reiconv::Encoding utf8("UTF-8"); + +std::cout << "(int)gb18030: " << (int)gb18030 << std::endl; +std::cout << "cp936 == cp936_2: " << (cp936 == cp936_2) << std::endl; // True +std::cout << "cp936 == utf8: " << (cp936 == utf8) << std::endl; // False +``` + +### `enum class reiconv::ConvertFlag` + +#### Definition + +```c +enum class ConvertFlag +{ + NO_FLAGS = 0, + DISCARD_ILSEQ = 1, +}; +``` + +#### Description + +This is a bitmask for conversion flags. + +- `NO_FLAGS`: No flags. Pass it by default. +- `DISCARD_ILSEQ`: Discard invalid sequence. +It's same as iconv's `//IGNORE` flag. + +Use `|` to combine flags. Use it in `reiconv::convert` function. + +### `reiconv::convert()` + +#### Definition + +```cpp +extern _CPPP_API std::string convert(Encoding from, Encoding to, const std::string_view input, enum ConvertFlag flag = ConvertFlag::NO_FLAGS); +``` + +#### Description + +Convert a string from one encoding to another. It will automatically allocate +memory for the output string. + +#### Parameters + +- `from`: The source encoding. +- `to`: The target encoding. +- `input`: The input string. +- `flag`: The conversion flags. Default is `ConvertFlag::NO_FLAGS`. + +#### Return + +- `std::string`: The converted string. + +#### Throws + +- `std::system_error` If the conversion failed. Use it because it's has errno set. + +#### Example + +```cpp +const std::string_view src = "\xb8\xfc\xcf\xb2\xe1\xba\xc9\xbd\xc7\xa7\xc0\xef\xd1\xa9\xa3\xac\xc8\xfd\xbe\xfc\xb9\xfd\xba\xf3\xbe\xa1\xbf\xaa\xd1\xd5\xa3\xa1"; +std::string result = reiconv::convert(reiconv::Encodings::GB18030, "UTF-8", src); +std::cout << result << std::endl; +``` + +## Locale charset API + +### `reiconv::locale_charset()` + +#### Definition + +```c +extern _CPPP_API std::string_view locale_charset(); +``` + +#### Description + +Determine the current locale's character encoding. But not same as GNU LIBICONV's +implementation, we will not canonicalize the encoding name. But nearly the most of +it's result can be used in `reiconv::Encoding()`. Except for some VERY RARE +encodings or some OSX specific encodings in old OSX versions. These encodings are +not supported in cppp-reiconv and GNU LIBICONV. + +#### Return + +The current locale's character encoding. + +#### Example + +```cpp +std::setlocale(LC_ALL, ""); +std::string_view charset = reiconv::locale_charset(); +std::cout <<"Your locale charset is: " << charset << std::endl; +``` diff --git a/docs/zh_CN/README.md b/docs/zh_CN/README.md new file mode 100644 index 00000000..68b8c406 --- /dev/null +++ b/docs/zh_CN/README.md @@ -0,0 +1,41 @@ +# cppp-reiconv ๆ–‡ๆกฃ + +## ไป‹็ป + +่ฟ™ๆ˜ฏ `cppp-reiconv 3.0.0` ๆ–‡ๆกฃใ€‚ไธ็จณๅฎš็‰ˆๆœฌใ€‚ + +cppp-reiconv ๆ˜ฏไธ€ไธชๅฏ็งปๆค็š„ C/C++ ๅบ“๏ผŒ็”จไบŽๅญ—็ฌฆ็ผ–็ ไน‹้—ด็š„่ฝฌๆขๅ’Œๅญ—็ฌฆ้›†ๆฃ€ๆต‹ใ€‚ + +## ไพ่ต– + +### ๆž„ๅปบ + +- ไธ€ไธชๆ”ฏๆŒ C++20 ็š„ C++ ็ผ–่ฏ‘ๅ™จใ€‚ +- CMake 3.12 ๆˆ–ๆ›ด้ซ˜็‰ˆๆœฌ. + +### ่ฟ่กŒๆ—ถ + +- C ่ฟ่กŒๆ—ถใ€‚ +- ๆ”ฏๆŒ C++20 ็š„ C++ ่ฟ่กŒๆ—ถใ€‚ + +### ็”Ÿๆˆๆ•ฐๆฎ + +ๆˆ‘ไปฌ้œ€่ฆไธบ็ผ–็ ็”Ÿๆˆ็ดขๅผ•๏ผŒๅฎƒไปฌๅญ˜ๅ‚จๅœจ `lib/generated` ไธญใ€‚ + +**ๅฆ‚ๆžœไฝ ไธๆ„Ÿๅ…ด่ถฃ๏ผŒไฝ ๅฏไปฅ่ทณ่ฟ‡่ฟ™ๆญฅ้ชคใ€‚** +**ๆˆ‘ไปฌๅทฒ็ปๅœจ Git ไป“ๅบ“ๅ’Œๆบ็ ๅŒ…ๆไพ›ไบ†็›ธๅ…ณๆ•ฐๆฎใ€‚** + +- GNU Make. +- GNU Gperf. +- ไธ€ไธช POSIX ๆ“ไฝœ็ณป็ปŸ. + +ๅฎ‰่ฃ…ไปฅไธŠๅทฅๅ…ทไปฅๅŽ๏ผŒไฝ ๅฏไปฅ็”จไธ‹้ข็š„ๅ‘ฝไปค็”Ÿๆˆๆ•ฐๆฎ๏ผš + +```shell +make -f Makefile.devel -B +``` + +## API ๅ‚่€ƒ + +- [C API ๅ’Œ iconv ๅ…ผๅฎน API ๅ‚่€ƒ](c-api.md) +- [C++ API ๅ‚่€ƒ](cpp-api.md) diff --git a/docs/zh_CN/c-api.md b/docs/zh_CN/c-api.md new file mode 100644 index 00000000..778c87b6 --- /dev/null +++ b/docs/zh_CN/c-api.md @@ -0,0 +1,617 @@ +# cppp-reiconv C API + +ๅฐฝ็ฎกๆˆ‘ไปฌๆไพ› C API๏ผŒๆˆ‘ไปฌไป้œ€ C++20 ่ฟ่กŒๆ—ถ + +ๅคดๆ–‡ไปถ `cppp/reiconv.h` ๅŒ…ๅซๆ‰€ๆœ‰็š„ C API. + +## ็‰ˆๆœฌไฟกๆฏ API + +### `struct VersionInfo` + +#### ๆ่ฟฐ + +่ฟ™ๆ˜ฏๅŒ…ๅซไบ†็‰ˆๆœฌไฟกๆฏ็š„็ป“ๆž„ไฝ“ใ€‚ + +#### ๅ€ผ + +- `int major`๏ผšไธป็‰ˆๆœฌๅทใ€‚ +- `int minor`๏ผšๆฌก็‰ˆๆœฌๅทใ€‚ +- `int patch`๏ผšไฟฎ่ฎข็‰ˆๆœฌๅทใ€‚ + +### `reiconv_version` + +#### ๆ่ฟฐ + +่ฟ™ๆ˜ฏไธ€ไธชๆ่ฟฐๅฝ“ๅ‰ๅบ“็‰ˆๆœฌไฟกๆฏ็š„ๅ˜้‡ใ€‚ + +#### ็คบไพ‹ + +```c +printf("cppp-reiconv ็‰ˆๆœฌ: %d.%d.%d\n", reiconv_version.major, reiconv_version.minor, reiconv_version.patch); +``` + +## ็ผ–็ ๅ็งฐ API + +### `reiconv_name_canonicalize()` + +#### ๅฎšไน‰ + +```c +extern _CPPP_API size_t reiconv_name_canonicalize(const char *name, char *outbuf); +``` + +#### ๆ่ฟฐ + +็ปŸไธ€ๅŒ–็ผ–็ ๅ็งฐ. `canonical` ๆŒ‡็š„ๆ˜ฏ่ง„่Œƒๆˆๅ†…้ƒจ็š„ๆ ผๅผ๏ผŒไธๆ˜ฏ IANA ็š„ๆ ผๅผใ€‚ +ๆˆ‘ไปฌไผšๅฟฝ็•ฅ '-' ๅ’Œ '_'๏ผŒๅนถๅฐ†ๆ‰€ๆœ‰ๅญ—็ฌฆ่ฝฌๆขไธบๅคงๅ†™ใ€‚ + +ๅฝ“ `name` ๆˆ– `outbuf` ไธบ `nullptr` ๆ—ถ๏ผŒไผšๅ‘็”Ÿๆฎต้”™่ฏฏใ€‚ๆˆ‘ไปฌไธไผšๆฃ€ๆŸฅ `outbuf` ็š„้•ฟๅบฆใ€‚ + +**่ฟ™ๆ˜ฏไธ€ไธชไธๆŽจ่ไฝฟ็”จ็š„ๅ‡ฝๆ•ฐใ€‚** + +#### ๅ‚ๆ•ฐ + +- `name`๏ผš้œ€่ฆ็ปŸไธ€ๅŒ–็š„็ผ–็ ๅ็งฐใ€‚ +- `outbuf`๏ผš็”จไบŽๅญ˜ๅ‚จ็ปŸไธ€ๅŒ–ๅŽ็š„็ผ–็ ๅ็งฐ็š„็ผ“ๅ†ฒๅŒบใ€‚ๅฟ…้กปๅˆ†้…่ถณๅคŸ็š„็ฉบ้—ดใ€‚ + +#### ่ฟ”ๅ›žๅ€ผ + +็ปŸไธ€ๅŒ–ๅŽ็š„็ผ–็ ๅ็งฐ็š„้•ฟๅบฆใ€‚ + +#### ็คบไพ‹ + +```c +const char* name = "UCS-4" +char outbuf[256]; +size_t outbuf_size = reiconv_name_canonicalize(name, outbuf); +// outbuf_size == 4, outbuf == "UCS4" +``` + +### `reiconv_lookup_from_name()` + +#### ๅฎšไน‰ + +```c +extern _CPPP_API int reiconv_lookup_from_name(const char *encoding); +``` + +#### ๆ่ฟฐ + +้€š่ฟ‡็ผ–็ ๅ็งฐๆŸฅๆ‰พ็ผ–็ ใ€‚ + +#### ๅ‚ๆ•ฐ + +- `encoding`๏ผš็ผ–็ ๅ็งฐใ€‚ๅคงๅฐๅ†™ไธๆ•ๆ„Ÿใ€‚ +**ๅฟ…้กปๆ˜ฏๆœ‰ๆ•ˆ็š„ๆŒ‡้’ˆ๏ผŒๅฆๅˆ™ไผšๅฏผ่‡ดๆœชๅฎšไน‰่กŒไธบใ€‚** + +#### ่ฟ”ๅ›žๅ€ผ + +่ฟ”ๅ›ž็ผ–็ ็ดขๅผ•ใ€‚ๆœชๆ‰พๅˆฐๅˆ™่ฟ”ๅ›ž `-1`ใ€‚ + +`encoding index` ๆ˜ฏ cppp-reiconv ๅ†…้ƒจ็š„ๅ”ฏไธ€ IDใ€‚ๅœจ `reiconv_open()` ๅ‡ฝๆ•ฐไธญไฝฟ็”จใ€‚ + +#### ็คบไพ‹ + +```c +int encoding_index = reiconv_lookup_from_name("UTF-8"); +``` + +### `reiconv_lookup_from_codepage()` + +#### ๅฎšไน‰ + +```c +extern _CPPP_API int reiconv_lookup_from_codepage(int codepage); +``` + +#### ๆ่ฟฐ + +้€š่ฟ‡ไปฃ็ ้กตๆŸฅๆ‰พไธ€ไธช็ผ–็ ใ€‚ + +#### ๅ‚ๆ•ฐ + +- `codepage`๏ผšไปฃ็ ้กตใ€‚ + +#### ่ฟ”ๅ›žๅ€ผ + +่ฟ”ๅ›žไปฃ็ ้กต็ดขๅผ•๏ผŒๆœชๆ‰พๅˆฐๅˆ™่ฟ”ๅ›ž `-1`ใ€‚ + +#### ็คบไพ‹ + +```c +// ไธŽ reiconv_lookup_from_name("CP936") ็›ธๅŒ +int encoding_index = reiconv_lookup_from_codepage(936); +``` + +## ็ผ–็ ่ฝฌๆข API + +### `reiconv_t` + +#### ๅฎšไน‰ + +```c +typedef void* reiconv_t; +``` + +#### ๆ่ฟฐ + +่ฟ™ๆ˜ฏไธ€ไธชๆŒ‡ๅ‘ๅ†…้ƒจ `conv_struct` ็š„ๆŒ‡้’ˆใ€‚ๅฐฝ็ฎก cppp-reiconv ๅŸบไบŽ GNU LIBICONV๏ผŒ +ไฝ†ๆˆ‘ไปฌ็š„ `conv_struct` ไบ’ไธๅ…ผๅฎนใ€‚ + +### `ConvertFlag` + +#### ๅฎšไน‰ + +```c +enum ConvertFlag +{ + REICONV_NO_FLAGS = 0, + REICONV_DISCARD_ILSEQ = 1, +}; +``` + +#### ๆ่ฟฐ + +่ฟ™ๆ˜ฏไธ€ไธชไฝๆŽฉ็ ๏ผŒ็”จไบŽ่กจๆ˜Ž่ฝฌๆขๆ ‡ๅฟ—ใ€‚ + +- `REICONV_NO_FLAGS`๏ผšๆ— ๆ ‡ๅฟ—ใ€‚้ป˜่ฎคไผ ๅ…ฅ่ฟ™ไธชใ€‚ +- `REICONV_DISCARD_ILSEQ`๏ผšไธขๅผƒ้žๆณ•ๅบๅˆ—ใ€‚ไธŽ iconv ็š„ `//IGNORE` ๆ ‡ๅฟ—็›ธๅŒใ€‚ + +### `reiconv_open_from_index()` + +#### ๅฎšไน‰ + +```c +extern _CPPP_API reiconv_t reiconv_open_from_index(int fromcode, int tocode, enum ConvertFlag flags); +``` + +#### ๆ่ฟฐ + +้€š่ฟ‡็ผ–็ ็ดขๅผ•ๆ‰“ๅผ€ไธ€ไธช่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚ +**็ดขๅผ•ๅฟ…้กปๆœ‰ๆ•ˆ๏ผŒๅฆๅˆ™่กŒไธบๆœชๅฎšไน‰ใ€‚** + +#### ๅ‚ๆ•ฐ + +- `fromcode`๏ผšๆบ็ผ–็ ็ดขๅผ•ใ€‚ +**ๆณจๆ„๏ผšreiconv ็š„ๆ่ฟฐ็ฌฆๆ‰“ๅผ€ๅ‡ฝๆ•ฐ็š„ๅ‚ๆ•ฐ้กบๅบๆ˜ฏๅ…ˆๆœ‰ `fromcode` ๅŽๆœ‰ `tocode`ใ€‚** +**ไฝ†ๆ˜ฏ iconv ๅ…ˆๆœ‰ `tocode` ๅŽๆœ‰ `fromcode`๏ผ** +- `tocode`๏ผš็›ฎๆ ‡็ผ–็ ็ดขๅผ•ใ€‚ๆˆ‘ไปฌๆŽจ่ไฝ ไฝฟ็”จ็ผ–็ ๆžšไธพ่€Œไธๆ˜ฏไปฃ็ ้กตใ€‚ +็ผ–็ ๆžšไธพๅฎšไน‰ๅœจ `cppp/encodings/reiconv.h`ใ€‚่ฟ™ๆ˜ฏ่‡ชๅŠจ็”Ÿๆˆ็š„ใ€‚ๅ‚่งไธ‹้ข็š„็คบไพ‹ใ€‚ +- `flags`๏ผš่ฝฌๆขๆ ‡ๅฟ—ใ€‚ +`flags` ๆ˜ฏไธ€ไธชไฝๆŽฉ็ ใ€‚ๅ‚่ง `ConvertFlag` ไบ†่งฃๆ›ดๅคšไฟกๆฏใ€‚ + +#### ่ฟ”ๅ›žๅ€ผ + +ๅฆ‚ๆžœ่ฝฌๆขๆ่ฟฐ็ฌฆๆ— ๆณ•ๅˆ›ๅปบ๏ผŒ่ฟ”ๅ›ž `(reiconv_t)(-1)`๏ผŒๅนถไธ”่ฎพ็ฝฎ errnoใ€‚ +่ฟ™ๅ’Œ iconv ็š„่ฟ”ๅ›žๅ€ผ็›ธๅŒใ€‚**ไธๆ˜ฏ NULL๏ผ** + + +่ฟ™ไธชๅ‡ฝๆ•ฐๅชไผšๅœจๅ†…ๅญ˜ๅˆ†้…ๅคฑ่ดฅๆ—ถๅ‡บ้”™ใ€‚ +**ๅฎƒไธไผšๆฃ€ๆŸฅ `fromcode` ๅ’Œ `tocode` ็š„ๆœ‰ๆ•ˆๆ€ง๏ผ** +**ไฝ ๅบ”่ฏฅๅชไผ ้€’็ผ–็ ๆžšไธพ็š„็ดขๅผ•๏ผ** + +#### ็คบไพ‹ + +```c +reiconv_t cd = reiconv_open_from_index( + ENCODING_UTF8, /* C API ไธญ็š„็ผ–็ ๆžšไธพ้กนๅ‡ไปฅ ENCODING_ ไธบๅ‰็ผ€ใ€‚ */ + ENCODING_GB18030, /* ๆŸฅ็œ‹ๅคดๆ–‡ไปถ่Žทๅ–่ฏฆ็ป†ไฟกๆฏใ€‚ */ + REICONV_DISCARD_ILSEQ /* ่ฟ™ไธชๆ ‡ๅฟ—ๆ„ๆ€ๆ˜ฏไธขๅผƒ้žๆณ•ๅบๅˆ—ใ€‚ */ +); +if (cd == (reiconv_t)(-1)) +{ + perror("reiconv_open_from_index"); +} +``` + +### `reiconv_open_from_codepage()` + +#### ๅฎšไน‰ + +```c +extern _CPPP_API reiconv_t reiconv_open_from_codepage(int fromcode, int tocode, enum ConvertFlag flags); +``` + +#### ๆ่ฟฐ + +้€š่ฟ‡ไปฃ็ ้กตๆ‰“ๅผ€ไธ€ไธช่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚่ฟ™ๆ˜ฏ `reiconv_lookup_from_codepage()` + `reiconv_open_from_index()` +็š„ๅฟซๆทๆ–นๅผใ€‚ +ๅ‚่ง `reiconv_open_from_index()` ไบ†่งฃๆ›ดๅคšๅ‚ๆ•ฐไฟกๆฏใ€‚ + +#### ๅ‚ๆ•ฐ + +- `fromcode`๏ผšๆบ็ผ–็ ็š„ไปฃ็ ้กตใ€‚ +- `tocode`๏ผš็›ฎๆ ‡็ผ–็ ็š„ไปฃ็ ้กตใ€‚ +- `flags`๏ผš่ฝฌๆขๆ ‡ๅฟ—ใ€‚ + +#### ่ฟ”ๅ›žๅ€ผ + +ๅฆ‚ๆžœ่ฝฌๆขๆ่ฟฐ็ฌฆๆ— ๆณ•ๅˆ›ๅปบ๏ผŒ่ฟ”ๅ›ž `(reiconv_t)(-1)`๏ผŒๅนถไธ”่ฎพ็ฝฎ errnoใ€‚ +ๆˆ‘ไปฌไผšๆฃ€ๆŸฅ `fromcode` ๅ’Œ `tocode` ็š„ๆœ‰ๆ•ˆๆ€งใ€‚ + +ไธ€ไบ›็ผ–็ ๅฏ่ƒฝๆฒกๆœ‰ไปฃ็ ้กตใ€‚ไฝ ๅบ”่ฏฅ้€š่ฟ‡็ดขๅผ•ๆˆ–ๅ็งฐๆฅๆ‰“ๅผ€ๅฎƒไปฌใ€‚ + +#### ็คบไพ‹ + +```c +reiconv_t cd = reiconv_open_from_codepage( + 65001, /* UTF-8 */ + 936, /* CP936 */ + REICONV_DISCARD_ILSEQ +); +if (cd == (reiconv_t)(-1)) +{ + perror("reiconv_open_from_codepage"); +} +``` + +CP936 ๅ’Œ GBK ๅฎž้™…ไธŠๆœ‰ไบ›ๅŒบๅˆซ. ๅ‚่ง `lib/converters/cp936.h`. + +`lib/converters/cp936.h` ไธญ็š„ๆณจ้‡Šๆ˜ฏ่ฟ™ๆ ท่ฏด็š„๏ผˆๆฅ่‡ช Bruno Haible๏ผ‰๏ผš + +> IANA ๅฐ† CP936 ไฝœไธบ GBK ็š„ๅˆซๅใ€‚ไฝ† GBK ๆ˜ฏๅฎ˜ๆ–น็š„ไธญๆ–‡่ง„่Œƒ๏ผŒ่€Œ CP936 ๅฎž้™…ไธŠๆ˜ฏ็”ฑๅพฎ่ฝฏ็ปดๆŠค็š„ใ€‚ +> ๅฝ“็„ถ๏ผŒ่‡ช 1999 ๅนดไปฅๆฅ๏ผŒๅพฎ่ฝฏๅฏน CP936 ่ฟ›่กŒไบ†ไฟฎๆ”นใ€‚ +> +> ไธŽ GBK ็š„ๅŒบๅˆซๅฆ‚ไธ‹๏ผš +> +> - ๅ•ไธชๅญ—็ฌฆ๏ผš +> +> | GBK | CP936 | +> | :----: | :----: | +> | 0x80 | 0x20AC # ๆฌงๅ…ƒ็ฌฆๅท | +> +> ไธ€ไบ› CP936 ็š„ๅ˜ไฝ“๏ผˆๅœจ JDKใ€Windows-2000ใ€ICU ไธญ๏ผ‰่ฟ˜ๆทปๅŠ ไบ†๏ผš +> +> - ็งๆœ‰ๅŒบๅŸŸๆ˜ ๅฐ„๏ผš +> +> | ไปฃ็  | Unicode | +> | :----: | :----: | +> | 0x{A1..A2}{40..7E,80..A0} | U+E4C6..U+E585 | +> | 0x{AA..AF,F8..FE}{A1..FE} | U+E000..U+E4C5 | +> +> ๆˆ‘ไปฌไนŸๆทปๅŠ ไบ†่ฟ™ไบ›ๆ˜ ๅฐ„๏ผŒๅ› ไธบๅฐฝ็ฎกๅฝ“็งๆœ‰ๅŒบๅŸŸ็š„ๅญ—็ฌฆ่ขซ็งปๅŠจๅˆฐๅฎ˜ๆ–น็š„ Unicode ็ ็‚นๆ—ถไผšๅ‡บ็Žฐๅ‘ๅŽๅ…ผๅฎนๆ€ง้—ฎ้ข˜๏ผŒไฝ†ๅฎƒไปฌๅœจๅฎž่ทตไธญๅฏนๆŸไบ›ไบบ้žๅธธๆœ‰็”จใ€‚ + +### `reiconv_open_from_name()` + +#### ๅฎšไน‰ + +```c +extern _CPPP_API reiconv_t reiconv_open_from_name(const char *fromcode, const char *tocode, enum ConvertFlag flags); +``` + +#### ๆ่ฟฐ + +้€š่ฟ‡็ผ–็ ๅ็งฐๆ‰“ๅผ€ไธ€ไธช่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚ +่ฟ™ๆ˜ฏ `reiconv_lookup_from_name()` + `reiconv_open_from_index()` ็š„ๅฟซๆทๆ–นๅผใ€‚ +ๅ‚่ง `reiconv_open_from_index()` ไบ†่งฃๆ›ดๅคšๅ‚ๆ•ฐไฟกๆฏใ€‚ + +#### ๅ‚ๆ•ฐ + +- `fromcode`๏ผšๆบ็ผ–็ ็š„ๅ็งฐใ€‚ๅช่ƒฝไผ ๅ…ฅ็ผ–็ ๅ็งฐ๏ผŒ**ไธๅ…่ฎธไผ ๅ…ฅ**`//IGNORE` or `//TRANSLIT` ็ญ‰ๆŽงๅˆถๅŽ็ผ€ใ€‚ +- `tocode`๏ผš็›ฎๆ ‡็ผ–็ ็š„ๅ็งฐใ€‚ +- `flags`๏ผš่ฝฌๆขๆ ‡ๅฟ—ใ€‚ + +#### ่ฟ”ๅ›žๅ€ผ + +ๅฆ‚ๆžœ่ฝฌๆขๆ่ฟฐ็ฌฆๆ— ๆณ•ๅˆ›ๅปบ๏ผŒ่ฟ”ๅ›ž `(reiconv_t)(-1)`๏ผŒๅนถไธ”่ฎพ็ฝฎ errnoใ€‚ +ๅฎƒไผšๆฃ€ๆŸฅ `fromcode` ๅ’Œ `tocode` ็š„ๆœ‰ๆ•ˆๆ€งใ€‚ + +#### ็คบไพ‹ + +```c +reiconv_t cd = reiconv_open_from_name( + "UTF-8", + "GB18030", + REICONV_NO_FLAGS +); +if (cd == (reiconv_t)(-1)) +{ + perror("reiconv_open_from_name"); +} +``` + +### `reiconv_result_size()` + +#### ๅฎšไน‰ + +```c +extern _CPPP_API size_t reiconv_result_size(reiconv_t cd, const char *start, size_t inlength); +``` + +#### ๆ่ฟฐ + +่Žทๅ–่ฝฌๆขๅŽ็š„ๅญ—็ฌฆไธฒๅคงๅฐใ€‚ + +#### ๅ‚ๆ•ฐ + +- `cd`๏ผš่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚ +- `start`๏ผš่พ“ๅ…ฅ็š„ๅญ—็ฌฆไธฒใ€‚ +- `inlength`๏ผš่พ“ๅ…ฅๅญ—็ฌฆไธฒ็š„้•ฟๅบฆใ€‚ + +#### ่ฟ”ๅ›žๅ€ผ + +่ฝฌๆขๅŽ็š„ๅญ—็ฌฆไธฒๅคงๅฐใ€‚ๅฆ‚ๆžœ่ฝฌๆขๅคฑ่ดฅ๏ผŒ่ฟ”ๅ›ž `(size_t)(-1)`ใ€‚ + +**็›ฎๅ‰่ฟ™ไธช API ไธๆ”ฏๆŒ่ฝฌๆขๆ ‡ๅฟ—ใ€‚ๆ‰€ไปฅ `flags` ๆฐธ่ฟœๆ˜ฏ `REICONV_NO_FLAGS`ใ€‚ๆˆ‘ไปฌไผšๅœจ** +**ไธ‹ไธ€ไธช็‰ˆๆœฌไธญๆ”ฏๆŒๅฎƒใ€‚ๆ‰€ไปฅ่ฟ™ไธช API ไผšๅœจไธ‹ไธ€ไธช็‰ˆๆœฌไธญๆ”นๅ˜ใ€‚** + +#### ็คบไพ‹ + +```c +const char input[] = "Hello, World!"; +size_t result_size = reiconv_result_size(cd, input, strlen(input)); + +if (result_size == (size_t)(-1)) +{ + perror("reiconv_result_size"); +} +``` + +### `reiconv_convert_static_size()` + +#### ๅฎšไน‰ + +```c +extern _CPPP_API int reiconv_convert_static_size(reiconv_t cd, const char *input_data, size_t input_length, + char *output_data, size_t output_length); +``` + +#### ๆ่ฟฐ + +็”จ่ฝฌๆขๆ่ฟฐ็ฌฆ `cd` ่ฝฌๆขไธ€ไธชๅญ—็ฌฆไธฒ๏ผŒไฝฟ็”จไธ€ไธช้™ๆ€ๅคงๅฐ็š„่พ“ๅ‡บ็ผ“ๅ†ฒๅŒบใ€‚ + +ๅฆ‚ๆžœ่พ“ๅ‡บ็ผ“ๅ†ฒๅŒบๅคชๅฐ๏ผŒ่ฟ”ๅ›ž `-1`ใ€‚ + +ๅฆ‚ๆžœ่พ“ๅ‡บ็ผ“ๅ†ฒๅŒบๅคชๅคง๏ผŒ่พ“ๅ‡บ็ผ“ๅ†ฒๅŒบ็š„ๅ…ถไฝ™้ƒจๅˆ†ไธไผšๆ”นๅ˜ใ€‚ + +ๅฝ“ไฝ ๆƒณ่ฆๅฐ†ไธ€ไธชๅญ—็ฌฆไธฒ่ฝฌๆขไธบไธ€ไธชๅ›บๅฎšๅคงๅฐ็š„็ผ“ๅ†ฒๅŒบ๏ผˆๆฏ”ๅฆ‚ๆ ˆ็ผ“ๅ†ฒๅŒบ๏ผ‰ๆ—ถ๏ผŒ่ฟ™ไธชๅ‡ฝๆ•ฐ้žๅธธๆœ‰็”จใ€‚ +ๅฎƒๆฏ” `reiconv_convert` ๅฟซใ€‚ + +#### ๅ‚ๆ•ฐ + +- `cd`๏ผš่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚ +- `input_data`๏ผš่พ“ๅ…ฅ็š„ๅญ—็ฌฆไธฒใ€‚ +- `input_length`๏ผš่พ“ๅ…ฅๅญ—็ฌฆไธฒ็š„้•ฟๅบฆใ€‚ +- `output_data`๏ผš่พ“ๅ‡บ็š„ๅญ—็ฌฆไธฒใ€‚ +- `output_length`๏ผš่พ“ๅ‡บๅญ—็ฌฆไธฒ็š„้•ฟๅบฆใ€‚ + +#### ่ฟ”ๅ›žๅ€ผ + +่ฝฌๆขๅŽ็š„ๅญ—็ฌฆไธฒ้•ฟๅบฆใ€‚ๅฆ‚ๆžœ่ฝฌๆขๅคฑ่ดฅ๏ผŒ่ฟ”ๅ›ž `(size_t)(-1)`ใ€‚ + +#### ็คบไพ‹ + +```c +const char input[] = "Hello, World!"; +char output[256]; +size_t result_size = reiconv_convert_static_size(cd, input, strlen(input), output, sizeof(output)); +if (result_size == (size_t)(-1)) +{ + perror("reiconv_convert_static_size"); +} +``` + +### `reiconv_convert()` + +#### ๅฎšไน‰ + +```c +extern _CPPP_API int reiconv_convert(reiconv_t cd, const char *input_data, size_t input_length, char **output_data_ptr, + size_t *output_length_ptr); +``` + +#### ๆ่ฟฐ + +ๆŠŠไธ€ๆฎตๆ–‡ๆœฌไปŽไธ€ไธช็ผ–็ ่ฝฌๆขๅˆฐๅฆไธ€ไธช็ผ–็ ใ€‚ + +่ฟ™ๆ˜ฏ cppp-reiconv ไธญๆœ€ๆ–นไพฟ็š„ๅ‡ฝๆ•ฐใ€‚ๅฎƒไผš่‡ชๅŠจ่ฎก็ฎ—่ฝฌๆขๅŽ็š„ๅญ—็ฌฆไธฒๅคงๅฐ๏ผŒๅนถไธ”ไธบไฝ ๅˆ†้…ๅ†…ๅญ˜ใ€‚ + +ไฝ†ๆ˜ฏ่ฎก็ฎ—่ฝฌๆขๅŽ็š„ๅญ—็ฌฆไธฒๅคงๅฐๆ€ปๆ˜ฏๅพˆๆ…ข็š„ใ€‚ๅฆ‚ๆžœไฝ ็Ÿฅ้“่ฝฌๆขๅŽ็š„ๅญ—็ฌฆไธฒๅคงๅฐ๏ผŒไฝ ๅบ”่ฏฅไฝฟ็”จ +`reiconv_convert_static_size()` ไปฃๆ›ฟใ€‚ + +ๆญคๅ‡ฝๆ•ฐไธไผš็‰นๆฎŠๅค„็†้›ถๅญ—็ฌฆใ€‚ + +Its code comes from `iconv_string()` in GNU LIBICONV's repository. + +ๅฎƒ็š„ไปฃ็ ๆฅ่‡ช GNU LIBICONV ไป“ๅบ“ไธญ็š„ `iconv_string()`ใ€‚ + +ๅ‚่ง + +Bruno Haible ๆŠŠ่ฟ™ไธชๆ–‡ไปถๆ”พๅˆฐไบ†ๅ…ฌๅ…ฑ้ข†ๅŸŸใ€‚`iconv_string.h` ไธๆ˜ฏ GNU LIBICONV ๅบ“็š„ไธ€้ƒจๅˆ†ใ€‚ + +#### ๅ‚ๆ•ฐ + +- `cd`๏ผš่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚ +- `input_data`๏ผš่พ“ๅ…ฅ็š„ๅญ—็ฌฆไธฒใ€‚ +- `input_length`๏ผš่พ“ๅ…ฅๅญ—็ฌฆไธฒ็š„้•ฟๅบฆใ€‚ +- `output_data_ptr`๏ผš่พ“ๅ‡บ็ผ“ๅ†ฒๅŒบ็š„ๆŒ‡้’ˆใ€‚ๅฆ‚ๆžœๅฎƒๆŒ‡ๅ‘ไธ€ไธช `NULL` ๆŒ‡้’ˆ๏ผŒๆˆ‘ไปฌไผšไธบไฝ ๅˆ†้…ๅ†…ๅญ˜, +ๅนถไธ”ๅฐ†ๅฎƒ่ฎพ็ฝฎไธบ็ป“ๆžœ็ผ“ๅ†ฒๅŒบใ€‚ๅฆ‚ๆžœๆŒ‡ๅ‘ๆŸไธชๆŒ‡้’ˆไฝ†ไธๆ˜ฏ `NULL`๏ผŒๆˆ‘ไปฌๅฐ†ไฝฟ็”จๅฎƒไฝœไธบ่พ“ๅ‡บ็ผ“ๅ†ฒๅŒบ๏ผŒ +ๅนถไธ”้‡ๆ–ฐๅˆ†้…ๅฎƒใ€‚ๆ‰€ไปฅๅฎƒๅฟ…้กปๆ˜ฏไธ€ไธชๅฏไปฅไฟฎๆ”น็š„ๆŒ‡้’ˆใ€‚ +**ไฝ†ๆ˜ฏไธ่ฆ่ฎฉ output_data_ptr ็š„ๅ€ผไธบ `NULL`๏ผ** +- `output_length_ptr`๏ผš่พ“ๅ‡บ็ผ“ๅ†ฒๅŒบ็š„้•ฟๅบฆใ€‚ๅฆ‚ๆžœไธบ `NULL`๏ผŒไผšๅ‘็”Ÿ้”™่ฏฏใ€‚ + +#### ่ฟ”ๅ›žๅ€ผ + +ๆˆ‘ไปฌๅชๅœจๆˆๅŠŸๆ—ถ่ฟ”ๅ›ž `0`ใ€‚ๅฆ‚ๆžœๅคฑ่ดฅ๏ผŒ่ฟ”ๅ›ž `-1` ๅนถ่ฎพ็ฝฎ errnoใ€‚ๆˆ‘ไปฌๅฐ†่พ“ๅ‡บ็ผ“ๅ†ฒๅŒบไฟๅญ˜ๅœจ +`output_data_ptr` ไธญใ€‚ + +**ๆณจๆ„๏ผš่ฏทๅœจไฝฟ็”จๅŽ้‡Šๆ”พ่พ“ๅ‡บ็ผ“ๅ†ฒๅŒบ๏ผๅฎƒๆ€ปๆ˜ฏๅŠจๆ€ๅˆ†้…็š„๏ผ** + +#### ็คบไพ‹ + +```c +const char input[] = "Hello, World!"; +char *output = NULL; /* NULL ๆ„ๅ‘ณ็€ๆˆ‘ไปฌไผšไธบไฝ ๅŠจๆ€ๅˆ†้…ๅ†…ๅญ˜ใ€‚ */ +size_t output_length = 0; +int result = reiconv_convert(cd, input, strlen(input), &output, &output_length); +if (result == -1) +{ + perror("reiconv_convert"); +} +printf("%zu: %s\n", output_length, output); +free(output); +``` + +```c +const char input[] = "Hello, World!"; +char* output = malloc(1); /* ๆˆ‘ไปฌไผš้‡ๅˆ†้…ๅฎƒใ€‚ */ +if (output == NULL) +{ + perror("malloc"); +} +size_t output_length = 0; +int result = reiconv_convert(cd, input, strlen(input), &output, &output_length); +if (result == -1) +{ + perror("reiconv_convert"); +} +printf("%zu: %s\n", output_length, output); +free(output); +``` + +### `reiconv_handle_close()` + +#### ๅฎšไน‰ + +```c +extern _CPPP_API int reiconv_handle_close(reiconv_t cd); +``` + +#### ๆ่ฟฐ + +ๅ…ณ้—ญไธ€ไธช่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚ + +#### ๅ‚ๆ•ฐ + +- `cd`๏ผš่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚ + +#### ่ฟ”ๅ›žๅ€ผ + +ๆˆ‘ไปฌๅœจๆˆๅŠŸๆ—ถ่ฟ”ๅ›ž `0`ใ€‚็Žฐๅœจๆˆ‘ไปฌๅช่ฟ”ๅ›ž `0`ใ€‚ๅ› ไธบๆˆ‘ไปฌๅช้œ€่ฆ้‡Šๆ”พ่ฝฌๆขๆ่ฟฐ็ฌฆ็š„ๅ†…ๅญ˜ใ€‚ + +#### ็คบไพ‹ + +```c +/* ่ฟ™่ฟ˜่ฆ็คบไพ‹๏ผŸ๏ผŸ๏ผŸ */ +reiconv_handle_close(cd); +``` + +## ๆœฌๅœฐ็ผ–็  API + +### `locale_charset()` + +#### ๅฎšไน‰ + +```c +extern _CPPP_API const char* locale_charset(); +``` + +#### ๆ่ฟฐ + +ๅˆคๆ–ญๅฝ“ๅ‰็š„ๆœฌๅœฐ็ผ–็ ใ€‚ไฝ†ๆ˜ฏๅ’Œ GNU LIBICONV ็š„ๅฎž็ŽฐไธๅŒ๏ผŒๆˆ‘ไปฌไธไผš็ปŸไธ€ๅŒ–็ผ–็ ๅ็งฐใ€‚ไฝ†ๆ˜ฏๅคงๅคšๆ•ฐ็š„็ป“ๆžœ +ๅฏไปฅๅœจ `reiconv_open_from_name()` ไธญไฝฟ็”จใ€‚้™คไบ†ไธ€ไบ›้žๅธธ็ฝ•่ง็š„็ผ–็ ๆˆ–ไธ€ไบ›ๆ—ง็š„ OSX ็‰ˆๆœฌไธญ็š„ไธ€ไบ› +็‰นๅฎš็š„็ผ–็ ใ€‚่ฟ™ไบ›็ผ–็ ๅœจ cppp-reiconv ๅ’Œ GNU LIBICONV ไธญ้ƒฝไธๆ”ฏๆŒใ€‚ + +#### ่ฟ”ๅ›žๅ€ผ + +ๅฝ“ๅ‰ๆœฌๅœฐ็ผ–็ ็š„ๅ็งฐใ€‚ + +#### ็คบไพ‹ + +```c +setlocale(LC_ALL, ""); +const char* charset = locale_charset(); +printf("ไฝ ็š„ๆœฌๅœฐ็ผ–็ ๆ˜ฏ๏ผš%s\n", charset); +``` + +## Iconv ๅ…ผๅฎน API + +**่ฟ™ไบ› API ไธๆŽจ่ๅœจ `cppp/reiconv.h` ไธญไฝฟ็”จใ€‚่ฏทๅœจ `iconv.h` ไธญไฝฟ็”จๅฎƒไปฌใ€‚** + +Iconv ๅ…ผๅฎนๆ€ง้ป˜่ฎคๆ˜ฏ็ฆ็”จ็š„ใ€‚ไฝ ๅฏไปฅๅœจ้…็ฝฎ cppp-reiconv ๆ—ถๅฎšไน‰ `-DICONV_COMPAT=ON` ๆฅๅฏ็”จๅฎƒใ€‚ + +### `iconv_t`๏ผŒๅณ `cppp/reiconv.h` ไธญ็š„ `reiconv_t` + +#### ๅฎšไน‰ + +```c +#define iconv_t reiconv_t +``` + +ๅ’ŒไธŠๆ–‡ `reiconv_t` ็›ธๅŒใ€‚ + +### `iconv_open`๏ผŒๅณ `cppp/reiconv.h` ไธญ็š„ `reiconv_open()` + +#### ๅฎšไน‰ + +ๅœจ `cppp/reiconv.h` ไธญ๏ผš + +```c +extern _CPPP_API reiconv_t reiconv_open(const char *tocode, const char *fromcode); +``` + +ๅœจ `iconv.h` ไธญ๏ผš + +```c +#define iconv_open reiconv_open +``` + +#### ๆ่ฟฐ + +ๆ‰“ๅผ€ไธ€ไธช่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚็”จไบŽ iconv ๅ…ผๅฎนๆ€งใ€‚ + +#### ๅ‚ๆ•ฐ + +- `tocode`๏ผš็›ฎๆ ‡็ผ–็ ็š„ๅ็งฐใ€‚**ๆณจๆ„๏ผšiconv ๅ…ผๅฎน API ็š„ๅ‚ๆ•ฐ้กบๅบๆ˜ฏๅ…ˆ `fromcode` ๅŽ `tocode`๏ผ** +- `fromcode`๏ผšๆบ็ผ–็ ็š„ๅ็งฐใ€‚ๆˆ‘ไปฌ็Žฐๅœจๆ”ฏๆŒ `//IGNORE`ใ€‚ + +#### ่ฟ”ๅ›žๅ€ผ + +่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚ๅฆ‚ๆžœๅ‡บ้”™๏ผŒ่ฟ”ๅ›ž `(reiconv_t)(-1)`๏ผŒๅนถไธ”่ฎพ็ฝฎ errnoใ€‚ + +### `iconv`๏ผŒๅณ `cppp/reiconv.h` ไธญ็š„ `reiconv_iconv()` + +#### ๅฎšไน‰ + +ๅœจ `cppp/reiconv.h` ไธญ๏ผš + +```c +extern _CPPP_API size_t reiconv_iconv(reiconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, + size_t *outbytesleft); +``` + +ๅœจ `iconv.h` ไธญ๏ผš + +```c +#define iconv reiconv_iconv +``` + +#### ๆ่ฟฐ + +ๆ‰ง่กŒ่ฝฌๆขใ€‚็”จไบŽ iconv ๅ…ผๅฎนๆ€งใ€‚ + +ๅ‚่ง `man 3 iconv`ใ€‚ + +#### ๅ‚ๆ•ฐ + +- `cd`๏ผš่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚ +- `inbuf`๏ผš่พ“ๅ…ฅ็ผ“ๅ†ฒๅŒบใ€‚ +- `inbytesleft`๏ผš่พ“ๅ…ฅ็ผ“ๅ†ฒๅŒบ็š„้•ฟๅบฆใ€‚ +- `outbuf`๏ผš่พ“ๅ‡บ็ผ“ๅ†ฒๅŒบใ€‚ +- `outbytesleft`๏ผš่พ“ๅ‡บ็ผ“ๅ†ฒๅŒบ็š„้•ฟๅบฆใ€‚ + +#### ่ฟ”ๅ›žๅ€ผ + +่ฝฌๆขๅŽ็š„ๅญ—็ฌฆไธฒ้•ฟๅบฆใ€‚ + +### `iconv_close`๏ผŒๅณ `cppp/reiconv.h` ไธญ็š„ `reiconv_handle_close()` + +#### ๅฎšไน‰ + +ๅœจ `iconv.h` ไธญ๏ผš + +```c +#define iconv_close reiconv_handle_close +``` + +ไธŽไธŠๆ–‡ `reiconv_handle_close()` ็›ธๅŒใ€‚ diff --git a/docs/zh_CN/cpp-api.md b/docs/zh_CN/cpp-api.md new file mode 100644 index 00000000..b3a95029 --- /dev/null +++ b/docs/zh_CN/cpp-api.md @@ -0,0 +1,234 @@ +# cppp-reiconv C++ API + +C++ API ไนŸ่ฎธๆฏ” C API ๆ…ขไธ€ไบ›ใ€‚ไฝ†ๅฎƒๆ›ดๆ–นไพฟใ€‚ + +## ็‰ˆๆœฌไฟกๆฏ API + +### `struct VersionInfo` + +#### ๆ่ฟฐ + +็ป“ๆž„ๅŒ…ๅซ็‰ˆๆœฌไฟกๆฏใ€‚ + +#### ๅ€ผ + +- `int major`๏ผšไธป็‰ˆๆœฌใ€‚ +- `int minor`๏ผšๆฌก็‰ˆๆœฌใ€‚ +- `int patch`๏ผšไฟฎ่ฎข็‰ˆๆœฌใ€‚ + +### `reiconv::version` + +#### ๆ่ฟฐ + +่ฟ™ๆ˜ฏไธ€ไธชๆ่ฟฐๅฝ“ๅ‰ๅบ“็‰ˆๆœฌไฟกๆฏ็š„ๅ˜้‡ใ€‚ + +#### ็คบไพ‹ + +```cpp +std::cout << "cppp-reiconv ็‰ˆๆœฌ๏ผš" << reiconv::version.major << "." + << reiconv::version.minor << "." << reiconv::version.patch << std::endl; +``` + +## ็ผ–็ ่ฝฌๆข API + +### `class reiconv::Encoding` + +็ผ–็ ็ฑปๅฐ่ฃ…ไบ†็ผ–็ ๆŸฅๆ‰พๅ‡ฝๆ•ฐใ€‚ + +ๅฎƒๅฏไปฅ่ฝฌๆขไธบไธ€ไธช int ๅ€ผ๏ผŒ็ญ‰ไบŽๅ†…้ƒจ็š„็ผ–็  idใ€‚ + +#### ไปŽ็ผ–็ ๅ็งฐๆž„้€  + +ไปŽ็ผ–็ ๅ็งฐๆž„้€ ็ผ–็ ๅฏน่ฑกใ€‚ + +##### ๅฎšไน‰ + +```cpp +public: +_CPPP_API Encoding(const char* const name); +_CPPP_API Encoding(const std::string& name); +``` + +##### ๅ‚ๆ•ฐ + +- `name`๏ผš็ผ–็ ๅ็งฐ. ไธๅ…่ฎธ `//` ๅŽ็ผ€ใ€‚ + +##### ่ฟ”ๅ›ž + +- `Encoding`๏ผš็ผ–็ ๅฏน่ฑกใ€‚ + +##### ๅผ‚ๅธธ + +- `std::invalid_argument`๏ผšๅฆ‚ๆžœ็ผ–็ ๅ็งฐๆ— ๆ•ˆใ€‚ + +#### ไปŽไปฃ็ ้กตๆž„้€  + +ไปŽไปฃ็ ้กตๆž„้€ ็ผ–็ ๅฏน่ฑกใ€‚ + +##### ๅฎšไน‰ + +```cpp +public: +_CPPP_API Encoding(const int codepage); +``` + +##### ๅ‚ๆ•ฐ + +- `codepage`๏ผšไปฃ็ ้กตใ€‚่ฟ™ไธ่ƒฝๆ‰“ๅผ€ไธ€ไธชๆฒกๆœ‰ไปฃ็ ้กต็š„็ผ–็ ใ€‚ + +##### ่ฟ”ๅ›ž + +- `Encoding`๏ผš็ผ–็ ๅฏน่ฑกใ€‚ + +##### ๅผ‚ๅธธ + +- `std::invalid_argument`๏ผšๅฆ‚ๆžœไปฃ็ ้กตๆ— ๆ•ˆใ€‚ + +#### ไปŽ็ผ–็  id ๆž„้€  + +##### ๅฎšไน‰ + +```cpp +public: +constexpr Encoding(const Encodings index); +``` + +##### ๅ‚ๆ•ฐ + +- `index`๏ผš็ผ–็  idใ€‚ๅฏ็”จ็š„็ผ–็  id ๅฎšไน‰ๅœจๆžšไธพ็ฑป `reiconv::Encodings` ไธญใ€‚ + +##### ่ฟ”ๅ›ž + +- `Encoding`๏ผš็ผ–็ ๅฏน่ฑกใ€‚ + +##### ๅผ‚ๅธธ + +ๆ— ๅผ‚ๅธธ๏ผŒ**ไฝ†ๆˆ‘ไปฌไธไผšๆฃ€ๆŸฅ็ผ–็  id ๆ˜ฏๅฆๆœ‰ๆ•ˆใ€‚ๆ‰€ไปฅ่ฏทไปŽ `reiconv::Encodings` ไผ ้€’ไธ€ไธชๆœ‰ๆ•ˆ็š„็ผ–็  idใ€‚** +**ๅฆๅˆ™๏ผŒๅฐ†ๅ‘็”Ÿๆœชๅฎšไน‰่กŒไธบใ€‚** + +#### ่ฝฌๆขๅˆฐ int + +##### ๅฎšไน‰ + +```cpp +public: +operator int() const noexcept; +``` + +##### ่ฟ”ๅ›ž + +- `int`๏ผš็ผ–็  idใ€‚ + +#### ๆฏ”่พƒ + +##### ๅฎšไน‰ + +```cpp +public: +bool operator==(const Encoding other) const noexcept; +``` + +##### ๅ‚ๆ•ฐ + +- `other`๏ผšๅฆไธ€ไธช็ผ–็ ๅฏน่ฑกใ€‚ + +##### ่ฟ”ๅ›ž + +- `bool`๏ผšๅฆ‚ๆžœไธคไธช็ผ–็ ๅฏน่ฑก็›ธ็ญ‰๏ผŒๅˆ™่ฟ”ๅ›ž true๏ผŒๅˆ™ๅฎƒไปฌๅ…ทๆœ‰็›ธๅŒ็š„็ผ–็  idใ€‚ + +#### ็คบไพ‹ + +```cpp +reiconv::Encoding gb18030(reiconv::Encodings::GB18030); // ไปŽ็ผ–็  id ๆž„้€  +reiconv::Encoding cp936(936); // ไปŽไปฃ็ ้กตๆž„้€  +reiconv::Encoding cp936_2("cp936"); // ไปŽ็ผ–็ ๅ็งฐๆž„้€  +reiconv::Encoding utf8("UTF-8"); + +std::cout << "(int)gb18030: " << (int)gb18030 << std::endl; +std::cout << "cp936 == cp936_2: " << (cp936 == cp936_2) << std::endl; // ็œŸ +std::cout << "cp936 == utf8: " << (cp936 == utf8) << std::endl; // ๅ‡ +``` + +### `enum class reiconv::ConvertFlag` + +#### ๅฎšไน‰ + +```c +enum class ConvertFlag +{ + NO_FLAGS = 0, + DISCARD_ILSEQ = 1, +}; +``` + +#### ๆ่ฟฐ + +่ฟ™ๆ˜ฏไธ€ไธช่ฝฌๆขๆ ‡ๅฟ—็š„ไฝๆŽฉ็ ใ€‚ + +- `NO_FLAGS`๏ผšๆ— ๆ ‡ๅฟ—ใ€‚่ฟ™ๆ˜ฏ้ป˜่ฎคๅ€ผใ€‚ +- `DISCARD_ILSEQ`๏ผšไธขๅผƒ้žๆณ•ๅบๅˆ—ใ€‚ไธŽ iconv ็š„ `//IGNORE` ๆ ‡ๅฟ—็›ธๅŒใ€‚ + +ไฝฟ็”จ `|` ๆฅ็ป„ๅˆๆ ‡ๅฟ—ใ€‚ๅœจ `reiconv::convert` ๅ‡ฝๆ•ฐไธญไฝฟ็”จใ€‚ + +### `reiconv::convert()` + +#### ๅฎšไน‰ + +```cpp +extern _CPPP_API std::string convert(Encoding from, Encoding to, const std::string_view input, enum ConvertFlag flag = ConvertFlag::NO_FLAGS); +``` + +#### ๆ่ฟฐ + +ไปŽไธ€ไธช็ผ–็ ่ฝฌๆขไธบๅฆไธ€ไธช็ผ–็ ใ€‚ๅฎƒไผš่‡ชๅŠจ็ป™่พ“ๅ‡บๅญ—็ฌฆไธฒๅˆ†้…ๅ†…ๅญ˜ใ€‚ + +#### ๅ‚ๆ•ฐ + +- `from`๏ผšๆบ็ผ–็ ใ€‚ +- `to`๏ผš็›ฎๆ ‡็ผ–็ ใ€‚ +- `input`๏ผš่พ“ๅ…ฅๅญ—็ฌฆไธฒใ€‚ +- `flag`๏ผš่ฝฌๆขๆ ‡ๅฟ—ใ€‚้ป˜่ฎคๅ€ผไธบ `ConvertFlag::NO_FLAGS`ใ€‚ + +#### ่ฟ”ๅ›ž + +- `std::string`๏ผš่ฝฌๆขๅŽ็š„ๅญ—็ฌฆไธฒใ€‚ + +#### ๅผ‚ๅธธ + +- `std::system_error`๏ผšๅฆ‚ๆžœ่ฝฌๆขๅคฑ่ดฅใ€‚็”จๅฎƒๅ› ไธบๅฎƒๆœ‰ errno ่ฎพ็ฝฎใ€‚ + +#### ็คบไพ‹ + +```cpp +const std::string_view src = "\xb8\xfc\xcf\xb2\xe1\xba\xc9\xbd\xc7\xa7\xc0\xef\xd1\xa9\xa3\xac\xc8\xfd\xbe\xfc\xb9\xfd\xba\xf3\xbe\xa1\xbf\xaa\xd1\xd5\xa3\xa1"; +std::string result = reiconv::convert(reiconv::Encodings::GB18030, "UTF-8", src); +std::cout << result << std::endl; +``` + +## ๆœฌๅœฐ็ผ–็  API + +### `reiconv::locale_charset()` + +#### ๅฎšไน‰ + +```c +extern _CPPP_API std::string_view locale_charset(); +``` + +#### ๆ่ฟฐ + +ๅˆคๆ–ญๅฝ“ๅ‰็š„ๆœฌๅœฐ็ผ–็ ใ€‚ไฝ†ๆ˜ฏๅ’Œ GNU LIBICONV ็š„ๅฎž็ŽฐไธๅŒ๏ผŒๆˆ‘ไปฌไธไผš็ปŸไธ€ๅŒ–็ผ–็ ๅ็งฐใ€‚ไฝ†ๆ˜ฏๅคงๅคšๆ•ฐ็š„็ป“ๆžœ +ๅฏไปฅๅœจ `reiconv_open_from_name()` ไธญไฝฟ็”จใ€‚้™คไบ†ไธ€ไบ›้žๅธธ็ฝ•่ง็š„็ผ–็ ๆˆ–ไธ€ไบ›ๆ—ง็š„ OSX ็‰ˆๆœฌไธญ็š„ไธ€ไบ› +็‰นๅฎš็š„็ผ–็ ใ€‚่ฟ™ไบ›็ผ–็ ๅœจ cppp-reiconv ๅ’Œ GNU LIBICONV ไธญ้ƒฝไธๆ”ฏๆŒใ€‚ + +#### ่ฟ”ๅ›ž + +ๅฝ“ๅ‰ๆœฌๅœฐ็ผ–็ ็š„ๅ็งฐใ€‚ + +#### ็คบไพ‹ + +```cpp +std::setlocale(LC_ALL, ""); +std::string_view charset = reiconv::locale_charset(); +std::cout <<"Your locale charset is: " << charset << std::endl; +``` diff --git a/include/cppp/encodings/reiconv.h.in b/include/cppp/encodings/reiconv.h.in new file mode 100644 index 00000000..b58b8122 --- /dev/null +++ b/include/cppp/encodings/reiconv.h.in @@ -0,0 +1,35 @@ +/** + * @file cppp/encodings/reiconv.h + * @author ChenPi11 + * @brief cppp-reiconv encodings list. + * @version 3.0.0 + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#pragma once +#ifndef _CPPP_ENCODINGS_REICONV_H_ +#define _CPPP_ENCODINGS_REICONV_H_ + +#if _MSC_VER >= 1600 +#pragma execution_character_set("utf-8") +#endif /* _MSC_VER >= 1600 */ + +@INDEXES_CODE@ +#endif /* _CPPP_ENCODINGS_REICONV_H_ */ diff --git a/include/cppp/encodings/reiconv.hpp.in b/include/cppp/encodings/reiconv.hpp.in new file mode 100644 index 00000000..6e71cea2 --- /dev/null +++ b/include/cppp/encodings/reiconv.hpp.in @@ -0,0 +1,35 @@ +/** + * @file cppp/encodings/reiconv.hpp + * @author ChenPi11 + * @brief cppp-reiconv encodings list. + * @version 3.0.0 + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#pragma once +#ifndef _CPPP_ENCODINGS_REICONV_HPP_ +#define _CPPP_ENCODINGS_REICONV_HPP_ + +#if _MSC_VER >= 1600 +#pragma execution_character_set("utf-8") +#endif // _MSC_VER >= 1600 + +@INDEXES_CODE@ +#endif // _CPPP_ENCODINGS_REICONV_HPP_ diff --git a/include/cppp/reiconv.h.in b/include/cppp/reiconv.h.in new file mode 100644 index 00000000..920fcaf1 --- /dev/null +++ b/include/cppp/reiconv.h.in @@ -0,0 +1,236 @@ +/** + * @file cppp/reiconv.h + * @author ChenPi11 + * @brief reiconv C API. + * @version 3.0.0 + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#pragma once +#ifndef _CPPP_REICONV_H_ +#define _CPPP_REICONV_H_ + +#include "encodings/reiconv.h" + +#include + +#ifndef _CPPP_API +#define _CPPP_API @CPPP_API@ +#endif /* _CPPP_API */ + +#if _MSC_VER >= 1600 +#pragma execution_character_set("utf-8") +#endif /* _MSC_VER >= 1600 */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** + * @brief Version information. + */ +struct VersionInfo +{ + /** + * @brief Major version. + */ + int major; + + /** + * @brief Minor version. + */ + int minor; + + /** + * @brief Patch version. + */ + int patch; +}; + +/** + * @brief Version infomation. + */ +extern _CPPP_API struct VersionInfo reiconv_version; + +/** + * @brief Canonicalize an encoding name. + * @note We will ignore '-' and '_', and uppercase all characters. + * @param name The encoding name. + * @param outbuf The output buffer. Must allocated with enough space. + * @return The length of the canonicalized name. + */ +extern _CPPP_API size_t reiconv_name_canonicalize(const char *name, char *outbuf); + +/** + * @brief Lookup an encoding by it's name. + * @note The return value is an encoding index that can be used with `reiconv_open_from_index`. + * @note We will ignore '-' and '_', and uppercase all characters. + * @param encoding The encoding name. + * @return The encoding index. If the it is not found, -1 is returned. + */ +extern _CPPP_API int reiconv_lookup_from_name(const char *encoding); + +/** + * @brief Lookup an encoding by it's codepage. + * @note The return value is an encoding index that can be used with `reiconv_open_from_index`. + * @param codepage The codepage. + * @return The encoding index. If the it is not found, -1 is returned. + */ +extern _CPPP_API int reiconv_lookup_from_codepage(int codepage); + +/** + * @brief Conversion descriptor. + */ +typedef void *reiconv_t; + +/** + * @brief Convert flags. Used for open conversion descriptor. + */ +enum ConvertFlag +{ + /** + * @brief No flags. + */ + REICONV_NO_FLAGS = 0, + + /** + * @brief Discard illegal sequences. Same as iconv(3) '//IGNORE'. + */ + REICONV_DISCARD_ILSEQ = 1, +}; + +/** + * @brief Open a conversion descriptor from encoding index. + * @note The return value is a conversion descriptor. + * @param fromcode The input buffer encoding's index. + * @param tocode The output buffer encoding's index. + * @param flags The convert flags. + * @return The conversion descriptor. Indexes MUST BE VALID or the behavior is undefined. + * @note If the conversion descriptor cannot be created, returns (reiconv_t)(-1) and errno is set to ENOMEM. + */ +extern _CPPP_API reiconv_t reiconv_open_from_index(int fromcode, int tocode, enum ConvertFlag flags); + +/** + * @brief Open a conversion descriptor from codepage. + * @note The return value is a conversion descriptor. + * @param fromcode The input buffer encoding's codepage. + * @param tocode The output buffer encoding's codepage. + * @param flags The convert flags. + * @return The conversion descriptor. (reiconv_t)(-1) is returned if error occured with errno set. + */ +extern _CPPP_API reiconv_t reiconv_open_from_codepage(int fromcode, int tocode, enum ConvertFlag flags); + +/** + * @brief Open a conversion descriptor from encoding name. + * @note The return value is a conversion descriptor. + * @param fromcode The input buffer encoding's name. + * @param tocode The output buffer encoding's name. + * @param flags The convert flags. + * @return The conversion descriptor. (reiconv_t)(-1) is returned if error occured with errno set. + */ +extern _CPPP_API reiconv_t reiconv_open_from_name(const char *fromcode, const char *tocode, enum ConvertFlag flags); + +/** + * @brief Get the size of the result. -1 on error with errno set. + * @note This function does not treat zero characters specially. + * @param start The input buffer. + * @param inlength The input buffer length. + * @return The size of the result. + */ +extern _CPPP_API size_t reiconv_result_size(reiconv_t cd, const char *start, size_t inlength); + +/** + * @brief Converts a string using conversion descriptor `cd`, with a static size output buffer. + * @note The function `reiconv_convert` is more easy to use. This function is for performance and flexibility. + * @note This function does not treat zero characters specially. + * @param cd The input conversion descriptor. + * @param input_data The input buffer. + * @param input_length Input buffer length. + * @param output_data The output buffer pointer. + * @param output_length The output buffer's length. + * @note If the output buffer is too small, -1 is returned. + * @note If the output buffer is too big, the rest of the buffer will not change. + * @return 0 on success, -1 on error with errno set. + */ +extern _CPPP_API int reiconv_convert_static_size(reiconv_t cd, const char *input_data, size_t input_length, + char *output_data, size_t output_length); + +/** + * @brief Converts an string from one encoding to another. + * @note Converts a string using conversion descriptor `cd`. + * @note `malloc`/`realloc` is used to allocate the result. + * @note This function does not treat zero characters specially. + * @param cd The input conversion descriptor. + * @param input_data Input buffer. + * @param input_length Input buffer length. + * @param output_data_ptr Output buffer pointer's pointer. If NULL, error will be occured. + * @note If `*output_data_ptr` is NULL, `malloc` is used to allocate the result. if not, `realloc` is used. + * @param output_length_ptr Output buffer length pointer. If NULL, error will be occured. + * @note The length of the result is stored in `*output_length_ptr`. + * @return 0 on success, -1 on error with errno set. + */ +extern _CPPP_API int reiconv_convert(reiconv_t cd, const char *input_data, size_t input_length, char **output_data_ptr, + size_t *output_length_ptr); + +/** + * @brief Open a conversion descriptor. For iconv compatibility. + * @param tocode The output buffer encoding. Supports "//IGNORE". + * @param fromcode The input buffer encoding. + * @return The conversion descriptor. (reiconv_t)(-1) is returned if error occured with errno set. + */ +extern _CPPP_API reiconv_t reiconv_open(const char *tocode, const char *fromcode); + +/** + * @brief Do conversion. For iconv compatibility. + * @note At most `*inbytesleft` bytes starting at `*inbuf`. + * @note Writing at most `*outbytesleft` bytes starting at `*outbuf`. + * @note Decrements `*inbytesleft` and increments `*inbuf` by the same amount. + * @note Decrements `*outbytesleft` and increments `*outbuf` by the same amount. + * @param cd The conversion descriptor. + * @param inbuf The input buffer. + * @param inbytesleft The input buffer length. + * @param outbuf The output buffer. + * @param outbytesleft The output buffer length. + * @return The number of bytes written to the output buffer. (size_t)(-1) is returned if error occured + * with errno set. + */ +extern _CPPP_API size_t reiconv_iconv(reiconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, + size_t *outbytesleft); + +/** + * @brief Close a conversion descriptor. For iconv compatibility. + * @param cd The conversion descriptor. + * @return 0 on success. Returns 0 every time. + */ +extern _CPPP_API int reiconv_handle_close(reiconv_t cd); + +/** + * @brief Determine the current locale's character encoding. + * @note The result is statically allocated. + * @return The encoding name. + */ +extern _CPPP_API const char *locale_charset(); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _CPPP_REICONV_H_ */ diff --git a/include/cppp/reiconv.hpp.in b/include/cppp/reiconv.hpp.in index caf4e176..bfcf969a 100644 --- a/include/cppp/reiconv.hpp.in +++ b/include/cppp/reiconv.hpp.in @@ -1,320 +1,164 @@ /** * @file cppp/reiconv.hpp * @author ChenPi11 - * @brief C++ Plus cppp-reiconv package. - * @version 2.1.0 - * @date 2023-7-28 - * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @brief reiconv C++ API. + * @version 3.0.0 + * @copyright Copyright (C) 2023-2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . */ -/* Copyright (C) 1999-2023 Free Software Foundation, Inc. - This file is part of the cppp-reiconv library. - - The cppp-reiconv library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 3 - of the License, or (at your option) any later version. - The cppp-reiconv library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. +#pragma once +#ifndef _CPPP_REICONV_HPP_ +#define _CPPP_REICONV_HPP_ - You should have received a copy of the GNU Lesser General Public - License along with the cppp-reiconv library; see the file COPYING. - If not, see . */ +#include "encodings/reiconv.hpp" -/* When installed, this file is called "cppp/reiconv.hpp". */ +#include +#include +#include -#ifndef _CPPP_REICONV_HPP -#define _CPPP_REICONV_HPP +#ifndef _CPPP_API +#define _CPPP_API @CPPP_API@ +#endif -#if _MSC_VER >= 1600 -/* Use UTF-8 to decode this file. */ +#if _MSC_VER >= 1600 #pragma execution_character_set("utf-8") #endif -#include -#include -#include -#include -#include -#include - -extern "C++" +namespace reiconv { - namespace cppp - { - namespace base - { - namespace reiconv - { - /** - * @brief Version infomation. (major<<8) + minor - */ - extern @DLL_VARIABLE@ int reiconv_version; - -#undef iconv_t - /** - * @typedef void* - * @brief Identifier for conversion method from one codeset to another. - */ - typedef void *iconv_t; - -#undef iconv_open - /** - * @brief Allocates descriptor for code conversion from encoding 'fromcode' to encoding 'tocode'. - * @param tocode Target encoding. - * @param fromcode From encoding. - * @return Allocated iconv conversation buffer's pointer. - */ - extern @DLL_VARIABLE@ iconv_t iconv_open(const char *tocode, const char *fromcode); - - /** - * @brief Allocates descriptor for code conversion from codepage 'tocode_cp' to codepage 'fromcode_cp'. - * @param tocode_cp Target codepage. - * @param fromcode_cp From codepage. - * @param strict Strict mode, if false, will ignore the invalid characters. - * @note Some encoding may don't have codepage. - * @return Allocated iconv conversation buffer's pointer. - */ - extern @DLL_VARIABLE@ iconv_t iconv_open(int tocode_cp, int fromcode_cp, bool strict = true); + using reiconv::encoding::Encodings; -#undef iconv /** - * @brief Converts, using conversion descriptor 'cd', at most '*inbytesleft' bytes starting at '*inbuf', writing at - * most '*outbytesleft' bytes starting at '*outbuf'. - * @attention Decrements '*inbytesleft' and increments '*inbuf' by the same amount. - * @attention Decrements '*outbytesleft' and increments '*outbuf' by the same amount. - * @param cd Conversion descriptor. - * @param inbuf Input buffer. - * @param inbytesleft Input bytes left. - * @param outbuf Output buffer. - * @param outbytesleft Output bytes left. - * @return Number of converted characters (excluding terminators, -1 means error). + * @brief Encoding. */ - extern @DLL_VARIABLE@ size_t iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, - size_t *outbytesleft); - -#undef iconv_close - /** - * @brief Frees resources allocated for conversion descriptor 'cd'. - * @param cd Conversion descriptor you want to close. - * @return Operation status. (-1 means error, 0 means success). - */ - extern @DLL_VARIABLE@ int iconv_close(iconv_t cd); - - /** - * @brief Control of attributes. - * @param cd Conversion descriptor. - * @param request Attribute request id. - * @param argument Attribute argument. - * @return Operation status (>=0 means success, <0 means error). - */ - extern @DLL_VARIABLE@ int iconvctl(iconv_t cd, int request, void *argument); - - /** - * @typedef void (*) (unsigned int, void*) - * @brief Hook performed after every successful conversion of a Unicode character. - */ - typedef void (*iconv_unicode_char_hook)(unsigned int uc, void *data); - - /** - * @brief Set of hooks. - */ - struct iconv_hooks + class Encoding { - iconv_unicode_char_hook uc_hook; - void *data; + private: + /** + * @brief Encoding index. This is the internal representation of the encoding. + */ + int _index; + + public: + /** + * @brief Find the encoding by name. IANA names are recommended. + * @throw std::invalid_argument if the encoding is not found. + */ + _CPPP_API Encoding(const char* const name); + + /** + * @brief Find the encoding by name. IANA names are recommended. + * @throw std::invalid_argument if the encoding is not found. + */ + _CPPP_API Encoding(const std::string& name) : Encoding(name.c_str()) {} + + /** + * @brief Find the encoding by codepage. Supports Windows and z/OS codepages. + * @throw std::invalid_argument if the encoding is not found. + */ + _CPPP_API Encoding(const int codepage); + + /** + * @brief Find the encoding by index. + * @throw std::invalid_argument if the encoding is not found. + */ + constexpr Encoding(const Encodings index) : _index(static_cast(index)) {} + + /** + * @brief Get the encoding index. + */ + operator int() const noexcept { return _index; } + + /** + * @brief Get the encoding name. + */ + bool operator==(const Encoding other) const noexcept { return _index == other._index; } }; /** - * @brief Fallback function. Invoked when a small number of bytes could not be - * converted to a Unicode character. This function should process all - * bytes from inbuf and may produce replacement Unicode characters by calling - * the write_replacement callback repeatedly. - */ - typedef void (*iconv_unicode_mb_to_uc_fallback)(const char *inbuf, size_t inbufsize, - void (*write_replacement)(const unsigned int *buf, size_t buflen, - void *callback_arg), - void *callback_arg, void *data); - - /** - * @brief Fallback function. Invoked when a Unicode character could not be converted - * to the target encoding. This function should process the character and - * may produce replacement bytes (in the target encoding) by calling the - * write_replacement callback repeatedly. - */ - typedef void (*iconv_unicode_uc_to_mb_fallback)(unsigned int code, - void (*write_replacement)(const char *buf, size_t buflen, - void *callback_arg), - void *callback_arg, void *data); - - /** - * @brief Set of fallbacks. + * @brief Version information. */ - struct iconv_fallbacks + struct VersionInfo { - iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback; - iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback; - void *data; + /** + * @brief Major version. + */ + int major; + + /** + * @brief Minor version. + */ + int minor; + + /** + * @brief Patch version. + */ + int patch; }; /** - * @brief Surfaces. The concept of surfaces is described in the 'recode' manual. + * @brief Version infomation. */ - constexpr int ICONV_SURFACE_NONE = 0; - /** - * @brief In EBCDIC encodings, 0x15 (which encodes the "newline function", see the - * Unicode standard, chapter 5) maps to U+000A instead of U+0085. This is - * for interoperability with C programs and Unix environments on z/OS. - */ - constexpr int ICONV_SURFACE_EBCDIC_ZOS_UNIX = 1; - - /** - * @brief Request for iconvctl. - */ - constexpr int ICONV_TRIVIALP = 0; /* int *argument */ - /** - * @brief Request for iconvctl. - */ - constexpr int ICONV_GET_DISCARD_ILSEQ = 3; /* int *argument */ - /** - * @brief Request for iconvctl. - */ - constexpr int ICONV_SET_DISCARD_ILSEQ = 4; /* const int *argument */ - /** - * @brief Request for iconvctl. - */ - constexpr int ICONV_SET_HOOKS = 5; /* const struct iconv_hooks *argument */ - /** - * @brief Request for iconvctl. - */ - constexpr int ICONV_SET_FALLBACKS = 6; /* const struct iconv_fallbacks *argument */ - /** - * @brief Request for iconvctl. - */ - constexpr int ICONV_GET_FROM_SURFACE = 7; /* unsigned int *argument */ - /** - * @brief Request for iconvctl. - */ - constexpr int ICONV_SET_FROM_SURFACE = 8; /* const unsigned int *argument */ - /** - * @brief Request for iconvctl. - */ - constexpr int ICONV_GET_TO_SURFACE = 9; /* unsigned int *argument */ - /** - * @brief Request for iconvctl. - */ - constexpr int ICONV_SET_TO_SURFACE = 10; /* const unsigned int *argument */ + extern _CPPP_API VersionInfo version; /** - * @brief Listing of locale independent encodings. - * @param do_one One encoding fallback function. - * @param data Data. + * @brief Convert flags. Used for open conversion descriptor. */ - extern @DLL_VARIABLE@ void iconvlist(int (*do_one)(unsigned int namescount, const char *const *names, void *data), - void *data); + enum class ConvertFlag + { + /** + * @brief No flags. + */ + NO_FLAGS = 0, + + /** + * @brief Discard illegal sequences. Same as iconv(3) '//IGNORE'. + */ + DISCARD_ILSEQ = 1, + }; /** - * @brief Converts an entire string from one encoding to another, using iconv. Easier to use than iconv() itself. - * @note This function does not treat zero characters specially. - * @param cd Conversion descriptor. - * @param start Source string start pointer. - * @param end Source string end pointer. - * @param resultp Result memory pointer. - * @param lengthp Pointer to a variable that stores the length of the result. - * @return Return 0 if successful, otherwise return errno and errno set. Particular errno values are EILSEQ and ENOMEM. - */ - extern @DLL_VARIABLE@ int iconv_string(const iconv_t& cd, const char *start, - const char *end, char **resultp, size_t *lengthp); - - /** - * @brief Converts an entire string from one encoding to another, - * and supports autodetect encodings on input. + * @brief Converts an string from one encoding to another, supports encodings autodetecting. * * @note Converts a memory region given in encoding FROMCODE to a new memory - * region in encoding TOCODE. FROMCODE and TOCODE are as for iconv_open(3), - * except that FROMCODE may be one of the values. - * - * @note "autodetect_utf8" supports ISO-8859-1 and UTF-8 - * @note "autodetect_jp" supports EUC-JP, ISO-2022-JP-2 and SHIFT_JIS - * @note "autodetect_kr" supports EUC-KR and ISO-2022-KR - * @note The input is in the memory region between start (inclusive) and end - * (exclusive). If resultp is not NULL, the output string is stored in - * *resultp; malloc/realloc is used to allocate the result. + * region in encoding TOCODE. FROMCODE and TOCODE are as for iconv_open(3), we don't support + * '//IGNORE' and '//TRANSLIT'. + * malloc/realloc is used to allocate the result. * * @note This function does not treat zero characters specially. - * @param tocode Target encoding. - * @param fromcode From encoding. - * @param start Source string start pointer. - * @param end Source string end pointer. - * @param resultp Result memory pointer. - * @param lengthp Pointer to a variable that stores the length of the result. - * @return Return 0 if successful, otherwise return errno and errno set. Particular errno values: EILSEQ and ENOMEM. - * - * @example - * const char* s = ...; - * char* result = NULL; - * if (iconv_string("UCS-4-INTERNAL", "GBK", - * s, s+strlen(s)+1, &result, NULL) != 0) - * perror("iconv_string"); - * + * @param from The input buffer encoding. + * @param to The output buffer encoding. + * @param input Input buffer. + * @param strict If false. We will ignore all conversion errors. Same as iconv(3) '//IGNORE'. + * @return Return the output buffer. + * @throw std::system_error if an error occurs. */ - extern @DLL_VARIABLE@ int iconv_string(const char* tocode, const char* fromcode, const char* start, - const char* end, char** resultp, size_t* lengthp); + extern _CPPP_API std::string convert(Encoding from, Encoding to, const std::string_view input, enum ConvertFlag flag = ConvertFlag::NO_FLAGS); /** - * @brief Converts an entire string from one encoding to another. - * @note This function does not treat zero characters specially. - * @param tocode_cp Target encoding codepage. - * @param fromcode_cp From encoding codepage. - * @param start Source string start pointer. - * @param end Source string end pointer. - * @param resultp Result memory pointer. - * @param lengthp Pointer to a variable that stores the length of the result. - * @param strict Strict mode, if false, will ignore the invalid characters. - * @return Return 0 if successful, otherwise return errno and errno set. Particular errno values: EILSEQ and ENOMEM. - * - * @example - * const char* s = ...; - * char* result = NULL; - * if (iconv_string(65001, 936, - * s, s+strlen(s)+1, &result, NULL) != 0) - * perror("iconv_string"); - * + * @brief Determine the current locale's character encoding. + * @note The result is statically allocated. + * @return The canonicalized encoding name. */ - extern @DLL_VARIABLE@ int iconv_string(int tocode_cp, int fromcode_cp, const char* start, - const char* end, char** resultp, size_t* lengthp, bool strict=true); - - /** - * @brief Encode source string to another encoding. - * @param from From encoding. - * @param to Target encoding. - * @param data Input string data. - * @param ignore Ignore invalid characters. - * @throw int: when conversation error, throw the 'errno', you can catch the errno for more infomation. - */ - inline std::vector encode(const std::string& from, const std::string& to, const std::vector& data, - bool ignore = false) - { - char *result = NULL; - size_t length = 0; - std::string ignstr = ignore ? "//IGNORE" : ""; - if (iconv_string((to + ignstr).c_str(), from.c_str(), data.data(), data.data() + data.size(), &result, - &length) < 0) - { - if (!ignore) - { - /* When conversation error, throw the errno, you can catch the errno for more infomation. */ - throw(int)(errno); - } - } - return std::vector(result, result + length); - } + extern _CPPP_API std::string_view locale_charset(); - } // namespace reiconv - } // namespace base - } // namespace cppp -} +} // namespace reiconv -#endif /* _CPPP_REICONV_HPP */ +#endif // _CPPP_REICONV_HPP_ diff --git a/include/iconv.h.in b/include/iconv.h.in new file mode 100644 index 00000000..fccd39c6 --- /dev/null +++ b/include/iconv.h.in @@ -0,0 +1,78 @@ +/** + * @file iconv.h + * @author ChenPi11 + * @brief reiconv iconv API compatibility header. + * @version 3.0.0 + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#ifndef _ICONV_H_ +#define _ICONV_H_ + +#if _MSC_VER >= 1600 +#pragma execution_character_set("utf-8") +#endif + +#include + +#undef iconv_t +#undef iconv_open +#undef iconv +#undef iconv_close + +/** + * @brief Iconv conversion descriptor type. + * @note This type is equivalent to `reiconv_t`. + * @see reiconv_t + */ +#define iconv_t reiconv_t + + /** + * @brief Open a conversion descriptor. For iconv compatibility. + * @param tocode The target encoding. Supports "//IGNORE". + * @param fromcode The source encoding. + * @return The conversion descriptor. (iconv_t)(-1) on error with errno set. + */ +#define iconv_open reiconv_open + +/** + * @brief Convert at most `*inbytesleft` bytes from `*inbuf` according to the code conversion + * algorithm specified by `cd` and place up to `*outbytesleft` bytes in buffer at `*outbuf`. + * @param cd The conversion descriptor. + * @param inbuf The input buffer. + * @param inbytesleft The number of bytes in the input buffer. + * @param outbuf The output buffer. + * @param outbytesleft The number of bytes in the output buffer. + * @return The number of bytes converted, or (size_t)(-1) on error with errno set. + * @note This function is equivalent to `reiconv_iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft)`. + * @see reiconv_iconv + */ +#define iconv reiconv_iconv + +/** + * @brief Close the conversion descriptor. + * @param cd The conversion descriptor. + * @return 0 on success, -1 on error with errno set. + * @note This function is equivalent to `reiconv_handle_close(cd)`. + * @see reiconv_handle_close + */ +#define iconv_close reiconv_handle_close + +#endif /* _ICONV_H_ */ diff --git a/lang/en_US.langmap b/lang/en_US.langmap deleted file mode 100644 index a266313d..00000000 --- a/lang/en_US.langmap +++ /dev/null @@ -1,4 +0,0 @@ -# C++ Plus NLS Util language map for cppp-reiconv. -# en_US - -# Original comment of reiconv.hpp.in is en_US, so we can keep this langmap empty. diff --git a/lang/zh_CN.langmap b/lang/zh_CN.langmap deleted file mode 100644 index 8b54e747..00000000 --- a/lang/zh_CN.langmap +++ /dev/null @@ -1,422 +0,0 @@ -# C++ Plus NLS Util language map for cppp-reiconv. -# zh_CN - -''' -/* Copyright (C) 1999-2023 Free Software Foundation, Inc. - This file is part of the cppp-reiconv library. - - The cppp-reiconv library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 3 - of the License, or (at your option) any later version. - - The cppp-reiconv library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the cppp-reiconv library; see the file COPYING. - If not, see . */ -''' -/* ็‰ˆๆƒๆ‰€ๆœ‰ (C) 1999-2023 Free Software Foundation, Inc. - ๆœฌๆ–‡ไปถๆ˜ฏ cppp-reiconv ๅบ“็š„ไธ€้ƒจๅˆ†ใ€‚ - - cppp-reiconv ๅบ“ๆ˜ฏ่‡ช็”ฑ่ฝฏไปถ๏ผŒๆ‚จๅฏไปฅๅœจ่‡ช็”ฑ่ฝฏไปถๅŸบ้‡‘ไผšๅ‘ๅธƒ็š„ GNU Lesser General Public - License ็‰ˆๆœฌ 3 ๆˆ–่€…๏ผˆๆ นๆฎๆ‚จ็š„้€‰ๆ‹ฉ๏ผ‰ไปปไฝ•ไปฅๅŽ็š„็‰ˆๆœฌไธ‹้‡ๆ–ฐๅˆ†ๅ‘ๅ’Œ/ๆˆ–ไฟฎๆ”นๅฎƒใ€‚ - - cppp-reiconv ๅบ“่ขซๅˆ†ๅ‘๏ผŒๅธŒๆœ›ๅฎƒๅฏนๆ‚จๆœ‰็”จ๏ผŒไฝ†ๆฒกๆœ‰ไปปไฝ•ๆ‹…ไฟ๏ผ›็”š่‡ณๆฒกๆœ‰ๆš—็คบ็š„ๆ‹…ไฟ - ๅ•†ไธšๆ€งๅ’Œ็‰นๅฎš็›ฎ็š„้€‚็”จๆ€ง็š„ๆ‹…ไฟใ€‚่ฏทๅ‚้˜… GNU Lesser General Public License ่Žทๅ–ๆ›ดๅคš่ฏฆ็ป†ไฟกๆฏใ€‚ - - ๆ‚จๅบ”่ฏฅๅทฒ็ปๆ”ถๅˆฐไบ† GNU Lesser General Public License ็š„ๅ‰ฏๆœฌ - ไธŽ cppp-reiconv ๅบ“ไธ€่ตท๏ผ›่ฏทๅ‚้˜… COPYING ๆ–‡ไปถใ€‚ - ๅฆ‚ๆžœๆฒกๆœ‰๏ผŒ่ฏทๅ‚้˜… https://www.gnu.org/licenses/ ใ€‚ */ -''' - -''' -/* When installed, this file is called "cppp/reiconv.hpp". */ -''' -/* ๅฎ‰่ฃ…ไน‹ๅŽ๏ผŒ่ฟ™ไธชๆ–‡ไปถๅซๅš โ€œcppp/reiconv.hppโ€ใ€‚ */ -''' - -''' -/* Use UTF-8 to decode this file. */ -''' -/* ไฝฟ็”จ UTF-8 ่งฃๆž่ฟ™ไธชๆ–‡ไปถ */ -''' - -''' - /** - * @brief Version infomation. (major<<8) + minor - */ -''' - /** - * @brief ็‰ˆๆœฌไฟกๆฏใ€‚ ็ฎ—ๆณ•๏ผš(major<<8) + minor - */ -''' - -''' - /** - * @typedef void* - * @brief Identifier for conversion method from one codeset to another. - */ -''' - /** - * @typedef void* - * @brief ไปŽไธ€ไธชๅญ—็ฌฆ้›†ๅˆฐๅฆไธ€ไธชๅญ—็ฌฆ้›†ไธญ็š„่ฝฌๆขๆ–นๆณ•็š„ๆ ‡่ฏ†็ฌฆใ€‚ - */ -''' - -''' - /** - * @brief Allocates descriptor for code conversion from encoding 'fromcode' to encoding 'tocode'. - * @param tocode Target encoding. - * @param fromcode From encoding. - * @return Allocated iconv conversation buffer's pointer. - */ -''' - /** - * @brief ไธบไปŽ็ผ–็  โ€œfromcodeโ€ ๅˆฐ็ผ–็  โ€œtocodeโ€ ็š„็ผ–็ ่ฝฌๆขๅˆ†้…ๆ่ฟฐ็ฌฆใ€‚ - * @param tocode ็›ฎๆ ‡็ผ–็ ใ€‚ - * @param fromcode ๅŽŸ็ผ–็ ใ€‚ - * @return ๅˆ†้…็š„ iconv ๆ่ฟฐ็ฌฆใ€‚ - */ -''' - -''' - /** - * @brief Allocates descriptor for code conversion from codepage 'tocode_cp' to codepage 'fromcode_cp'. - * @param tocode_cp Target codepage. - * @param fromcode_cp From codepage. - * @param strict Strict mode, if false, will ignore the invalid characters. - * @note Some encoding may don't have codepage. - * @return Allocated iconv conversation buffer's pointer. - */ -''' - /** - * @brief ไธบไปŽไปฃ็ ้กต โ€œfromcode_cpโ€ ๅˆฐไปฃ็ ้กต โ€œtocode_cpโ€ ็š„็ผ–็ ่ฝฌๆขๅˆ†้…ๆ่ฟฐ็ฌฆใ€‚ - * @param tocode_cp Target codepage. - * @param fromcode_cp From codepage. - * @param strict Strict mode, if false, will ignore the invalid characters. - * @note Some encoding may don't have codepage. - * @return Allocated iconv conversation buffer's pointer. - */ -''' - -''' - /** - * @brief Converts, using conversion descriptor 'cd', at most '*inbytesleft' bytes starting at '*inbuf', writing at - * most '*outbytesleft' bytes starting at '*outbuf'. - * @attention Decrements '*inbytesleft' and increments '*inbuf' by the same amount. - * @attention Decrements '*outbytesleft' and increments '*outbuf' by the same amount. - * @param cd Conversion descriptor. - * @param inbuf Input buffer. - * @param inbytesleft Input bytes left. - * @param outbuf Output buffer. - * @param outbytesleft Output bytes left. - * @return Number of converted characters (excluding terminators, -1 means error). - */ -''' - /** - * @brief ไฝฟ็”จ่ฝฌๆขๆ่ฟฐ็ฌฆ โ€œcdโ€๏ผŒๅฐ†ๆœ€ๅคš โ€œ*inbytesleftโ€ ๅญ—่Š‚ไปŽ โ€œ*inbufโ€ ๅผ€ๅง‹่ฝฌๆข๏ผŒๅนถๅฐ†ๆœ€ๅคš โ€œ*outbytesleftโ€ ๅญ—่Š‚ๅ†™ๅ…ฅ - * โ€œ*outbufโ€ ใ€‚ - * @attention ๅฐ† โ€œ*inbytesleftโ€ ๅ‡ๅฐ‘็›ธๅŒ็š„ๆ•ฐ้‡๏ผŒๅนถๅฐ† โ€œ*inbufโ€ ๅขžๅŠ ็›ธๅŒ็š„ๆ•ฐ้‡ใ€‚ - * @attention ๅฐ† โ€œ*outbytesleftโ€ ๅ‡ๅฐ‘็›ธๅŒ็š„ๆ•ฐ้‡๏ผŒๅนถๅฐ† โ€œ*outbufโ€ ๅขžๅŠ ็›ธๅŒ็š„ๆ•ฐ้‡ใ€‚ - * @param cd ่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚ - * @param inbuf ่พ“ๅ…ฅ็ผ“ๅ†ฒๅŒบใ€‚ - * @param inbytesleft ๅ‰ฉไฝ™่พ“ๅ…ฅๅญ—่Š‚ใ€‚ - * @param outbuf ่พ“ๅ‡บ็ผ“ๅ†ฒๅŒบใ€‚ - * @param outbytesleft ๅ‰ฉไฝ™่พ“ๅ‡บๅญ—่Š‚ใ€‚ - * @return ่ฝฌๆข็š„ๅญ—็ฌฆๆ•ฐ้‡๏ผˆไธๅŒ…ๆ‹ฌ็ปˆๆญข็ฌฆ๏ผŒ-1 ่กจ็คบ้”™่ฏฏ๏ผ‰ใ€‚ - */ -''' - -''' - /** - * @brief Frees resources allocated for conversion descriptor 'cd'. - * @param cd Conversion descriptor you want to close. - * @return Operation status. (-1 means error, 0 means success). - */ -''' - /** - * @brief ้‡Šๆ”พไธบ่ฝฌๆขๆ่ฟฐ็ฌฆ โ€œcdโ€ ๅˆ†้…็š„่ต„ๆบใ€‚ - * @param cd ๆ‚จๆƒณ่ฆ้‡Šๆ”พ็š„ iconv ่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚ - * @return ๆ“ไฝœ็Šถๆ€ใ€‚๏ผˆ-1 ่กจ็คบ้”™่ฏฏ๏ผŒ0 ่กจ็คบๆˆๅŠŸ๏ผ‰ใ€‚ - */ -''' - -''' - /** - * @brief Control of attributes. - * @param cd Conversion descriptor. - * @param request Attribute request id. - * @param argument Attribute argument. - * @return Operation status (>=0 means success, <0 means error). - */ -''' - /** - * @brief ่ฎพ็ฝฎๆ่ฟฐ็ฌฆ็š„ๅฑžๆ€ง - * @param cd ่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚ - * @param request ๅฑžๆ€ง่ฏทๆฑ‚ IDใ€‚ - * @param argument ๅฑžๆ€ง็š„ๅ€ผใ€‚ - * @return ๆ“ไฝœ็Šถๆ€๏ผˆ>=0 ่กจ็คบๆˆๅŠŸ๏ผŒ<0 ่กจ็คบ้”™่ฏฏ๏ผ‰ใ€‚ - */ -''' - -''' - /** - * @typedef void (*) (unsigned int, void*) - * @brief Hook performed after every successful conversion of a Unicode character. - */ -''' - /** - * @typedef void (*) (unsigned int, void*) - * @brief ๅœจๆฏๆฌกๆˆๅŠŸ่ฝฌๆข Unicode ๅญ—็ฌฆไน‹ๅŽๆ‰ง่กŒ็š„้’ฉๅญๅ‡ฝๆ•ฐใ€‚ - */ -''' - -''' - /** - * @brief Set of hooks. - */ -''' - /** - * @brief ้’ฉๅญๅ‡ฝๆ•ฐ้›†ใ€‚ - */ -''' - -''' - /** - * @brief Fallback function. Invoked when a small number of bytes could not be - * converted to a Unicode character. This function should process all - * bytes from inbuf and may produce replacement Unicode characters by calling - * the write_replacement callback repeatedly. - */ -''' - /** - ย * @brief ๅ›ž่ฐƒๅ‡ฝๆ•ฐใ€‚ๅฝ“ๅฐ‘้‡ๅญ—่Š‚ๆ— ๆณ•่ฝฌๆขไธบ Unicode ๅญ—็ฌฆๆ—ถ่ฐƒ็”จใ€‚ - * ๆญคๅ‡ฝๆ•ฐๅบ”ๅค„็† โ€œinbufโ€ ไธญ็š„ๆ‰€ๆœ‰ๅญ—่Š‚๏ผŒๅนถ้€š่ฟ‡ๅคšๆฌก่ฐƒ็”จ โ€œwrite_replacementโ€ ๅ›ž่ฐƒๅ‡ฝๆ•ฐ็”Ÿๆˆๆ›ฟๆข็š„ Unicode ๅญ—็ฌฆใ€‚ - ย */ -''' - -''' - /** - * @brief Fallback function. Invoked when a Unicode character could not be converted - * to the target encoding. This function should process the character and - * may produce replacement bytes (in the target encoding) by calling the - * write_replacement callback repeatedly. - */ -''' - /** - * @brief ๅ›ž่ฐƒๅ‡ฝๆ•ฐใ€‚ๅœจๆ— ๆณ•ๅฐ† Unicode ๅญ—็ฌฆ่ฝฌๆขไธบ็›ฎๆ ‡็ผ–็ ๆ—ถ่ฐƒ็”จใ€‚ - * ๆญคๅ‡ฝๆ•ฐๅบ”ๅค„็†ๅญ—็ฌฆ๏ผŒๅนถๅฏ้€š่ฟ‡้‡ๅค่ฐƒ็”จ โ€œwrite_replacementโ€ ๅ›ž่ฐƒๆฅ็”Ÿๆˆๆ›ฟไปฃๅญ—่Š‚๏ผˆไฝฟ็”จ็›ฎๆ ‡็ผ–็ ๏ผ‰ใ€‚ - */ -''' - -''' - /** - * @brief Set of fallbacks. - */ -''' - /** - * @brief ๅ›ž่ฐƒๅ‡ฝๆ•ฐ้›†ใ€‚ - */ -''' - -''' - /** - * @brief Surfaces. The concept of surfaces is described in the 'recode' manual. - */ -''' - /** - * @brief Surfaces. โ€œSurfacesโ€ ๆ˜ฏๅœจ โ€œrecodeโ€ ๆ‰‹ๅ†Œไธญๆ่ฟฐ็š„ๆฆ‚ๅฟตใ€‚ - */ -''' - -''' - /** - * @brief In EBCDIC encodings, 0x15 (which encodes the "newline function", see the - * Unicode standard, chapter 5) maps to U+000A instead of U+0085. This is - * for interoperability with C programs and Unix environments on z/OS. - */ -''' - /** - * @brief ๅœจ EBCDIC ็ผ–็ ไธญ๏ผŒ0x15๏ผˆ็”จไบŽ็ผ–็ โ€œๆข่กŒ็ฌฆๅŠŸ่ƒฝโ€๏ผŒๅ‚่ง Unicode ๆ ‡ๅ‡†็ฌฌ 5 ็ซ ๏ผ‰ๅฐ†ๆ˜ ๅฐ„ไธบ U+000A ่€Œไธๆ˜ฏ U+0085 ใ€‚ - * ่ฟ™ๆ˜ฏไธบไบ†ๅœจ z/OS ไธŠไธŽ C ็จ‹ๅบๅ’Œ Unix ็Žฏๅขƒๅฎž็Žฐไบ’ๆ“ไฝœๆ€งใ€‚ - */ -''' - -''' - /** - * @brief Request for iconvctl. - */ -''' - /** - * @brief โ€œiconvctlโ€ ็š„ โ€œrequestโ€. - */ -''' - -''' - /** - * @brief Listing of locale independent encodings. - * @param do_one One encoding fallback function. - * @param data Data. - */ -''' - /** - * @brief ๅˆ—ๅ‡บไธŽๅŒบๅŸŸ่ฎพ็ฝฎๆ— ๅ…ณ็š„็ผ–็ ๆ–นๅผใ€‚ - * @param do_one ไธ€ไธช็ผ–็ ๅ›ž้€€ๅ‡ฝๆ•ฐใ€‚ - * @param data ๆ•ฐๆฎใ€‚ - */ -''' - -''' - /** - * @brief Converts an entire string from one encoding to another, using iconv. Easier to use than iconv() itself. - * @note This function does not treat zero characters specially. - * @param cd Conversion descriptor. - * @param start Source string start pointer. - * @param end Source string end pointer. - * @param resultp Result memory pointer. - * @param lengthp Pointer to a variable that stores the length of the result. - * @return Return 0 if successful, otherwise return errno and errno set. Particular errno values are EILSEQ and ENOMEM. - */ -''' - /** - * @brief ไฝฟ็”จ iconv ๅฐ†ๆ•ดไธชๅญ—็ฌฆไธฒไปŽไธ€็ง็ผ–็ ่ฝฌๆขไธบๅฆไธ€็ง็ผ–็ ใ€‚ๆฏ”็›ดๆŽฅไฝฟ็”จ iconv() ๅ‡ฝๆ•ฐๆ›ด็ฎ€ๅ•ใ€‚ - * @note ่ฏฅๅ‡ฝๆ•ฐไธ็‰นๆฎŠๅค„็† '\0' ๅญ—็ฌฆใ€‚ - * @param cd ่ฝฌๆขๆ่ฟฐ็ฌฆใ€‚ - * @param start ๆบๅญ—็ฌฆไธฒ่ตทๅง‹ๆŒ‡้’ˆใ€‚ - * @param end ๆบๅญ—็ฌฆไธฒ็ป“ๆŸๆŒ‡้’ˆใ€‚ - * @param resultp ็ป“ๆžœๅ†…ๅญ˜ๆŒ‡้’ˆใ€‚ - * @param lengthp ๆŒ‡ๅ‘ๅญ˜ๅ‚จ็ป“ๆžœ้•ฟๅบฆ็š„ๅ˜้‡็š„ๆŒ‡้’ˆใ€‚ - * @return ๅฆ‚ๆžœๆˆๅŠŸ๏ผŒ่ฟ”ๅ›ž 0 ๏ผŒๅฆๅˆ™่ฟ”ๅ›ž errno ๅนถ่ฎพ็ฝฎ errno ใ€‚็‰นๅฎš็š„ errno ๅ€ผๅŒ…ๆ‹ฌ EILSEQ ๅ’Œ ENOMEM ใ€‚ - */ -''' - -''' - /** - * @brief Converts an entire string from one encoding to another, - * and supports autodetect encodings on input. - * - * @note Converts a memory region given in encoding FROMCODE to a new memory - * region in encoding TOCODE. FROMCODE and TOCODE are as for iconv_open(3), - * except that FROMCODE may be one of the values. - * - * @note "autodetect_utf8" supports ISO-8859-1 and UTF-8 - * @note "autodetect_jp" supports EUC-JP, ISO-2022-JP-2 and SHIFT_JIS - * @note "autodetect_kr" supports EUC-KR and ISO-2022-KR - * @note The input is in the memory region between start (inclusive) and end - * (exclusive). If resultp is not NULL, the output string is stored in - * *resultp; malloc/realloc is used to allocate the result. - * - * @note This function does not treat zero characters specially. - * @param tocode Target encoding. - * @param fromcode From encoding. - * @param start Source string start pointer. - * @param end Source string end pointer. - * @param resultp Result memory pointer. - * @param lengthp Pointer to a variable that stores the length of the result. - * @return Return 0 if successful, otherwise return errno and errno set. Particular errno values: EILSEQ and ENOMEM. - * - * @example - * const char* s = ...; - * char* result = NULL; - * if (iconv_string("UCS-4-INTERNAL", "GBK", - * s, s+strlen(s)+1, &result, NULL) != 0) - * perror("iconv_string"); - * - */ -''' - /** - * @brief ๅฐ†ๆ•ดไธชๅญ—็ฌฆไธฒไปŽไธ€็ง็ผ–็ ่ฝฌๆขไธบๅฆไธ€็ง็ผ–็ ๏ผŒๅนถๆ”ฏๆŒ่‡ชๅŠจๆฃ€ๆต‹่พ“ๅ…ฅ็ผ–็ ใ€‚ - * - * @note ๅฐ†ไปฅ็ผ–็  FROMCODE ็ป™ๅ‡บ็š„ๅ†…ๅญ˜ๅŒบๅŸŸ่ฝฌๆขไธบไปฅ็ผ–็  TOCODE ็ป™ๅ‡บ็š„ๆ–ฐๅ†…ๅญ˜ๅŒบๅŸŸใ€‚ FROMCODE ๅ’Œ TOCODE ไธŽ iconv_open(3) ไธญ็š„ๅ‚ๆ•ฐ็›ธๅŒ๏ผŒไฝ† FROMCODE ๅฏ่ƒฝๆ˜ฏไปฅไธ‹ๅ€ผไน‹ไธ€ใ€‚ - * - * @note "autodetect_utf8" ๆ”ฏๆŒ ISO-8859-1 ๅ’Œ UTF-8 - * @note "autodetect_jp" ๆ”ฏๆŒ EUC-JP ใ€ ISO-2022-JP-2ๅ’Œ SHIFT_JIS - * @note "autodetect_kr" ๆ”ฏๆŒ EUC-KR ๅ’Œ ISO-2022-KR - * @note ่พ“ๅ…ฅไฝไบŽ start ๏ผˆๅŒ…ๅซ๏ผ‰ๅ’Œ end ๏ผˆไธๅŒ…ๅซ๏ผ‰ไน‹้—ด็š„ๅ†…ๅญ˜ๅŒบๅŸŸใ€‚ๅฆ‚ๆžœ resultp ไธไธบ NULL ๏ผŒๅˆ™่พ“ๅ‡บๅญ—็ฌฆไธฒๅญ˜ๅ‚จๅœจ *resultp ไธญ๏ผ› malloc/realloc ็”จไบŽๅˆ†้…็ป“ๆžœใ€‚ - * - * @note ่ฏฅๅ‡ฝๆ•ฐไธ็‰นๆฎŠๅค„็†้›ถๅญ—็ฌฆใ€‚ - * @param tocode ็›ฎๆ ‡็ผ–็ ใ€‚ - * @param fromcode ๆบ็ผ–็ ใ€‚ - * @param start ๆบๅญ—็ฌฆไธฒ่ตทๅง‹ๆŒ‡้’ˆใ€‚ - * @param end ๆบๅญ—็ฌฆไธฒ็ป“ๆŸๆŒ‡้’ˆใ€‚ - * @param resultp ็ป“ๆžœๅ†…ๅญ˜ๆŒ‡้’ˆใ€‚ - * @param lengthp ๆŒ‡ๅ‘ๅญ˜ๅ‚จ็ป“ๆžœ้•ฟๅบฆ็š„ๅ˜้‡็š„ๆŒ‡้’ˆใ€‚ - * @return ๅฆ‚ๆžœๆˆๅŠŸ๏ผŒ่ฟ”ๅ›ž0๏ผ›ๅฆๅˆ™่ฟ”ๅ›ž errno ๅนถ่ฎพ็ฝฎ errno ใ€‚็‰นๅฎš็š„ errno ๅ€ผๅŒ…ๆ‹ฌ EILSEQ ๅ’Œ ENOMEM ใ€‚ - * - * @example - * const char* s = ...; - * char* result = NULL; - * if (iconv_string("UCS-4-INTERNAL", "GBK", - * s, s+strlen(s)+1, &result, NULL) != 0) - * perror("iconv_string"); - * - */ -''' - -''' - /** - * @brief Converts an entire string from one encoding to another. - * @note This function does not treat zero characters specially. - * @param tocode_cp Target encoding codepage. - * @param fromcode_cp From encoding codepage. - * @param start Source string start pointer. - * @param end Source string end pointer. - * @param resultp Result memory pointer. - * @param lengthp Pointer to a variable that stores the length of the result. - * @param strict Strict mode, if false, will ignore the invalid characters. - * @return Return 0 if successful, otherwise return errno and errno set. Particular errno values: EILSEQ and ENOMEM. - * - * @example - * const char* s = ...; - * char* result = NULL; - * if (iconv_string(65001, 936, - * s, s+strlen(s)+1, &result, NULL) != 0) - * perror("iconv_string"); - * - */ -''' - /** - * @brief ๅฐ†ๆ•ดไธชๅญ—็ฌฆไธฒไปŽไธ€็ง็ผ–็ ่ฝฌๆขไธบๅฆไธ€็ง็ผ–็ ใ€‚ - * @note ่ฏฅๅ‡ฝๆ•ฐไธ็‰นๆฎŠๅค„็†้›ถๅญ—็ฌฆใ€‚ - * @param tocode_cp ็›ฎๆ ‡็ผ–็ ้กตใ€‚ - * @param fromcode_cp ๆบ็ผ–็ ้กตใ€‚ - * @param start ๆบๅญ—็ฌฆไธฒ่ตทๅง‹ๆŒ‡้’ˆใ€‚ - * @param end ๆบๅญ—็ฌฆไธฒ็ป“ๆŸๆŒ‡้’ˆใ€‚ - * @param resultp ็ป“ๆžœๅ†…ๅญ˜ๆŒ‡้’ˆใ€‚ - * @param lengthp ๆŒ‡ๅ‘ๅญ˜ๅ‚จ็ป“ๆžœ้•ฟๅบฆ็š„ๅ˜้‡็š„ๆŒ‡้’ˆใ€‚ - * @param strict ไธฅๆ ผๆจกๅผ๏ผŒๅฆ‚ๆžœไธบ false ๏ผŒๅฐ†ๅฟฝ็•ฅๆ— ๆ•ˆๅญ—็ฌฆใ€‚ - * @return ๅฆ‚ๆžœๆˆๅŠŸ๏ผŒ่ฟ”ๅ›ž 0 ๏ผ›ๅฆๅˆ™่ฟ”ๅ›ž errno ๅนถ่ฎพ็ฝฎ errno ใ€‚็‰นๅฎš็š„ errno ๅ€ผๅŒ…ๆ‹ฌ EILSEQ ๅ’Œ ENOMEM ใ€‚ - * - * @example - * const char* s = ...; - * char* result = NULL; - * if (iconv_string(65001, 936, - * s, s+strlen(s)+1, &result, NULL) != 0) - * perror("iconv_string"); - * - */ -''' - -''' - /** - * @brief Encode source string to another encoding. - * @param from From encoding. - * @param to Target encoding. - * @param data Input string data. - * @param ignore Ignore invalid characters. - * @throw int: when conversation error, throw the 'errno', you can catch the errno for more infomation. - */ -''' - /** - * @brief ๅฐ†ๆบๅญ—็ฌฆไธฒ็ผ–็ ไธบๅฆไธ€็ง็ผ–็ ๆ–นๅผใ€‚ - * @param from ๆบ็ผ–็ ใ€‚ - * @param to ็›ฎๆ ‡็ผ–็ ใ€‚ - * @param data ่พ“ๅ…ฅๅญ—็ฌฆไธฒๆ•ฐๆฎใ€‚ - * @param ignore ๅฟฝ็•ฅๆ— ๆ•ˆๅญ—็ฌฆใ€‚ - * @throw int๏ผšๅฝ“่ฝฌๆข้”™่ฏฏๆ—ถ๏ผŒๆŠ›ๅ‡บ โ€œerrnoโ€ ๏ผŒๆ‚จๅฏไปฅๆ•่Žท errno ไปฅ่Žทๅ–ๆ›ดๅคšไฟกๆฏใ€‚ - */ -''' diff --git a/lib/aliases2.h b/lib/aliases2.h deleted file mode 100644 index 02d9b96a..00000000 --- a/lib/aliases2.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 1999-2003, 2008, 2022 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -#ifdef USE_AIX -# if defined _AIX -# include "aliases_aix_sysaix.h" -# else -# include "aliases_aix.h" -# endif -#endif -#ifdef USE_OSF1 -# if defined __osf__ -# include "aliases_osf1_sysosf1.h" -# else -# include "aliases_osf1.h" -# endif -#endif -#ifdef USE_DOS -# include "aliases_dos.h" -#endif -#ifdef USE_ZOS -# include "aliases_zos.h" -#endif -#ifdef USE_EXTRA -# include "aliases_extra.h" -#endif diff --git a/lib/all_encodings.h b/lib/all_encodings.h new file mode 100644 index 00000000..e112b46e --- /dev/null +++ b/lib/all_encodings.h @@ -0,0 +1,43 @@ +/** + * @file all_encodings.h + * @brief Definition of `all_encodings[]`. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _ALL_ENCODINGS_H_ +#define _ALL_ENCODINGS_H_ + +#include "converters.h" // IWYU pragma: keep. Include all the converters for `encodings.h.snippet`. +#include "encoding.h" + +#define DEFENCODING(xxx_names, xxx, xxx_index, xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2) \ + {xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2}, +#define DEFCODEPAGE(codepage, xxx) +#define DEFINDEX(alias, name) + +static struct encoding const all_encodings[] = { +#include "encodings.h.snippet" +}; + +#undef DEFINDEX +#undef DEFENCODING +#undef DEFCODEPAGE + +#endif /* _ALL_ENCODINGS_H_ */ diff --git a/lib/big5_2003.h b/lib/big5_2003.h deleted file mode 100644 index 6051bfb7..00000000 --- a/lib/big5_2003.h +++ /dev/null @@ -1,475 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2005, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * BIG5-2003 - */ - -/* - * BIG5-2003 is a slightly extended and slightly modified version of BIG5. - * It is actually nearer to Microsoft CP950 than to BIG5. The differences - * between EASTASIA/OTHER/BIG5.TXT found on ftp.unicode.org and BIG5-2003.TXT - * are as follows: - * - * 1. Some characters in the symbols area (0xA140..0xA2CE) are defined - * differently: - * - * code BIG5.TXT BIG5-2003.TXT - * 0xA145 0x2022 # BULLET 0x2027 # HYPHENATION POINT - * 0xA14E 0xFF64 # HALFWIDTH IDEOGRAPHIC COMMA - * 0xFE51 # SMALL IDEOGRAPHIC COMMA - * 0xA156 0x2013 # EN DASH 0x2015 # HORIZONTAL BAR - * 0xA15A --- 0x2574 # BOX DRAWINGS LIGHT LEFT - * 0xA1C3 --- 0xFFE3 # FULLWIDTH MACRON - * 0xA1C5 --- 0x02CD # MODIFIER LETTER LOW MACRON - * 0xA1E3 0x223C # TILDE OPERATOR 0xFF5E # FULLWIDTH TILDE - * 0xA1F2 0x2641 # EARTH 0x2295 # CIRCLED PLUS - * 0xA1F3 0x2609 # SUN 0x2299 # CIRCLED DOT OPERATOR - * 0xA1FE --- 0xFF0F # FULLWIDTH SOLIDUS - * 0xA240 --- 0xFF3C # FULLWIDTH REVERSE SOLIDUS - * 0xA241 0xFF0F # FULLWIDTH SOLIDUS 0x2215 # DIVISION SLASH - * 0xA242 0xFF3C # FULLWIDTH REVERSE SOLIDUS - * 0xFE68 # SMALL REVERSE SOLIDUS - * 0xA244 0x00A5 # YEN SIGN 0xFFE5 # FULLWIDTH YEN SIGN - * 0xA246 0x00A2 # CENT SIGN 0xFFE0 # FULLWIDTH CENT SIGN - * 0xA247 0x00A3 # POUND SIGN 0xFFE1 # FULLWIDTH POUND SIGN - * 0xA2A4 0x2550 # BOX DRAWINGS DOUBLE HORIZONTAL - * 0x2501 # BOX DRAWINGS HEAVY HORIZONTAL - * 0xA2A5 0x255E # BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE - * 0x251D # BOX DRAWINGS VERTICAL LIGHT AND RIGHT HEAVY - * 0xA2A6 0x256A # BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE - * 0x253F # BOX DRAWINGS VERTICAL LIGHT AND HORIZONTAL HEAVY - * 0xA2A7 0x2561 # BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE - * 0x2525 # BOX DRAWINGS VERTICAL LIGHT AND LEFT HEAVY - * 0xA2CC --- 0x3038 # HANGZHOU NUMERAL TEN - * 0xA2CD 0x5344 0x3039 # HANGZHOU NUMERAL TWENTY - * 0xA2CE --- 0x303A # HANGZHOU NUMERAL THIRTY - * - * 2. A control symbols area is added: - * - * code - * 0xA3C0..0xA3E0 U+2400..U+2421 - * - * 3. The Euro sign is added: - * - * code - * 0xA3E1 0x20AC # EURO SIGN - * - * 4. Some characters in the main area are defined differently: - * - * code BIG5.TXT BIG5-2003.TXT - * 0xC255 0x5F5D 0x5F5E - * - * 5. The area 0xC6A1..0xC7FE is organized differently: - * - * code - * 0xC6A1..0xC6BE numerals (was in BIG5.TXT at 0xC7E9..0xC7FC) - * 0xC6BF..0xC6D7 radicals - * 0xC6D8..0xC6E6 rarely used symbols - * 0xC6E7..0xC77A hiragana (U+3041..U+3093, was in BIG5.TXT at 0xC6A5..0xC6F7) - * 0xC77B..0xC7F2 katakana (U+30A1..U+30F6, was in BIG5.TXT at 0xC6F8..0xC7B0) - * - * 6. Some characters are added at 0xF9D6..0xF9DC. - * - * 7. Box drawing characters are added at 0xF9DD..0xF9FE. - * - * Note: 4 of these characters are mapped in a non-inversible way, because - * Unicode does not yet include the corresponding characters: - * - * code Unicode approximation - * 0xF9FA BOX DRAWINGS DOUBLE ARC DOWN AND RIGHT 0x2554 - * 0xF9FB BOX DRAWINGS DOUBLE ARC DOWN AND LEFT 0x2557 - * 0xF9FC BOX DRAWINGS DOUBLE ARC UP AND RIGHT 0x255A - * 0xF9FD BOX DRAWINGS DOUBLE ARC UP AND LEFT 0x255D - * - * 8. Private area mappings are added: - * - * code Unicode - * 0x{81..8D}{40..7E,A1..FE} U+EEB8..U+F6B0 - * 0x{8E..A0}{40..7E,A1..FE} U+E311..U+EEB7 - * 0x{FA..FE}{40..7E,A1..FE} U+E000..U+E310 - * - * These mappings are not contained in the BSMI Big5-2003 standard. However, - * they were contained in a draft of it. - */ - -static const unsigned short big5_2003_2uni_pagea1[314] = { - /* 0xa1 */ - 0x3000, 0xff0c, 0x3001, 0x3002, 0xff0e, 0x2027, 0xff1b, 0xff1a, - 0xff1f, 0xff01, 0xfe30, 0x2026, 0x2025, 0xfe50, 0xfe51, 0xfe52, - 0x00b7, 0xfe54, 0xfe55, 0xfe56, 0xfe57, 0xff5c, 0x2015, 0xfe31, - 0x2014, 0xfe33, 0x2574, 0xfe34, 0xfe4f, 0xff08, 0xff09, 0xfe35, - 0xfe36, 0xff5b, 0xff5d, 0xfe37, 0xfe38, 0x3014, 0x3015, 0xfe39, - 0xfe3a, 0x3010, 0x3011, 0xfe3b, 0xfe3c, 0x300a, 0x300b, 0xfe3d, - 0xfe3e, 0x3008, 0x3009, 0xfe3f, 0xfe40, 0x300c, 0x300d, 0xfe41, - 0xfe42, 0x300e, 0x300f, 0xfe43, 0xfe44, 0xfe59, 0xfe5a, 0xfe5b, - 0xfe5c, 0xfe5d, 0xfe5e, 0x2018, 0x2019, 0x201c, 0x201d, 0x301d, - 0x301e, 0x2035, 0x2032, 0xff03, 0xff06, 0xff0a, 0x203b, 0x00a7, - 0x3003, 0x25cb, 0x25cf, 0x25b3, 0x25b2, 0x25ce, 0x2606, 0x2605, - 0x25c7, 0x25c6, 0x25a1, 0x25a0, 0x25bd, 0x25bc, 0x32a3, 0x2105, - 0x203e, 0xffe3, 0xff3f, 0x02cd, 0xfe49, 0xfe4a, 0xfe4d, 0xfe4e, - 0xfe4b, 0xfe4c, 0xfe5f, 0xfe60, 0xfe61, 0xff0b, 0xff0d, 0x00d7, - 0x00f7, 0x00b1, 0x221a, 0xff1c, 0xff1e, 0xff1d, 0x2266, 0x2267, - 0x2260, 0x221e, 0x2252, 0x2261, 0xfe62, 0xfe63, 0xfe64, 0xfe65, - 0xfe66, 0xff5e, 0x2229, 0x222a, 0x22a5, 0x2220, 0x221f, 0x22bf, - 0x33d2, 0x33d1, 0x222b, 0x222e, 0x2235, 0x2234, 0x2640, 0x2642, - 0x2295, 0x2299, 0x2191, 0x2193, 0x2190, 0x2192, 0x2196, 0x2197, - 0x2199, 0x2198, 0x2225, 0x2223, 0xff0f, - /* 0xa2 */ - 0xff3c, 0x2215, 0xfe68, 0xff04, 0xffe5, 0x3012, 0xffe0, 0xffe1, - 0xff05, 0xff20, 0x2103, 0x2109, 0xfe69, 0xfe6a, 0xfe6b, 0x33d5, - 0x339c, 0x339d, 0x339e, 0x33ce, 0x33a1, 0x338e, 0x338f, 0x33c4, - 0x00b0, 0x5159, 0x515b, 0x515e, 0x515d, 0x5161, 0x5163, 0x55e7, - 0x74e9, 0x7cce, 0x2581, 0x2582, 0x2583, 0x2584, 0x2585, 0x2586, - 0x2587, 0x2588, 0x258f, 0x258e, 0x258d, 0x258c, 0x258b, 0x258a, - 0x2589, 0x253c, 0x2534, 0x252c, 0x2524, 0x251c, 0x2594, 0x2500, - 0x2502, 0x2595, 0x250c, 0x2510, 0x2514, 0x2518, 0x256d, 0x256e, - 0x2570, 0x256f, 0x2501, 0x251d, 0x253f, 0x2525, 0x25e2, 0x25e3, - 0x25e5, 0x25e4, 0x2571, 0x2572, 0x2573, 0xff10, 0xff11, 0xff12, - 0xff13, 0xff14, 0xff15, 0xff16, 0xff17, 0xff18, 0xff19, 0x2160, - 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, - 0x2169, 0x3021, 0x3022, 0x3023, 0x3024, 0x3025, 0x3026, 0x3027, - 0x3028, 0x3029, 0x3038, 0x3039, 0x303a, 0xff21, 0xff22, 0xff23, - 0xff24, 0xff25, 0xff26, 0xff27, 0xff28, 0xff29, 0xff2a, 0xff2b, - 0xff2c, 0xff2d, 0xff2e, 0xff2f, 0xff30, 0xff31, 0xff32, 0xff33, - 0xff34, 0xff35, 0xff36, 0xff37, 0xff38, 0xff39, 0xff3a, 0xff41, - 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48, 0xff49, - 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50, 0xff51, - 0xff52, 0xff53, 0xff54, 0xff55, 0xff56, -}; - -static const unsigned short big5_2003_2uni_pagec6[70] = { - /* 0xc6a1 */ - 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, - 0x2468, 0x2469, 0x2474, 0x2475, 0x2476, 0x2477, 0x2478, 0x2479, - 0x247a, 0x247b, 0x247c, 0x247d, 0x2170, 0x2171, 0x2172, 0x2173, - 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x2f02, 0x2f03, - 0x2f05, 0x2f07, 0x2f0c, 0x2f0d, 0x2f0e, 0x2f13, 0x2f16, 0x2f19, - 0x2f1b, 0x2f22, 0x2f27, 0x2f2e, 0x2f33, 0x2f34, 0x2f35, 0x2f39, - 0x2f3a, 0x2f41, 0x2f46, 0x2f67, 0x2f68, 0x2fa1, 0x2faa, 0x00a8, - 0xff3e, 0x30fd, 0x30fe, 0x309d, 0x309e, 0xfffd, 0xfffd, 0x3005, - 0x3006, 0x3007, 0x30fc, 0xff3b, 0xff3d, 0x273d, -}; - -static const unsigned short big5_2003_2uni_pagef9[41] = { - /* 0xf9d6 */ - 0x7881, 0x92b9, 0x88cf, 0x58bb, 0x6052, 0x7ca7, 0x5afa, - /* 0xf9dd */ - 0x2554, 0x2566, 0x2557, 0x2560, 0x256c, 0x2563, 0x255a, 0x2569, - 0x255d, 0x2552, 0x2564, 0x2555, 0x255e, 0x256a, 0x2561, 0x2558, - 0x2567, 0x255b, 0x2553, 0x2565, 0x2556, 0x255f, 0x256b, 0x2562, - 0x2559, 0x2568, 0x255c, 0x2551, 0x2550, - 0x2554, 0x2557, 0x255a, 0x255d, /* not invertible */ - 0x2593, -}; - -static int -big5_2003_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - /* Code set 0 (ASCII) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (BIG5 extended) */ - if (c >= 0x81 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) { - if (c >= 0xa1) { - if (c < 0xa3) { - unsigned int i = 157 * (c - 0xa1) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); - unsigned short wc = big5_2003_2uni_pagea1[i]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; - } - } - if (!((c == 0xc6 && c2 >= 0xa1) || c == 0xc7)) { - if (!(c == 0xc2 && c2 == 0x55)) { - int ret = big5_mbtowc(conv,pwc,s,2); - if (ret != RET_ILSEQ) - return ret; - if (c == 0xa3) { - if (c2 >= 0xc0 && c2 <= 0xe1) { - *pwc = (c2 == 0xe1 ? 0x20ac : c2 == 0xe0 ? 0x2421 : 0x2340 + c2); - return 2; - } - } else if (c == 0xf9) { - if (c2 >= 0xd6) { - *pwc = big5_2003_2uni_pagef9[c2-0xd6]; - return 2; - } - } else if (c >= 0xfa) { - *pwc = 0xe000 + 157 * (c - 0xfa) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); - return 2; - } - } else { - /* c == 0xc2 && c2 == 0x55. */ - *pwc = 0x5f5e; - return 2; - } - } else { - /* (c == 0xc6 && c2 >= 0xa1) || c == 0xc7. */ - unsigned int i = 157 * (c - 0xc6) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); - if (i < 133) { - /* 63 <= i < 133. */ - unsigned short wc = big5_2003_2uni_pagec6[i-63]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; - } - } else if (i < 216) { - /* 133 <= i < 216. Hiragana. */ - *pwc = 0x3041 - 133 + i; - return 2; - } else if (i < 302) { - /* 216 <= i < 302. Katakana. */ - *pwc = 0x30a1 - 216 + i; - return 2; - } - } - } else { - /* 0x81 <= c < 0xa1. */ - *pwc = (c >= 0x8e ? 0xdb18 : 0xeeb8) + 157 * (c - 0x81) - + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); - return 2; - } - } - } - } - return RET_ILSEQ; -} - -static const unsigned char big5_2003_2charset_page25[29] = { - /* 0x2550 */ - 0xf9, 0xf8, 0xe6, 0xef, 0xdd, 0xe8, 0xf1, 0xdf, - 0xec, 0xf5, 0xe3, 0xee, 0xf7, 0xe5, 0xe9, 0xf2, - 0xe0, 0xeb, 0xf4, 0xe2, 0xe7, 0xf0, 0xde, 0xed, - 0xf6, 0xe4, 0xea, 0xf3, 0xe1, -}; - -static int -big5_2003_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[2]; - int ret; - - /* Code set 0 (ASCII) */ - ret = ascii_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - /* Code set 1 (BIG5 extended) */ - switch (wc >> 8) { - case 0x00: - if (wc == 0x00a8) { buf[0] = 0xc6; buf[1] = 0xd8; ret = 2; break; } - if (wc == 0x00a2 || wc == 0x00a3 || wc == 0x00a5) - return RET_ILUNI; - break; - case 0x02: - if (wc == 0x02cd) { buf[0] = 0xa1; buf[1] = 0xc5; ret = 2; break; } - break; - case 0x04: - return RET_ILUNI; - case 0x20: - if (wc == 0x2015) { buf[0] = 0xa1; buf[1] = 0x56; ret = 2; break; } - if (wc == 0x2027) { buf[0] = 0xa1; buf[1] = 0x45; ret = 2; break; } - if (wc == 0x20ac) { buf[0] = 0xa3; buf[1] = 0xe1; ret = 2; break; } - if (wc == 0x2013 || wc == 0x2022) - return RET_ILUNI; - break; - case 0x21: - if (wc >= 0x2170 && wc <= 0x2179) { - buf[0] = 0xc6; buf[1] = wc - 0x20bb; ret = 2; - break; - } - break; - case 0x22: - if (wc == 0x2215) { buf[0] = 0xa2; buf[1] = 0x41; ret = 2; break; } - if (wc == 0x2295) { buf[0] = 0xa1; buf[1] = 0xf2; ret = 2; break; } - if (wc == 0x2299) { buf[0] = 0xa1; buf[1] = 0xf3; ret = 2; break; } - if (wc == 0x223c) - return RET_ILUNI; - break; - case 0x24: - if (wc <= 0x241f) { buf[0] = 0xa3; buf[1] = wc - 0x2340; ret = 2; break; } - if (wc == 0x2421) { buf[0] = 0xa3; buf[1] = 0xe0; ret = 2; break; } - if (wc >= 0x2460 && wc <= 0x2469) { - buf[0] = 0xc6; buf[1] = wc - 0x23bf; ret = 2; - break; - } - if (wc >= 0x2474 && wc <= 0x247d) { - buf[0] = 0xc6; buf[1] = wc - 0x23c9; ret = 2; - break; - } - break; - case 0x25: - if (wc == 0x2501) { buf[0] = 0xa2; buf[1] = 0xa4; ret = 2; break; } - if (wc == 0x251d) { buf[0] = 0xa2; buf[1] = 0xa5; ret = 2; break; } - if (wc == 0x2525) { buf[0] = 0xa2; buf[1] = 0xa7; ret = 2; break; } - if (wc == 0x253f) { buf[0] = 0xa2; buf[1] = 0xa6; ret = 2; break; } - if (wc >= 0x2550 && wc <= 0x256c) { - buf[0] = 0xf9; buf[1] = big5_2003_2charset_page25[wc-0x2550]; ret = 2; - break; - } - if (wc == 0x2574) { buf[0] = 0xa1; buf[1] = 0x5a; ret = 2; break; } - if (wc == 0x2593) { buf[0] = 0xf9; buf[1] = 0xfe; ret = 2; break; } - break; - case 0x26: - if (wc == 0x2609 || wc == 0x2641) - return RET_ILUNI; - break; - case 0x27: - if (wc == 0x273d) { buf[0] = 0xc6; buf[1] = 0xe6; ret = 2; break; } - break; - case 0x2f: - if (wc == 0x2f02) { buf[0] = 0xc6; buf[1] = 0xbf; ret = 2; break; } - if (wc == 0x2f03) { buf[0] = 0xc6; buf[1] = 0xc0; ret = 2; break; } - if (wc == 0x2f05) { buf[0] = 0xc6; buf[1] = 0xc1; ret = 2; break; } - if (wc == 0x2f07) { buf[0] = 0xc6; buf[1] = 0xc2; ret = 2; break; } - if (wc == 0x2f0c) { buf[0] = 0xc6; buf[1] = 0xc3; ret = 2; break; } - if (wc == 0x2f0d) { buf[0] = 0xc6; buf[1] = 0xc4; ret = 2; break; } - if (wc == 0x2f0e) { buf[0] = 0xc6; buf[1] = 0xc5; ret = 2; break; } - if (wc == 0x2f13) { buf[0] = 0xc6; buf[1] = 0xc6; ret = 2; break; } - if (wc == 0x2f16) { buf[0] = 0xc6; buf[1] = 0xc7; ret = 2; break; } - if (wc == 0x2f19) { buf[0] = 0xc6; buf[1] = 0xc8; ret = 2; break; } - if (wc == 0x2f1b) { buf[0] = 0xc6; buf[1] = 0xc9; ret = 2; break; } - if (wc == 0x2f22) { buf[0] = 0xc6; buf[1] = 0xca; ret = 2; break; } - if (wc == 0x2f27) { buf[0] = 0xc6; buf[1] = 0xcb; ret = 2; break; } - if (wc == 0x2f2e) { buf[0] = 0xc6; buf[1] = 0xcc; ret = 2; break; } - if (wc == 0x2f33) { buf[0] = 0xc6; buf[1] = 0xcd; ret = 2; break; } - if (wc == 0x2f34) { buf[0] = 0xc6; buf[1] = 0xce; ret = 2; break; } - if (wc == 0x2f35) { buf[0] = 0xc6; buf[1] = 0xcf; ret = 2; break; } - if (wc == 0x2f39) { buf[0] = 0xc6; buf[1] = 0xd0; ret = 2; break; } - if (wc == 0x2f3a) { buf[0] = 0xc6; buf[1] = 0xd1; ret = 2; break; } - if (wc == 0x2f41) { buf[0] = 0xc6; buf[1] = 0xd2; ret = 2; break; } - if (wc == 0x2f46) { buf[0] = 0xc6; buf[1] = 0xd3; ret = 2; break; } - if (wc == 0x2f67) { buf[0] = 0xc6; buf[1] = 0xd4; ret = 2; break; } - if (wc == 0x2f68) { buf[0] = 0xc6; buf[1] = 0xd5; ret = 2; break; } - if (wc == 0x2fa1) { buf[0] = 0xc6; buf[1] = 0xd6; ret = 2; break; } - if (wc == 0x2faa) { buf[0] = 0xc6; buf[1] = 0xd7; ret = 2; break; } - break; - case 0x30: - if (wc >= 0x3005 && wc <= 0x3007) { - buf[0] = 0xc6; buf[1] = wc - 0x2f25; ret = 2; - break; - } - if (wc >= 0x3038 && wc <= 0x303a) { - buf[0] = 0xa2; buf[1] = wc - 0x2f6c; ret = 2; - break; - } - if (wc >= 0x3041 && wc <= 0x3093) { - if (wc < 0x3059) { - buf[0] = 0xc6; buf[1] = wc - 0x2f5a; - } else { - buf[0] = 0xc7; buf[1] = wc - 0x3019; - } - ret = 2; - break; - } - if (wc == 0x309d) { buf[0] = 0xc6; buf[1] = 0xdc; ret = 2; break; } - if (wc == 0x309e) { buf[0] = 0xc6; buf[1] = 0xdd; ret = 2; break; } - if (wc >= 0x30a1 && wc <= 0x30f6) { - buf[0] = 0xc7; buf[1] = wc - (wc < 0x30a5 ? 0x3026 : 0x3004); ret = 2; - break; - } - if (wc == 0x30fc) { buf[0] = 0xc6; buf[1] = 0xe3; ret = 2; break; } - if (wc == 0x30fd) { buf[0] = 0xc6; buf[1] = 0xda; ret = 2; break; } - if (wc == 0x30fe) { buf[0] = 0xc6; buf[1] = 0xdb; ret = 2; break; } - break; - case 0x53: - if (wc == 0x5344) - return RET_ILUNI; - break; - case 0x58: - if (wc == 0x58bb) { buf[0] = 0xf9; buf[1] = 0xd9; ret = 2; break; } - break; - case 0x5a: - if (wc == 0x5afa) { buf[0] = 0xf9; buf[1] = 0xdc; ret = 2; break; } - break; - case 0x5f: - if (wc == 0x5f5e) { buf[0] = 0xc2; buf[1] = 0x55; ret = 2; break; } - if (wc == 0x5f5d) - return RET_ILUNI; - break; - case 0x60: - if (wc == 0x6052) { buf[0] = 0xf9; buf[1] = 0xda; ret = 2; break; } - break; - case 0x78: - if (wc == 0x7881) { buf[0] = 0xf9; buf[1] = 0xd6; ret = 2; break; } - break; - case 0x7c: - if (wc == 0x7ca7) { buf[0] = 0xf9; buf[1] = 0xdb; ret = 2; break; } - break; - case 0x88: - if (wc == 0x88cf) { buf[0] = 0xf9; buf[1] = 0xd8; ret = 2; break; } - break; - case 0x92: - if (wc == 0x92b9) { buf[0] = 0xf9; buf[1] = 0xd7; ret = 2; break; } - break; - case 0xe0: case 0xe1: case 0xe2: case 0xe3: case 0xe4: case 0xe5: - case 0xe6: case 0xe7: case 0xe8: case 0xe9: case 0xea: case 0xeb: - case 0xec: case 0xed: case 0xee: case 0xef: case 0xf0: case 0xf1: - case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf6: - { - unsigned int i = wc - 0xe000; - if (i < 5809) { - unsigned int c1 = i / 157; - unsigned int c2 = i % 157; - buf[0] = c1 + (c1 < 5 ? 0xfa : c1 < 24 ? 0x89 : 0x69); - buf[1] = c2 + (c2 < 0x3f ? 0x40 : 0x62); - ret = 2; - break; - } - } - break; - case 0xfe: - if (wc == 0xfe51) { buf[0] = 0xa1; buf[1] = 0x4e; ret = 2; break; } - if (wc == 0xfe68) { buf[0] = 0xa2; buf[1] = 0x42; ret = 2; break; } - break; - case 0xff: - if (wc == 0xff0f) { buf[0] = 0xa1; buf[1] = 0xfe; ret = 2; break; } - if (wc == 0xff3b) { buf[0] = 0xc6; buf[1] = 0xe4; ret = 2; break; } - if (wc == 0xff3c) { buf[0] = 0xa2; buf[1] = 0x40; ret = 2; break; } - if (wc == 0xff3d) { buf[0] = 0xc6; buf[1] = 0xe5; ret = 2; break; } - if (wc == 0xff3e) { buf[0] = 0xc6; buf[1] = 0xd9; ret = 2; break; } - if (wc == 0xff5e) { buf[0] = 0xa1; buf[1] = 0xe3; ret = 2; break; } - if (wc == 0xffe0) { buf[0] = 0xa2; buf[1] = 0x46; ret = 2; break; } - if (wc == 0xffe1) { buf[0] = 0xa2; buf[1] = 0x47; ret = 2; break; } - if (wc == 0xffe3) { buf[0] = 0xa1; buf[1] = 0xc3; ret = 2; break; } - if (wc == 0xffe5) { buf[0] = 0xa2; buf[1] = 0x44; ret = 2; break; } - if (wc == 0xff64) - return RET_ILUNI; - break; - } - if (ret == RET_ILUNI) - ret = big5_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]; - r[1] = buf[1]; - return 2; - } - - return RET_ILUNI; -} diff --git a/lib/big5hkscs1999.h b/lib/big5hkscs1999.h deleted file mode 100644 index ad38d1de..00000000 --- a/lib/big5hkscs1999.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) 1999-2002, 2006, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * BIG5-HKSCS:1999 - */ - -/* - * BIG5-HKSCS:1999 can be downloaded from - * http://www.info.gov.hk/digital21/eng/hkscs/download.html - * http://www.info.gov.hk/digital21/eng/hkscs/index.html - * - * It extends BIG5 (without the rows 0xC6..0xC7) through the ranges - * - * 0x{88..8D}{40..7E,A1..FE} 641 characters - * 0x{8E..A0}{40..7E,A1..FE} 2898 characters - * 0x{C6..C8}{40..7E,A1..FE} 359 characters - * 0xF9{D6..FE} 41 characters - * 0x{FA..FE}{40..7E,A1..FE} 763 characters - * - * Note that some HKSCS characters are not contained in Unicode 3.2 - * and are therefore best represented as sequences of Unicode characters: - * 0x8862 U+00CA U+0304 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND MACRON - * 0x8864 U+00CA U+030C LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND CARON - * 0x88A3 U+00EA U+0304 LATIN SMALL LETTER E WITH CIRCUMFLEX AND MACRON - * 0x88A5 U+00EA U+030C LATIN SMALL LETTER E WITH CIRCUMFLEX AND CARON - */ - -#include "hkscs1999.h" -#include "flushwc.h" - -static int -big5hkscs1999_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - ucs4_t last_wc = conv->istate; - if (last_wc) { - /* Output the buffered character. */ - conv->istate = 0; - *pwc = last_wc; - return 0; /* Don't advance the input pointer. */ - } else { - unsigned char c = *s; - /* Code set 0 (ASCII) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (BIG5 extended) */ - if (c >= 0xa1 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) { - if (!((c == 0xc6 && c2 >= 0xa1) || c == 0xc7)) { - int ret = big5_mbtowc(conv,pwc,s,2); - if (ret != RET_ILSEQ) - return ret; - } - } - } - } - { - int ret = hkscs1999_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - } - if (c == 0x88) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c2 == 0x62 || c2 == 0x64 || c2 == 0xa3 || c2 == 0xa5) { - /* It's a composed character. */ - ucs4_t wc1 = ((c2 >> 3) << 2) + 0x009a; /* = 0x00ca or 0x00ea */ - ucs4_t wc2 = ((c2 & 6) << 2) + 0x02fc; /* = 0x0304 or 0x030c */ - /* We cannot output two Unicode characters at once. So, - output the first character and buffer the second one. */ - *pwc = wc1; - conv->istate = wc2; - return 2; - } - } - } - return RET_ILSEQ; - } -} - -#define big5hkscs1999_flushwc normal_flushwc - -static int -big5hkscs1999_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - int count = 0; - unsigned char last = conv->ostate; - - if (last) { - /* last is = 0x66 or = 0xa7. */ - if (wc == 0x0304 || wc == 0x030c) { - /* Output the combined character. */ - if (n >= 2) { - r[0] = 0x88; - r[1] = last + ((wc & 24) >> 2) - 4; /* = 0x62 or 0x64 or 0xa3 or 0xa5 */ - conv->ostate = 0; - return 2; - } else - return RET_TOOSMALL; - } - - /* Output the buffered character. */ - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x88; - r[1] = last; - r += 2; - count = 2; - } - - /* Code set 0 (ASCII) */ - if (wc < 0x0080) { - /* Plain ASCII character. */ - if (n > count) { - r[0] = (unsigned char) wc; - conv->ostate = 0; - return count+1; - } else - return RET_TOOSMALL; - } else { - unsigned char buf[2]; - int ret; - - /* Code set 1 (BIG5 extended) */ - ret = big5_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (!((buf[0] == 0xc6 && buf[1] >= 0xa1) || buf[0] == 0xc7)) { - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - } - ret = hkscs1999_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if ((wc & ~0x0020) == 0x00ca) { - /* A possible first character of a multi-character sequence. We have to - buffer it. */ - if (!(buf[0] == 0x88 && (buf[1] == 0x66 || buf[1] == 0xa7))) abort(); - conv->ostate = buf[1]; /* = 0x66 or = 0xa7 */ - return count+0; - } - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - return RET_ILUNI; - } -} - -static int -big5hkscs1999_reset (conv_t conv, unsigned char *r, size_t n) -{ - unsigned char last = conv->ostate; - - if (last) { - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x88; - r[1] = last; - /* conv->ostate = 0; will be done by the caller */ - return 2; - } else - return 0; -} diff --git a/lib/big5hkscs2001.h b/lib/big5hkscs2001.h deleted file mode 100644 index ffd57199..00000000 --- a/lib/big5hkscs2001.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (C) 1999-2002, 2006, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * BIG5-HKSCS:2001 - */ - -/* - * BIG5-HKSCS:2001 can be downloaded from - * http://www.info.gov.hk/digital21/eng/hkscs/download.html - * http://www.info.gov.hk/digital21/eng/hkscs/index.html - * - * It extends BIG5-HKSCS:1999 through 116 characters. - * - * It extends BIG5 (without the rows 0xC6..0xC7) through the ranges - * - * 0x{88..8D}{40..7E,A1..FE} 757 characters - * 0x{8E..A0}{40..7E,A1..FE} 2898 characters - * 0x{C6..C8}{40..7E,A1..FE} 359 characters - * 0xF9{D6..FE} 41 characters - * 0x{FA..FE}{40..7E,A1..FE} 763 characters - * - * Note that some HKSCS characters are not contained in Unicode 3.2 - * and are therefore best represented as sequences of Unicode characters: - * 0x8862 U+00CA U+0304 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND MACRON - * 0x8864 U+00CA U+030C LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND CARON - * 0x88A3 U+00EA U+0304 LATIN SMALL LETTER E WITH CIRCUMFLEX AND MACRON - * 0x88A5 U+00EA U+030C LATIN SMALL LETTER E WITH CIRCUMFLEX AND CARON - */ - -#include "hkscs2001.h" -#include "flushwc.h" - -static int -big5hkscs2001_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - ucs4_t last_wc = conv->istate; - if (last_wc) { - /* Output the buffered character. */ - conv->istate = 0; - *pwc = last_wc; - return 0; /* Don't advance the input pointer. */ - } else { - unsigned char c = *s; - /* Code set 0 (ASCII) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (BIG5 extended) */ - if (c >= 0xa1 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) { - if (!((c == 0xc6 && c2 >= 0xa1) || c == 0xc7)) { - int ret = big5_mbtowc(conv,pwc,s,2); - if (ret != RET_ILSEQ) - return ret; - } - } - } - } - { - int ret = hkscs1999_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - } - { - int ret = hkscs2001_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - } - if (c == 0x88) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c2 == 0x62 || c2 == 0x64 || c2 == 0xa3 || c2 == 0xa5) { - /* It's a composed character. */ - ucs4_t wc1 = ((c2 >> 3) << 2) + 0x009a; /* = 0x00ca or 0x00ea */ - ucs4_t wc2 = ((c2 & 6) << 2) + 0x02fc; /* = 0x0304 or 0x030c */ - /* We cannot output two Unicode characters at once. So, - output the first character and buffer the second one. */ - *pwc = wc1; - conv->istate = wc2; - return 2; - } - } - } - return RET_ILSEQ; - } -} - -#define big5hkscs2001_flushwc normal_flushwc - -static int -big5hkscs2001_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - int count = 0; - unsigned char last = conv->ostate; - - if (last) { - /* last is = 0x66 or = 0xa7. */ - if (wc == 0x0304 || wc == 0x030c) { - /* Output the combined character. */ - if (n >= 2) { - r[0] = 0x88; - r[1] = last + ((wc & 24) >> 2) - 4; /* = 0x62 or 0x64 or 0xa3 or 0xa5 */ - conv->ostate = 0; - return 2; - } else - return RET_TOOSMALL; - } - - /* Output the buffered character. */ - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x88; - r[1] = last; - r += 2; - count = 2; - } - - /* Code set 0 (ASCII) */ - if (wc < 0x0080) { - /* Plain ASCII character. */ - if (n > count) { - r[0] = (unsigned char) wc; - conv->ostate = 0; - return count+1; - } else - return RET_TOOSMALL; - } else { - unsigned char buf[2]; - int ret; - - /* Code set 1 (BIG5 extended) */ - ret = big5_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (!((buf[0] == 0xc6 && buf[1] >= 0xa1) || buf[0] == 0xc7)) { - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - } - ret = hkscs1999_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if ((wc & ~0x0020) == 0x00ca) { - /* A possible first character of a multi-character sequence. We have to - buffer it. */ - if (!(buf[0] == 0x88 && (buf[1] == 0x66 || buf[1] == 0xa7))) abort(); - conv->ostate = buf[1]; /* = 0x66 or = 0xa7 */ - return count+0; - } - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - ret = hkscs2001_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - return RET_ILUNI; - } -} - -static int -big5hkscs2001_reset (conv_t conv, unsigned char *r, size_t n) -{ - unsigned char last = conv->ostate; - - if (last) { - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x88; - r[1] = last; - /* conv->ostate = 0; will be done by the caller */ - return 2; - } else - return 0; -} diff --git a/lib/big5hkscs2004.h b/lib/big5hkscs2004.h deleted file mode 100644 index 412b508f..00000000 --- a/lib/big5hkscs2004.h +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (C) 1999-2002, 2006, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * BIG5-HKSCS:2004 - */ - -/* - * BIG5-HKSCS:2004 can be downloaded from - * http://www.info.gov.hk/digital21/eng/hkscs/download.html - * http://www.info.gov.hk/digital21/eng/hkscs/index.html - * - * It extends BIG5-HKSCS:2001 through 123 characters. - * - * It extends BIG5 (without the rows 0xC6..0xC7) through the ranges - * - * 0x{87..8D}{40..7E,A1..FE} 880 characters - * 0x{8E..A0}{40..7E,A1..FE} 2898 characters - * 0x{C6..C8}{40..7E,A1..FE} 359 characters - * 0xF9{D6..FE} 41 characters - * 0x{FA..FE}{40..7E,A1..FE} 763 characters - * - * Note that some HKSCS characters are not contained in Unicode 3.2 - * and are therefore best represented as sequences of Unicode characters: - * 0x8862 U+00CA U+0304 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND MACRON - * 0x8864 U+00CA U+030C LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND CARON - * 0x88A3 U+00EA U+0304 LATIN SMALL LETTER E WITH CIRCUMFLEX AND MACRON - * 0x88A5 U+00EA U+030C LATIN SMALL LETTER E WITH CIRCUMFLEX AND CARON - */ - -#include "hkscs2004.h" -#include "flushwc.h" - -static int -big5hkscs2004_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - ucs4_t last_wc = conv->istate; - if (last_wc) { - /* Output the buffered character. */ - conv->istate = 0; - *pwc = last_wc; - return 0; /* Don't advance the input pointer. */ - } else { - unsigned char c = *s; - /* Code set 0 (ASCII) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (BIG5 extended) */ - if (c >= 0xa1 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) { - if (!((c == 0xc6 && c2 >= 0xa1) || c == 0xc7)) { - int ret = big5_mbtowc(conv,pwc,s,2); - if (ret != RET_ILSEQ) - return ret; - } - } - } - } - { - int ret = hkscs1999_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - } - { - int ret = hkscs2001_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - } - { - int ret = hkscs2004_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - } - if (c == 0x88) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c2 == 0x62 || c2 == 0x64 || c2 == 0xa3 || c2 == 0xa5) { - /* It's a composed character. */ - ucs4_t wc1 = ((c2 >> 3) << 2) + 0x009a; /* = 0x00ca or 0x00ea */ - ucs4_t wc2 = ((c2 & 6) << 2) + 0x02fc; /* = 0x0304 or 0x030c */ - /* We cannot output two Unicode characters at once. So, - output the first character and buffer the second one. */ - *pwc = wc1; - conv->istate = wc2; - return 2; - } - } - } - return RET_ILSEQ; - } -} - -#define big5hkscs2004_flushwc normal_flushwc - -static int -big5hkscs2004_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - int count = 0; - unsigned char last = conv->ostate; - - if (last) { - /* last is = 0x66 or = 0xa7. */ - if (wc == 0x0304 || wc == 0x030c) { - /* Output the combined character. */ - if (n >= 2) { - r[0] = 0x88; - r[1] = last + ((wc & 24) >> 2) - 4; /* = 0x62 or 0x64 or 0xa3 or 0xa5 */ - conv->ostate = 0; - return 2; - } else - return RET_TOOSMALL; - } - - /* Output the buffered character. */ - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x88; - r[1] = last; - r += 2; - count = 2; - } - - /* Code set 0 (ASCII) */ - if (wc < 0x0080) { - /* Plain ASCII character. */ - if (n > count) { - r[0] = (unsigned char) wc; - conv->ostate = 0; - return count+1; - } else - return RET_TOOSMALL; - } else { - unsigned char buf[2]; - int ret; - - /* Code set 1 (BIG5 extended) */ - ret = big5_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (!((buf[0] == 0xc6 && buf[1] >= 0xa1) || buf[0] == 0xc7)) { - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - } - ret = hkscs1999_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if ((wc & ~0x0020) == 0x00ca) { - /* A possible first character of a multi-character sequence. We have to - buffer it. */ - if (!(buf[0] == 0x88 && (buf[1] == 0x66 || buf[1] == 0xa7))) abort(); - conv->ostate = buf[1]; /* = 0x66 or = 0xa7 */ - return count+0; - } - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - ret = hkscs2001_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - ret = hkscs2004_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - return RET_ILUNI; - } -} - -static int -big5hkscs2004_reset (conv_t conv, unsigned char *r, size_t n) -{ - unsigned char last = conv->ostate; - - if (last) { - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x88; - r[1] = last; - /* conv->ostate = 0; will be done by the caller */ - return 2; - } else - return 0; -} diff --git a/lib/big5hkscs2008.h b/lib/big5hkscs2008.h deleted file mode 100644 index 79184a48..00000000 --- a/lib/big5hkscs2008.h +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (C) 1999-2002, 2006, 2010 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * BIG5-HKSCS:2008 - */ - -/* - * BIG5-HKSCS:2008 can be downloaded from - * http://www.ogcio.gov.hk/ccli/eng/hkscs/download.html - * http://www.ogcio.gov.hk/ccli/eng/hkscs/introduction.html - * - * It extends BIG5-HKSCS:2004 through 68 characters. - * - * It extends BIG5 (without the rows 0xC6..0xC7) through the ranges - * - * 0x{87..8D}{40..7E,A1..FE} 880 characters - * 0x{8E..A0}{40..7E,A1..FE} 2898 characters - * 0x{C6..C8}{40..7E,A1..FE} 359 characters - * 0xF9{D6..FE} 41 characters - * 0x{FA..FE}{40..7E,A1..FE} 763 characters - * - * Note that some HKSCS characters are not contained in Unicode 3.2 - * and are therefore best represented as sequences of Unicode characters: - * 0x8862 U+00CA U+0304 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND MACRON - * 0x8864 U+00CA U+030C LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND CARON - * 0x88A3 U+00EA U+0304 LATIN SMALL LETTER E WITH CIRCUMFLEX AND MACRON - * 0x88A5 U+00EA U+030C LATIN SMALL LETTER E WITH CIRCUMFLEX AND CARON - */ - -#include "hkscs2008.h" -#include "flushwc.h" - -static int -big5hkscs2008_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - ucs4_t last_wc = conv->istate; - if (last_wc) { - /* Output the buffered character. */ - conv->istate = 0; - *pwc = last_wc; - return 0; /* Don't advance the input pointer. */ - } else { - unsigned char c = *s; - /* Code set 0 (ASCII) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (BIG5 extended) */ - if (c >= 0xa1 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) { - if (!((c == 0xc6 && c2 >= 0xa1) || c == 0xc7)) { - int ret = big5_mbtowc(conv,pwc,s,2); - if (ret != RET_ILSEQ) - return ret; - } - } - } - } - { - int ret = hkscs1999_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - } - { - int ret = hkscs2001_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - } - { - int ret = hkscs2004_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - } - { - int ret = hkscs2008_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - } - if (c == 0x88) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c2 == 0x62 || c2 == 0x64 || c2 == 0xa3 || c2 == 0xa5) { - /* It's a composed character. */ - ucs4_t wc1 = ((c2 >> 3) << 2) + 0x009a; /* = 0x00ca or 0x00ea */ - ucs4_t wc2 = ((c2 & 6) << 2) + 0x02fc; /* = 0x0304 or 0x030c */ - /* We cannot output two Unicode characters at once. So, - output the first character and buffer the second one. */ - *pwc = wc1; - conv->istate = wc2; - return 2; - } - } - } - return RET_ILSEQ; - } -} - -#define big5hkscs2008_flushwc normal_flushwc - -static int -big5hkscs2008_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - int count = 0; - unsigned char last = conv->ostate; - - if (last) { - /* last is = 0x66 or = 0xa7. */ - if (wc == 0x0304 || wc == 0x030c) { - /* Output the combined character. */ - if (n >= 2) { - r[0] = 0x88; - r[1] = last + ((wc & 24) >> 2) - 4; /* = 0x62 or 0x64 or 0xa3 or 0xa5 */ - conv->ostate = 0; - return 2; - } else - return RET_TOOSMALL; - } - - /* Output the buffered character. */ - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x88; - r[1] = last; - r += 2; - count = 2; - } - - /* Code set 0 (ASCII) */ - if (wc < 0x0080) { - /* Plain ASCII character. */ - if (n > count) { - r[0] = (unsigned char) wc; - conv->ostate = 0; - return count+1; - } else - return RET_TOOSMALL; - } else { - unsigned char buf[2]; - int ret; - - /* Code set 1 (BIG5 extended) */ - ret = big5_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (!((buf[0] == 0xc6 && buf[1] >= 0xa1) || buf[0] == 0xc7)) { - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - } - ret = hkscs1999_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if ((wc & ~0x0020) == 0x00ca) { - /* A possible first character of a multi-character sequence. We have to - buffer it. */ - if (!(buf[0] == 0x88 && (buf[1] == 0x66 || buf[1] == 0xa7))) abort(); - conv->ostate = buf[1]; /* = 0x66 or = 0xa7 */ - return count+0; - } - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - ret = hkscs2001_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - ret = hkscs2004_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - ret = hkscs2008_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n >= count+2) { - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - return RET_ILUNI; - } -} - -static int -big5hkscs2008_reset (conv_t conv, unsigned char *r, size_t n) -{ - unsigned char last = conv->ostate; - - if (last) { - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x88; - r[1] = last; - /* conv->ostate = 0; will be done by the caller */ - return 2; - } else - return 0; -} diff --git a/lib/c99.h b/lib/c99.h deleted file mode 100644 index fda70a91..00000000 --- a/lib/c99.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * C99 - * This is ASCII with \uXXXX and \UXXXXXXXX escape sequences, denoting Unicode - * characters. See ISO/IEC 9899:1999, section 6.4.3. - * The treatment of control characters in the range U+0080..U+009F is not - * specified; we pass them through unmodified. - */ - -static int -c99_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c; - ucs4_t wc; - int i; - - c = s[0]; - if (c < 0xa0) { - if (c != '\\') { - *pwc = c; - return 1; - } - if (n < 2) - return RET_TOOFEW(0); - c = s[1]; - if (c == 'u') { - wc = 0; - for (i = 2; i < 6; i++) { - if (n <= i) - return RET_TOOFEW(0); - c = s[i]; - if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'Z') - c -= 'A'-10; - else if (c >= 'a' && c <= 'z') - c -= 'a'-10; - else - goto simply_backslash; - wc |= (ucs4_t) c << (4 * (5-i)); - } - if ((wc >= 0x00a0 && !(wc >= 0xd800 && wc < 0xe000)) - || wc == 0x0024 || wc == 0x0040 || wc == 0x0060) { - *pwc = wc; - return 6; - } - } else if (c == 'U') { - wc = 0; - for (i = 2; i < 10; i++) { - if (n <= i) - return RET_TOOFEW(0); - c = s[i]; - if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'Z') - c -= 'A'-10; - else if (c >= 'a' && c <= 'z') - c -= 'a'-10; - else - goto simply_backslash; - wc |= (ucs4_t) c << (4 * (9-i)); - } - if ((wc >= 0x00a0 && !(wc >= 0xd800 && wc < 0xe000)) - || wc == 0x0024 || wc == 0x0040 || wc == 0x0060) { - *pwc = wc; - return 10; - } - } else - goto simply_backslash; - } - return RET_ILSEQ; -simply_backslash: - *pwc = '\\'; - return 1; -} - -static int -c99_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc < 0xa0) { - *r = wc; - return 1; - } else { - int result; - unsigned char u; - if (wc < 0x10000) { - result = 6; - u = 'u'; - } else { - result = 10; - u = 'U'; - } - if (n >= result) { - int count; - r[0] = '\\'; - r[1] = u; - r += 2; - for (count = result-3; count >= 0; count--) { - unsigned int i = (wc >> (4*count)) & 0x0f; - *r++ = (i < 10 ? '0'+i : 'a'-10+i); - } - return result; - } else - return RET_TOOSMALL; - } -} diff --git a/lib/ces_big5.h b/lib/ces_big5.h deleted file mode 100644 index 8586f0b7..00000000 --- a/lib/ces_big5.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * BIG-5 - */ - -static int -ces_big5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - /* Code set 0 (ASCII) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (BIG5) */ - if (c >= 0xa1 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) - return big5_mbtowc(conv,pwc,s,2); - else - return RET_ILSEQ; - } - } - return RET_ILSEQ; -} - -static int -ces_big5_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[2]; - int ret; - - /* Code set 0 (ASCII) */ - ret = ascii_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - /* Code set 1 (BIG5) */ - ret = big5_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]; - r[1] = buf[1]; - return 2; - } - - return RET_ILUNI; -} diff --git a/lib/ces_gbk.h b/lib/ces_gbk.h deleted file mode 100644 index bc987b99..00000000 --- a/lib/ces_gbk.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2005, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * GBK - */ - -static int -ces_gbk_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - - /* Code set 0 (ASCII or GB 1988-89) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (GBK) */ - if (c >= 0x81 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - return gbk_mbtowc(conv,pwc,s,2); - } - return RET_ILSEQ; -} - -static int -ces_gbk_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[2]; - int ret; - - /* Code set 0 (ASCII or GB 1988-89) */ - ret = ascii_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - /* Code set 1 (GBK) */ - ret = gbk_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]; - r[1] = buf[1]; - return 2; - } - - return RET_ILUNI; -} diff --git a/lib/cns11643_4.h b/lib/cns11643_4.h deleted file mode 100644 index e3929ae2..00000000 --- a/lib/cns11643_4.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * CNS 11643-1992 plane 4 - */ - -/* - * The table has been split into two parts. Each part's entries fit it 16 bits. - * But the combined table would need 17 bits per entry. - */ -#include "cns11643_4a.h" -#include "cns11643_4b.h" - -static int -cns11643_4_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c1 = s[0]; - if ((c1 >= 0x21 && c1 <= 0x6e)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 < 0x7f) { - unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); - ucs4_t wc = 0xfffd; - unsigned short swc; - { - if (i < 2914) - swc = cns11643_4a_2uni_page21[i], - wc = cns11643_4a_2uni_upages[swc>>8] | (swc & 0xff); - else if (i < 7298) - swc = cns11643_4b_2uni_page40[i-2914], - wc = cns11643_4b_2uni_upages[swc>>8] | (swc & 0xff); - } - if (wc != 0xfffd) { - *pwc = wc; - return 2; - } - } - return RET_ILSEQ; - } - return RET_TOOFEW(0); - } - return RET_ILSEQ; -} diff --git a/lib/codepage_to_ei.h b/lib/codepage_to_ei.h new file mode 100644 index 00000000..598ff72c --- /dev/null +++ b/lib/codepage_to_ei.h @@ -0,0 +1,24 @@ +/** + * @file codepage_to_ei.h + * @brief A mapping of codepages to encoding indexes. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ + +#ifndef _CODEPAGE_TO_EI_H_ +#define _CODEPAGE_TO_EI_H_ + +#include "encoding_indexes.h" // IWYU pragma: keep + +#define DEFENCODING(xxx_names, xxx, xxx_index, xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2) +#define DEFCODEPAGE(codepage, xxx) [codepage] = ei_##xxx + 1, +#define DEFINDEX(alias, name) + +static const int codepage_to_eindex[] = { +#include "encodings.h.snippet" +}; + +#undef DEFINDEX +#undef DEFENCODING +#undef DEFCODEPAGE + +#endif /* _CODEPAGE_TO_EI_H_ */ diff --git a/lib/converters.h b/lib/converters.h index 1fcd6e01..fb4e3380 100644 --- a/lib/converters.h +++ b/lib/converters.h @@ -1,5 +1,10 @@ +/** + * @file converters.h + * @brief Include all the converters. + * @copyright Copyright (C) 1999-2002, 2004-2011, 2016, 2022-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2004-2011, 2016, 2022-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,376 +18,249 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* This file defines all the converters. */ - - -/* Our own notion of wide character, as UCS-4, according to ISO-10646-1. */ -typedef unsigned int ucs4_t; - -/* State used by a conversion. 0 denotes the initial state. */ -typedef unsigned int state_t; - -/* iconv_t is an opaque type. This is the real iconv_t type. */ -typedef struct conv_struct * conv_t; - -/* - * Data type for conversion multibyte -> unicode - */ -struct mbtowc_funcs { - int (*xxx_mbtowc) (conv_t conv, ucs4_t *pwc, unsigned char const *s, size_t n); - /* - * int xxx_mbtowc (conv_t conv, ucs4_t *pwc, unsigned char const *s, size_t n) - * converts the byte sequence starting at s to a wide character. Up to n bytes - * are available at s. n is >= 1. - * Result is number of bytes consumed (if a wide character was read), - * or -1 if invalid, or -2 if n too small, - * or RET_SHIFT_ILSEQ(number of bytes consumed) if invalid input after a shift - * sequence was read, - * or RET_TOOFEW(number of bytes consumed) if only a shift sequence was read. - */ - int (*xxx_flushwc) (conv_t conv, ucs4_t *pwc); - /* - * int xxx_flushwc (conv_t conv, ucs4_t *pwc) - * returns to the initial state and stores the pending wide character, if any. - * Result is 1 (if a wide character was read) or 0 if none was pending. - */ -}; - -/* Return code if invalid input after a shift sequence of n bytes was read. - (xxx_mbtowc) */ -#define RET_SHIFT_ILSEQ(n) (-1-2*(n)) -/* Return code if invalid. (xxx_mbtowc) */ -#define RET_ILSEQ RET_SHIFT_ILSEQ(0) -/* Return code if only a shift sequence of n bytes was read. (xxx_mbtowc) */ -#define RET_TOOFEW(n) (-2-2*(n)) -/* Retrieve the n from the encoded RET_... value. */ -#define DECODE_SHIFT_ILSEQ(r) ((unsigned int)(RET_SHIFT_ILSEQ(0) - (r)) / 2) -#define DECODE_TOOFEW(r) ((unsigned int)(RET_TOOFEW(0) - (r)) / 2) -/* Maximum value of n that may be used as argument to RET_SHIFT_ILSEQ or RET_TOOFEW. */ -#define RET_COUNT_MAX ((INT_MAX / 2) - 1) - -/* - * Data type for conversion unicode -> multibyte - */ -struct wctomb_funcs { - int (*xxx_wctomb) (conv_t conv, unsigned char *r, ucs4_t wc, size_t n); - /* - * int xxx_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) - * converts the wide character wc to the character set xxx, and stores the - * result beginning at r. Up to n bytes may be written at r. n is >= 1. - * Result is number of bytes written, or -1 if invalid, or -2 if n too small. - */ - int (*xxx_reset) (conv_t conv, unsigned char *r, size_t n); - /* - * int xxx_reset (conv_t conv, unsigned char *r, size_t n) - * stores a shift sequences returning to the initial state beginning at r. - * Up to n bytes may be written at r. n is >= 0. - * Result is number of bytes written, or -2 if n too small. - */ -}; - -/* Return code if invalid. (xxx_wctomb) */ -#define RET_ILUNI -1 -/* Return code if output buffer is too small. (xxx_wctomb, xxx_reset) */ -#define RET_TOOSMALL -2 - -/* - * Contents of a conversion descriptor. - */ -struct conv_struct { - struct loop_funcs lfuncs; - /* Input (conversion multibyte -> unicode) */ - int iindex; - struct mbtowc_funcs ifuncs; - unsigned int isurface; - state_t istate; - /* Output (conversion unicode -> multibyte) */ - int oindex; - struct wctomb_funcs ofuncs; - int oflags; - unsigned int osurface; - state_t ostate; - /* Operation flags */ - int discard_ilseq; - struct iconv_fallbacks fallbacks; - struct iconv_hooks hooks; -}; - -/* - * Include all the converters. - */ - -#include "ascii.h" - -/* General multi-byte encodings */ -#include "utf8.h" -#include "ucs2.h" -#include "ucs2be.h" -#include "ucs2le.h" -#include "ucs4.h" -#include "ucs4be.h" -#include "ucs4le.h" -#include "utf16.h" -#include "utf16be.h" -#include "utf16le.h" -#include "utf32.h" -#include "utf32be.h" -#include "utf32le.h" -#include "utf7.h" -#include "ucs2internal.h" -#include "ucs2swapped.h" -#include "ucs4internal.h" -#include "ucs4swapped.h" -#include "c99.h" -#include "java.h" - -/* 8-bit encodings */ -#include "iso8859_1.h" -#include "iso8859_2.h" -#include "iso8859_3.h" -#include "iso8859_4.h" -#include "iso8859_5.h" -#include "iso8859_6.h" -#include "iso8859_7.h" -#include "iso8859_8.h" -#include "iso8859_9.h" -#include "iso8859_10.h" -#include "iso8859_11.h" -#include "iso8859_13.h" -#include "iso8859_14.h" -#include "iso8859_15.h" -#include "iso8859_16.h" -#include "koi8_r.h" -#include "koi8_u.h" -#include "koi8_ru.h" -#include "cp1250.h" -#include "cp1251.h" -#include "cp1252.h" -#include "cp1253.h" -#include "cp1254.h" -#include "cp1255.h" -#include "cp1256.h" -#include "cp1257.h" -#include "cp1258.h" -#include "cp850.h" -#include "cp862.h" -#include "cp866.h" -#include "cp1131.h" -#include "mac_roman.h" -#include "mac_centraleurope.h" -#include "mac_iceland.h" -#include "mac_croatian.h" -#include "mac_romania.h" -#include "mac_cyrillic.h" -#include "mac_ukraine.h" -#include "mac_greek.h" -#include "mac_turkish.h" -#include "mac_hebrew.h" -#include "mac_arabic.h" -#include "mac_thai.h" -#include "hp_roman8.h" -#include "nextstep.h" -#include "armscii_8.h" -#include "georgian_academy.h" -#include "georgian_ps.h" -#include "koi8_t.h" -#include "pt154.h" -#include "rk1048.h" -#include "mulelao.h" -#include "cp1133.h" -#include "tis620.h" -#include "cp874.h" -#include "viscii.h" -#include "tcvn.h" - -/* CJK character sets [CCS = coded character set] [CJKV.INF chapter 3] */ - -typedef struct { - unsigned short indx; /* index into big table */ - unsigned short used; /* bitmask of used entries */ -} Summary16; - -#include "iso646_jp.h" -#include "jisx0201.h" -#include "jisx0208.h" -#include "jisx0212.h" - -#include "iso646_cn.h" -#include "gb2312.h" -#include "isoir165.h" -/*#include "gb12345.h"*/ -#include "gbk.h" -#include "cns11643.h" -#include "big5.h" - -#include "ksc5601.h" -#include "johab_hangul.h" - -/* CJK encodings [CES = character encoding scheme] [CJKV.INF chapter 4] */ - -#include "euc_jp.h" -#include "sjis.h" -#include "cp932.h" -#include "iso2022_jp.h" -#include "iso2022_jp1.h" -#include "iso2022_jp2.h" -#include "iso2022_jpms.h" - -#include "euc_cn.h" -#include "ces_gbk.h" -#include "cp936.h" -#include "gb18030_2005.h" -#include "gb18030_2022.h" -#include "iso2022_cn.h" -#include "iso2022_cnext.h" -#include "hz.h" -#include "euc_tw.h" -#include "ces_big5.h" -#include "cp950.h" -#include "big5hkscs1999.h" -#include "big5hkscs2001.h" -#include "big5hkscs2004.h" -#include "big5hkscs2008.h" - -#include "euc_kr.h" -#include "cp949.h" -#include "johab.h" -#include "iso2022_kr.h" - -/* Encodings used by system dependent locales. */ - -#ifdef USE_AIX -#include "cp856.h" -#include "cp922.h" -#include "cp943.h" -#include "cp1046.h" -#include "cp1124.h" -#include "cp1129.h" -#include "cp1161.h" -#include "cp1162.h" -#include "cp1163.h" -#endif - -#ifdef USE_OSF1 -#include "dec_kanji.h" -#include "dec_hanyu.h" -#endif - -#ifdef USE_DOS -#include "cp437.h" -#include "cp737.h" -#include "cp775.h" -#include "cp852.h" -#include "cp853.h" -#include "cp855.h" -#include "cp857.h" -#include "cp858.h" -#include "cp860.h" -#include "cp861.h" -#include "cp863.h" -#include "cp864.h" -#include "cp865.h" -#include "cp869.h" -#include "cp1125.h" -#endif - -#ifdef USE_ZOS +#ifndef _CONVERTERS_H_ +#define _CONVERTERS_H_ + +#include "reiconv_defines.h" // IWYU pragma: keep + +#pragma region ASCII +#include "converters/ascii.h" // IWYU pragma: keep +#pragma endregion + +#pragma region General multi-byte encodings +#include "converters/c99.h" // IWYU pragma: keep +#include "converters/java.h" // IWYU pragma: keep +#include "converters/ucs2.h" // IWYU pragma: keep +#include "converters/ucs2be.h" // IWYU pragma: keep +#include "converters/ucs2internal.h" // IWYU pragma: keep +#include "converters/ucs2le.h" // IWYU pragma: keep +#include "converters/ucs2swapped.h" // IWYU pragma: keep +#include "converters/ucs4.h" // IWYU pragma: keep +#include "converters/ucs4be.h" // IWYU pragma: keep +#include "converters/ucs4internal.h" // IWYU pragma: keep +#include "converters/ucs4le.h" // IWYU pragma: keep +#include "converters/ucs4swapped.h" // IWYU pragma: keep +#include "converters/utf16.h" // IWYU pragma: keep +#include "converters/utf16be.h" // IWYU pragma: keep +#include "converters/utf16le.h" // IWYU pragma: keep +#include "converters/utf32.h" // IWYU pragma: keep +#include "converters/utf32be.h" // IWYU pragma: keep +#include "converters/utf32le.h" // IWYU pragma: keep +#include "converters/utf7.h" // IWYU pragma: keep +#include "converters/utf8.h" // IWYU pragma: keep +#pragma endregion + +#pragma region 8-bit encodings +#include "converters/armscii_8.h" // IWYU pragma: keep +#include "converters/cp1131.h" // IWYU pragma: keep +#include "converters/cp1133.h" // IWYU pragma: keep +#include "converters/cp1250.h" // IWYU pragma: keep +#include "converters/cp1251.h" // IWYU pragma: keep +#include "converters/cp1252.h" // IWYU pragma: keep +#include "converters/cp1253.h" // IWYU pragma: keep +#include "converters/cp1254.h" // IWYU pragma: keep +#include "converters/cp1255.h" // IWYU pragma: keep +#include "converters/cp1256.h" // IWYU pragma: keep +#include "converters/cp1257.h" // IWYU pragma: keep +#include "converters/cp1258.h" // IWYU pragma: keep +#include "converters/cp850.h" // IWYU pragma: keep +#include "converters/cp862.h" // IWYU pragma: keep +#include "converters/cp866.h" // IWYU pragma: keep +#include "converters/cp874.h" // IWYU pragma: keep +#include "converters/georgian_academy.h" // IWYU pragma: keep +#include "converters/georgian_ps.h" // IWYU pragma: keep +#include "converters/hp_roman8.h" // IWYU pragma: keep +#include "converters/iso8859_1.h" // IWYU pragma: keep +#include "converters/iso8859_10.h" // IWYU pragma: keep +#include "converters/iso8859_11.h" // IWYU pragma: keep +#include "converters/iso8859_13.h" // IWYU pragma: keep +#include "converters/iso8859_14.h" // IWYU pragma: keep +#include "converters/iso8859_15.h" // IWYU pragma: keep +#include "converters/iso8859_16.h" // IWYU pragma: keep +#include "converters/iso8859_2.h" // IWYU pragma: keep +#include "converters/iso8859_3.h" // IWYU pragma: keep +#include "converters/iso8859_4.h" // IWYU pragma: keep +#include "converters/iso8859_5.h" // IWYU pragma: keep +#include "converters/iso8859_6.h" // IWYU pragma: keep +#include "converters/iso8859_7.h" // IWYU pragma: keep +#include "converters/iso8859_8.h" // IWYU pragma: keep +#include "converters/iso8859_9.h" // IWYU pragma: keep +#include "converters/koi8_r.h" // IWYU pragma: keep +#include "converters/koi8_ru.h" // IWYU pragma: keep +#include "converters/koi8_t.h" // IWYU pragma: keep +#include "converters/koi8_u.h" // IWYU pragma: keep +#include "converters/mac_arabic.h" // IWYU pragma: keep +#include "converters/mac_centraleurope.h" // IWYU pragma: keep +#include "converters/mac_croatian.h" // IWYU pragma: keep +#include "converters/mac_cyrillic.h" // IWYU pragma: keep +#include "converters/mac_greek.h" // IWYU pragma: keep +#include "converters/mac_hebrew.h" // IWYU pragma: keep +#include "converters/mac_iceland.h" // IWYU pragma: keep +#include "converters/mac_roman.h" // IWYU pragma: keep +#include "converters/mac_romania.h" // IWYU pragma: keep +#include "converters/mac_thai.h" // IWYU pragma: keep +#include "converters/mac_turkish.h" // IWYU pragma: keep +#include "converters/mac_ukraine.h" // IWYU pragma: keep +#include "converters/mulelao.h" // IWYU pragma: keep +#include "converters/nextstep.h" // IWYU pragma: keep +#include "converters/pt154.h" // IWYU pragma: keep +#include "converters/rk1048.h" // IWYU pragma: keep +#include "converters/tcvn.h" // IWYU pragma: keep +#include "converters/tis620.h" // IWYU pragma: keep +#include "converters/viscii.h" // IWYU pragma: keep +#pragma endregion + +#pragma region CJK character sets +#include "converters/iso646_jp.h" // IWYU pragma: keep +#include "converters/jisx0201.h" // IWYU pragma: keep +#include "converters/jisx0208.h" // IWYU pragma: keep +#include "converters/jisx0212.h" // IWYU pragma: keep + +#include "converters/gb2312.h" // IWYU pragma: keep +#include "converters/iso646_cn.h" // IWYU pragma: keep +#include "converters/isoir165.h" // IWYU pragma: keep +/* #include "converters/gb12345.h" // IWYU pragma: keep */ +#include "converters/big5.h" // IWYU pragma: keep +#include "converters/cns11643.h" // IWYU pragma: keep +#include "converters/gbk.h" // IWYU pragma: keep + +#include "converters/johab_hangul.h" // IWYU pragma: keep +#include "converters/ksc5601.h" // IWYU pragma: keep +#pragma endregion + +/* [CES = character encoding scheme] [CJKV.INF chapter 4] */ +#pragma region CJK encodings +#include "converters/cp932.h" // IWYU pragma: keep +#include "converters/euc_jp.h" // IWYU pragma: keep +#include "converters/iso2022_jp.h" // IWYU pragma: keep +#include "converters/iso2022_jp1.h" // IWYU pragma: keep +#include "converters/iso2022_jp2.h" // IWYU pragma: keep +#include "converters/iso2022_jpms.h" // IWYU pragma: keep +#include "converters/sjis.h" // IWYU pragma: keep + +#include "converters/big5hkscs1999.h" // IWYU pragma: keep +#include "converters/big5hkscs2001.h" // IWYU pragma: keep +#include "converters/big5hkscs2004.h" // IWYU pragma: keep +#include "converters/big5hkscs2008.h" // IWYU pragma: keep +#include "converters/ces_big5.h" // IWYU pragma: keep +#include "converters/ces_gbk.h" // IWYU pragma: keep +#include "converters/cp936.h" // IWYU pragma: keep +#include "converters/cp950.h" // IWYU pragma: keep +#include "converters/euc_cn.h" // IWYU pragma: keep +#include "converters/euc_tw.h" // IWYU pragma: keep +#include "converters/gb18030_2005.h" // IWYU pragma: keep +#include "converters/gb18030_2022.h" // IWYU pragma: keep +#include "converters/hz.h" // IWYU pragma: keep +#include "converters/iso2022_cn.h" // IWYU pragma: keep +#include "converters/iso2022_cnext.h" // IWYU pragma: keep + +#include "converters/cp949.h" // IWYU pragma: keep +#include "converters/euc_kr.h" // IWYU pragma: keep +#include "converters/iso2022_kr.h" // IWYU pragma: keep +#include "converters/johab.h" // IWYU pragma: keep + +#include "converters/dec_hanyu.h" // IWYU pragma: keep +#include "converters/dec_kanji.h" // IWYU pragma: keep +#pragma endregion + +#pragma region Encodings used by system dependent locales +#include "converters/cp1046.h" // IWYU pragma: keep +#include "converters/cp1124.h" // IWYU pragma: keep +#include "converters/cp1129.h" // IWYU pragma: keep +#include "converters/cp1161.h" // IWYU pragma: keep +#include "converters/cp1162.h" // IWYU pragma: keep +#include "converters/cp1163.h" // IWYU pragma: keep +#include "converters/cp856.h" // IWYU pragma: keep +#include "converters/cp922.h" // IWYU pragma: keep +#include "converters/cp943.h" // IWYU pragma: keep + +#include "converters/cp1125.h" // IWYU pragma: keep +#include "converters/cp437.h" // IWYU pragma: keep +#include "converters/cp737.h" // IWYU pragma: keep +#include "converters/cp775.h" // IWYU pragma: keep +#include "converters/cp852.h" // IWYU pragma: keep +#include "converters/cp853.h" // IWYU pragma: keep +#include "converters/cp855.h" // IWYU pragma: keep +#include "converters/cp857.h" // IWYU pragma: keep +#include "converters/cp858.h" // IWYU pragma: keep +#include "converters/cp860.h" // IWYU pragma: keep +#include "converters/cp861.h" // IWYU pragma: keep +#include "converters/cp863.h" // IWYU pragma: keep +#include "converters/cp864.h" // IWYU pragma: keep +#include "converters/cp865.h" // IWYU pragma: keep +#include "converters/cp869.h" // IWYU pragma: keep +#pragma endregion #define DEDUPLICATE_TABLES 1 -/* Swaps the values 0x15 and 0x25. - Both gcc and clang compile this expression to something that involves as few - conditional branching instructions as possible. */ -#define swap_x15_x25_a(x) ((x) == 0x15 ? 0x25 : (x) == 0x25 ? 0x15 : (x)) -#define swap_x15_x25_b(x) ((x) ^ ((x) == 0x15 || (x) == 0x25 ? 0x30 : 0)) -#define swap_x15_x25_c(x) ((x) ^ ((((x) - 0x15) & ~0x10) == 0 ? 0x30 : 0)) -/* Number of conditional branches (with "gcc -O2", as of 2023): - a b c - --------------- - aarch64 1 0 0 - alpha 0 0 0 - arm 1 0 0 - hppa 1 1 1 - i686 1 0 0 - m68k 2 1 1 - mips 2 1 0 - mips64 2 1 0 - powerpc 2 1 1 - powerpc64 2 1 1 - powerpc64le 2 1 1 - riscv64 2 1 1 - s390x 1 1 1 - sh4 2 1 1 - x86_64 1 0 0 -*/ -#define swap_x15_x25 swap_x15_x25_c - -#include "ebcdic037.h" -#include "ebcdic273.h" -#include "ebcdic277.h" -#include "ebcdic278.h" -#include "ebcdic280.h" -#include "ebcdic282.h" -#include "ebcdic284.h" -#include "ebcdic285.h" -#include "ebcdic297.h" -#include "ebcdic423.h" -#include "ebcdic424.h" -#include "ebcdic425.h" -#include "ebcdic500.h" -#include "ebcdic838.h" -#include "ebcdic870.h" -#include "ebcdic871.h" -#include "ebcdic875.h" -#include "ebcdic880.h" -#include "ebcdic905.h" -#include "ebcdic924.h" -#include "ebcdic1025.h" -#include "ebcdic1026.h" -#include "ebcdic1047.h" -#include "ebcdic1097.h" -#include "ebcdic1112.h" -#include "ebcdic1122.h" -#include "ebcdic1123.h" -#include "ebcdic1130.h" -#include "ebcdic1132.h" -#include "ebcdic1137.h" -#include "ebcdic1140.h" -#include "ebcdic1141.h" -#include "ebcdic1142.h" -#include "ebcdic1143.h" -#include "ebcdic1144.h" -#include "ebcdic1145.h" -#include "ebcdic1146.h" -#include "ebcdic1147.h" -#include "ebcdic1148.h" -#include "ebcdic1149.h" -#include "ebcdic1153.h" -#include "ebcdic1154.h" -#include "ebcdic1155.h" -#include "ebcdic1156.h" -#include "ebcdic1157.h" -#include "ebcdic1158.h" -#include "ebcdic1160.h" -#include "ebcdic1164.h" -#include "ebcdic1165.h" -#include "ebcdic1166.h" -#include "ebcdic4971.h" -#include "ebcdic12712.h" -#include "ebcdic16804.h" -#endif - -#ifdef USE_EXTRA -#include "euc_jisx0213.h" -#include "shift_jisx0213.h" -#include "iso2022_jp3.h" -#include "big5_2003.h" -#include "tds565.h" -#include "atarist.h" -#include "riscos1.h" -#endif - +#pragma region AIX locales +#include "converters/ebcdic037.h" // IWYU pragma: keep +#include "converters/ebcdic273.h" // IWYU pragma: keep +#include "converters/ebcdic277.h" // IWYU pragma: keep +#include "converters/ebcdic278.h" // IWYU pragma: keep +#include "converters/ebcdic280.h" // IWYU pragma: keep +#include "converters/ebcdic282.h" // IWYU pragma: keep +#include "converters/ebcdic284.h" // IWYU pragma: keep +#include "converters/ebcdic285.h" // IWYU pragma: keep +#include "converters/ebcdic297.h" // IWYU pragma: keep +#include "converters/ebcdic423.h" // IWYU pragma: keep +#include "converters/ebcdic424.h" // IWYU pragma: keep +#include "converters/ebcdic425.h" // IWYU pragma: keep +#include "converters/ebcdic500.h" // IWYU pragma: keep +#include "converters/ebcdic838.h" // IWYU pragma: keep +#include "converters/ebcdic870.h" // IWYU pragma: keep +#include "converters/ebcdic871.h" // IWYU pragma: keep +#include "converters/ebcdic875.h" // IWYU pragma: keep +#include "converters/ebcdic880.h" // IWYU pragma: keep +#include "converters/ebcdic905.h" // IWYU pragma: keep +#include "converters/ebcdic924.h" // IWYU pragma: keep +#include "converters/ebcdic1025.h" // IWYU pragma: keep +#include "converters/ebcdic1026.h" // IWYU pragma: keep +#include "converters/ebcdic1047.h" // IWYU pragma: keep +#include "converters/ebcdic1097.h" // IWYU pragma: keep +#include "converters/ebcdic1112.h" // IWYU pragma: keep +#include "converters/ebcdic1122.h" // IWYU pragma: keep +#include "converters/ebcdic1123.h" // IWYU pragma: keep +#include "converters/ebcdic1130.h" // IWYU pragma: keep +#include "converters/ebcdic1132.h" // IWYU pragma: keep +#include "converters/ebcdic1137.h" // IWYU pragma: keep +#include "converters/ebcdic1140.h" // IWYU pragma: keep +#include "converters/ebcdic1141.h" // IWYU pragma: keep +#include "converters/ebcdic1142.h" // IWYU pragma: keep +#include "converters/ebcdic1143.h" // IWYU pragma: keep +#include "converters/ebcdic1144.h" // IWYU pragma: keep +#include "converters/ebcdic1145.h" // IWYU pragma: keep +#include "converters/ebcdic1146.h" // IWYU pragma: keep +#include "converters/ebcdic1147.h" // IWYU pragma: keep +#include "converters/ebcdic1148.h" // IWYU pragma: keep +#include "converters/ebcdic1149.h" // IWYU pragma: keep +#include "converters/ebcdic1153.h" // IWYU pragma: keep +#include "converters/ebcdic1154.h" // IWYU pragma: keep +#include "converters/ebcdic1155.h" // IWYU pragma: keep +#include "converters/ebcdic1156.h" // IWYU pragma: keep +#include "converters/ebcdic1157.h" // IWYU pragma: keep +#include "converters/ebcdic1158.h" // IWYU pragma: keep +#include "converters/ebcdic1160.h" // IWYU pragma: keep +#include "converters/ebcdic1164.h" // IWYU pragma: keep +#include "converters/ebcdic1165.h" // IWYU pragma: keep +#include "converters/ebcdic1166.h" // IWYU pragma: keep +#include "converters/ebcdic4971.h" // IWYU pragma: keep +#include "converters/ebcdic12712.h" // IWYU pragma: keep +#include "converters/ebcdic16804.h" // IWYU pragma: keep +#pragma endregion + +#pragma region Extra encodings +#include "converters/atarist.h" // IWYU pragma: keep +#include "converters/big5_2003.h" // IWYU pragma: keep +#include "converters/euc_jisx0213.h" // IWYU pragma: keep +#include "converters/iso2022_jp3.h" // IWYU pragma: keep +#include "converters/riscos1.h" // IWYU pragma: keep +#include "converters/shift_jisx0213.h" // IWYU pragma: keep +#include "converters/tds565.h" // IWYU pragma: keep +#pragma endregion + +#endif /* _CONVERTERS_H_ */ diff --git a/lib/armscii_8.h b/lib/converters/armscii_8.h similarity index 69% rename from lib/armscii_8.h rename to lib/converters/armscii_8.h index 7794d972..383a16cf 100644 --- a/lib/armscii_8.h +++ b/lib/converters/armscii_8.h @@ -1,5 +1,10 @@ +/** + * @file armscii_8.h + * @brief ARMSCII-8 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ARMSCII-8 - */ +#ifndef _ARMSCII_8_H_ +#define _ARMSCII_8_H_ + +#include "reiconv_defines.h" static const unsigned short armscii_8_2uni[96] = { /* 0xa0 */ @@ -42,22 +48,24 @@ static const unsigned short armscii_8_2uni[96] = { 0x0554, 0x0584, 0x0555, 0x0585, 0x0556, 0x0586, 0x055a, 0xfffd, }; -static int -armscii_8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int armscii_8_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = armscii_8_2uni[c-0xa0]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0xa0) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = armscii_8_2uni[c - 0xa0]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char armscii_8_page00[8] = { @@ -89,27 +97,30 @@ static const unsigned char armscii_8_page20[24] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xae, 0x00, /* 0x20-0x27 */ }; -static int -armscii_8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int armscii_8_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0028) { - *r = wc; - return 1; - } - else if (wc >= 0x0028 && wc < 0x0030) - c = armscii_8_page00[wc-0x0028]; - else if (wc >= 0x0030 && wc < 0x00a0) - c = wc; - else if (wc >= 0x00a0 && wc < 0x00c0) - c = armscii_8_page00_1[wc-0x00a0]; - else if (wc >= 0x0530 && wc < 0x0590) - c = armscii_8_page05[wc-0x0530]; - else if (wc >= 0x2010 && wc < 0x2028) - c = armscii_8_page20[wc-0x2010]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0028) + { + *r = wc; + return 1; + } + else if (wc >= 0x0028 && wc < 0x0030) + c = armscii_8_page00[wc - 0x0028]; + else if (wc >= 0x0030 && wc < 0x00a0) + c = wc; + else if (wc >= 0x00a0 && wc < 0x00c0) + c = armscii_8_page00_1[wc - 0x00a0]; + else if (wc >= 0x0530 && wc < 0x0590) + c = armscii_8_page05[wc - 0x0530]; + else if (wc >= 0x2010 && wc < 0x2028) + c = armscii_8_page20[wc - 0x2010]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ARMSCII_8_H_ */ diff --git a/lib/converters/ascii.h b/lib/converters/ascii.h new file mode 100644 index 00000000..ce289681 --- /dev/null +++ b/lib/converters/ascii.h @@ -0,0 +1,51 @@ +/** + * @file ascii.h + * @brief ASCII + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _ASCII_H_ +#define _ASCII_H_ + +#include "reiconv_defines.h" + +static int ascii_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; + } + return RET_ILSEQ; +} + +static int ascii_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0x0080) + { + *r = wc; + return 1; + } + return RET_ILUNI; +} + +#endif /* _ASCII_H_ */ diff --git a/lib/atarist.h b/lib/converters/atarist.h similarity index 79% rename from lib/atarist.h rename to lib/converters/atarist.h index 73c46baa..b1490ad4 100644 --- a/lib/atarist.h +++ b/lib/converters/atarist.h @@ -1,5 +1,10 @@ +/** + * @file atarist.h + * @brief Atari ST + * @copyright Copyright (C) 1999-2005, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2005, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * Atari ST - */ +#ifndef _ATARIST_H_ +#define _ATARIST_H_ + +#include "reiconv_defines.h" static const unsigned short atarist_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short atarist_2uni[128] = { 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x00b3, 0x00af, }; -static int -atarist_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int atarist_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) atarist_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)atarist_2uni[c - 0x80]; + return 1; } static const unsigned char atarist_page00[96] = { @@ -123,35 +128,38 @@ static const unsigned char atarist_page23[24] = { 0xf4, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ }; -static int -atarist_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int atarist_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = atarist_page00[wc-0x00a0]; - else if (wc >= 0x0130 && wc < 0x0198) - c = atarist_page01[wc-0x0130]; - else if (wc >= 0x0390 && wc < 0x03c8) - c = atarist_page03[wc-0x0390]; - else if (wc >= 0x05d0 && wc < 0x05f0) - c = atarist_page05[wc-0x05d0]; - else if (wc == 0x2020) - c = 0xbb; - else if (wc == 0x207f) - c = 0xfc; - else if (wc == 0x2122) - c = 0xbf; - else if (wc >= 0x2208 && wc < 0x2268) - c = atarist_page22[wc-0x2208]; - else if (wc >= 0x2310 && wc < 0x2328) - c = atarist_page23[wc-0x2310]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = atarist_page00[wc - 0x00a0]; + else if (wc >= 0x0130 && wc < 0x0198) + c = atarist_page01[wc - 0x0130]; + else if (wc >= 0x0390 && wc < 0x03c8) + c = atarist_page03[wc - 0x0390]; + else if (wc >= 0x05d0 && wc < 0x05f0) + c = atarist_page05[wc - 0x05d0]; + else if (wc == 0x2020) + c = 0xbb; + else if (wc == 0x207f) + c = 0xfc; + else if (wc == 0x2122) + c = 0xbf; + else if (wc >= 0x2208 && wc < 0x2268) + c = atarist_page22[wc - 0x2208]; + else if (wc >= 0x2310 && wc < 0x2328) + c = atarist_page23[wc - 0x2310]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ATARIST_H_ */ diff --git a/lib/big5.h b/lib/converters/big5.h similarity index 98% rename from lib/big5.h rename to lib/converters/big5.h index b48870ba..27b357b8 100644 --- a/lib/big5.h +++ b/lib/converters/big5.h @@ -1,5 +1,10 @@ +/** + * @file big5.h + * @brief BIG5 + * @copyright Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * BIG5 - */ +#ifndef _BIG5_H_ +#define _BIG5_H_ -static const unsigned short big5_2uni_pagea1[6121] = { +#include "reiconv_defines.h" + +static const unsigned short big5_2uni_pagea1[6121] = +{ /* 0xa1 */ 0x3000, 0xff0c, 0x3001, 0x3002, 0xff0e, 0x2022, 0xff1b, 0xff1a, 0xff1f, 0xff01, 0xfe30, 0x2026, 0x2025, 0xfe50, 0xff64, 0xfe52, @@ -842,7 +849,8 @@ static const unsigned short big5_2uni_pagea1[6121] = { 0x2469, 0x2474, 0x2475, 0x2476, 0x2477, 0x2478, 0x2479, 0x247a, 0x247b, 0x247c, 0x247d, }; -static const unsigned short big5_2uni_pagec9[7652] = { +static const unsigned short big5_2uni_pagec9[7652] = +{ /* 0xc9 */ 0x4e42, 0x4e5c, 0x51f5, 0x531a, 0x5382, 0x4e07, 0x4e0c, 0x4e47, 0x4e8d, 0x56d7, 0xfa0c, 0x5c6e, 0x5f73, 0x4e0f, 0x5187, 0x4e0e, @@ -1869,36 +1877,43 @@ static const unsigned short big5_2uni_pagec9[7652] = { 0x9ea4, 0x9f7e, 0x9f49, 0x9f98, }; -static int -big5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int big5_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0xa1 && c1 <= 0xc7) || (c1 >= 0xc9 && c1 <= 0xf9)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) { - unsigned int i = 157 * (c1 - 0xa1) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); - unsigned short wc = 0xfffd; - if (i < 6280) { - if (i < 6121) - wc = big5_2uni_pagea1[i]; - } else { - if (i < 13932) - wc = big5_2uni_pagec9[i-6280]; - } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; + unsigned char c1 = s[0]; + if ((c1 >= 0xa1 && c1 <= 0xc7) || (c1 >= 0xc9 && c1 <= 0xf9)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) + { + unsigned int i = 157 * (c1 - 0xa1) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); + unsigned short wc = 0xfffd; + if (i < 6280) + { + if (i < 6121) + wc = big5_2uni_pagea1[i]; + } + else + { + if (i < 13932) + wc = big5_2uni_pagec9[i - 6280]; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } -static const unsigned short big5_2charset[13703] = { +static const unsigned short big5_2charset[13703] = +{ 0xa246, 0xa247, 0xa244, 0xa1b1, 0xa258, 0xa1d3, 0xa150, 0xa1d1, 0xa1d2, 0xa3be, 0xa3bc, 0xa3bd, 0xa3bf, 0xa3bb, 0xa344, 0xa345, 0xa346, 0xa347, 0xa348, 0xa349, 0xa34a, 0xa34b, 0xa34c, 0xa34d, @@ -3614,14 +3629,16 @@ static const unsigned short big5_2charset[13703] = { 0xa341, 0xa342, 0xa343, 0xa161, 0xa155, 0xa162, 0xa14e, }; -static const Summary16 big5_uni2indx_page00[16] = { +static const Summary16 big5_uni2indx_page00[16] = +{ /* 0x0000 */ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x00ac }, { 4, 0x0083 }, { 7, 0x0000 }, { 7, 0x0080 }, { 8, 0x0000 }, { 8, 0x0080 }, }; -static const Summary16 big5_uni2indx_page02[38] = { +static const Summary16 big5_uni2indx_page02[38] = +{ /* 0x0200 */ { 9, 0x0000 }, { 9, 0x0000 }, { 9, 0x0000 }, { 9, 0x0000 }, { 9, 0x0000 }, { 9, 0x0000 }, { 9, 0x0000 }, { 9, 0x0000 }, @@ -3636,7 +3653,8 @@ static const Summary16 big5_uni2indx_page02[38] = { { 62, 0x0002 }, { 63, 0x1ff0 }, { 72, 0xfff8 }, { 85, 0xffff }, { 101, 0xffff }, { 117, 0x0002 }, }; -static const Summary16 big5_uni2indx_page20[44] = { +static const Summary16 big5_uni2indx_page20[44] = +{ /* 0x2000 */ { 118, 0x0000 }, { 118, 0x3318 }, { 124, 0x0064 }, { 127, 0x4824 }, { 131, 0x0000 }, { 131, 0x0000 }, { 131, 0x0000 }, { 131, 0x0000 }, @@ -3652,7 +3670,8 @@ static const Summary16 big5_uni2indx_page20[44] = { { 165, 0x0000 }, { 165, 0x0004 }, { 166, 0x00c3 }, { 170, 0x0000 }, { 170, 0x0000 }, { 170, 0x0000 }, { 170, 0x0020 }, { 171, 0x8000 }, }; -static const Summary16 big5_uni2indx_page24[37] = { +static const Summary16 big5_uni2indx_page24[37] = +{ /* 0x2400 */ { 172, 0x0000 }, { 172, 0x0000 }, { 172, 0x0000 }, { 172, 0x0000 }, { 172, 0x0000 }, { 172, 0x0000 }, { 172, 0x03ff }, { 182, 0x3ff0 }, @@ -3667,7 +3686,8 @@ static const Summary16 big5_uni2indx_page24[37] = { { 246, 0x0260 }, { 249, 0x0000 }, { 249, 0x0000 }, { 249, 0x0000 }, { 249, 0x0007 }, }; -static const Summary16 big5_uni2indx_page30[62] = { +static const Summary16 big5_uni2indx_page30[62] = +{ /* 0x3000 */ { 252, 0xff2f }, { 265, 0x6037 }, { 272, 0x03fe }, { 281, 0x0000 }, { 281, 0xfffe }, { 296, 0xffff }, { 312, 0xffff }, { 328, 0xffff }, @@ -3689,7 +3709,8 @@ static const Summary16 big5_uni2indx_page30[62] = { { 491, 0xc000 }, { 493, 0x7000 }, { 496, 0x0002 }, { 497, 0x0000 }, { 497, 0x4010 }, { 499, 0x0026 }, }; -static const Summary16 big5_uni2indx_page4e[1307] = { +static const Summary16 big5_uni2indx_page4e[1307] = +{ /* 0x4e00 */ { 502, 0xff8b }, { 514, 0xc373 }, { 523, 0x6840 }, { 527, 0x1b0f }, { 535, 0xe9ac }, { 544, 0xf34c }, { 553, 0x0200 }, { 554, 0xc008 }, @@ -4100,11 +4121,13 @@ static const Summary16 big5_uni2indx_page4e[1307] = { { 13502, 0xffcf }, { 13516, 0xfbf4 }, { 13528, 0xdcfb }, { 13540, 0x4ff7 }, { 13552, 0x2000 }, { 13553, 0x1137 }, { 13560, 0x0015 }, }; -static const Summary16 big5_uni2indx_pagefa[1] = { +static const Summary16 big5_uni2indx_pagefa[1] = +{ /* 0xfa00 */ { 13563, 0x3000 }, }; -static const Summary16 big5_uni2indx_pagefe[23] = { +static const Summary16 big5_uni2indx_pagefe[23] = +{ /* 0xfe00 */ { 13565, 0x0000 }, { 13565, 0x0000 }, { 13565, 0x0000 }, { 13565, 0xfffb }, { 13580, 0xfe1f }, { 13592, 0xfef5 }, { 13605, 0x0e7f }, { 13615, 0x0000 }, @@ -4115,45 +4138,50 @@ static const Summary16 big5_uni2indx_pagefe[23] = { { 13673, 0xfffe }, { 13688, 0x3fff }, { 13702, 0x0010 }, }; -static int -big5_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int big5_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc >= 0x0000 && wc < 0x0100) - summary = &big5_uni2indx_page00[(wc>>4)]; - else if (wc >= 0x0200 && wc < 0x0460) - summary = &big5_uni2indx_page02[(wc>>4)-0x020]; - else if (wc >= 0x2000 && wc < 0x22c0) - summary = &big5_uni2indx_page20[(wc>>4)-0x200]; - else if (wc >= 0x2400 && wc < 0x2650) - summary = &big5_uni2indx_page24[(wc>>4)-0x240]; - else if (wc >= 0x3000 && wc < 0x33e0) - summary = &big5_uni2indx_page30[(wc>>4)-0x300]; - else if (wc >= 0x4e00 && wc < 0x9fb0) - summary = &big5_uni2indx_page4e[(wc>>4)-0x4e0]; - else if (wc >= 0xfa00 && wc < 0xfa10) - summary = &big5_uni2indx_pagefa[(wc>>4)-0xfa0]; - else if (wc >= 0xfe00 && wc < 0xff70) - summary = &big5_uni2indx_pagefe[(wc>>4)-0xfe0]; - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = big5_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc >= 0x0000 && wc < 0x0100) + summary = &big5_uni2indx_page00[(wc >> 4)]; + else if (wc >= 0x0200 && wc < 0x0460) + summary = &big5_uni2indx_page02[(wc >> 4) - 0x020]; + else if (wc >= 0x2000 && wc < 0x22c0) + summary = &big5_uni2indx_page20[(wc >> 4) - 0x200]; + else if (wc >= 0x2400 && wc < 0x2650) + summary = &big5_uni2indx_page24[(wc >> 4) - 0x240]; + else if (wc >= 0x3000 && wc < 0x33e0) + summary = &big5_uni2indx_page30[(wc >> 4) - 0x300]; + else if (wc >= 0x4e00 && wc < 0x9fb0) + summary = &big5_uni2indx_page4e[(wc >> 4) - 0x4e0]; + else if (wc >= 0xfa00 && wc < 0xfa10) + summary = &big5_uni2indx_pagefa[(wc >> 4) - 0xfa0]; + else if (wc >= 0xfe00 && wc < 0xff70) + summary = &big5_uni2indx_pagefe[(wc >> 4) - 0xfe0]; + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = big5_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _BIG5_H_ */ diff --git a/lib/converters/big5_2003.h b/lib/converters/big5_2003.h new file mode 100644 index 00000000..5739a569 --- /dev/null +++ b/lib/converters/big5_2003.h @@ -0,0 +1,962 @@ +/** + * @file big5_2003.h + * @brief BIG5-2003 + * @copyright Copyright (C) 1999-2001, 2005, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * BIG5-2003 is a slightly extended and slightly modified version of BIG5. + * It is actually nearer to Microsoft CP950 than to BIG5. The differences + * between EASTASIA/OTHER/BIG5.TXT found on ftp.unicode.org and BIG5-2003.TXT + * are as follows: + * + * 1. Some characters in the symbols area (0xA140..0xA2CE) are defined + * differently: + * + * code BIG5.TXT BIG5-2003.TXT + * 0xA145 0x2022 # BULLET 0x2027 # HYPHENATION POINT + * 0xA14E 0xFF64 # HALFWIDTH IDEOGRAPHIC COMMA + * 0xFE51 # SMALL IDEOGRAPHIC COMMA + * 0xA156 0x2013 # EN DASH 0x2015 # HORIZONTAL BAR + * 0xA15A --- 0x2574 # BOX DRAWINGS LIGHT LEFT + * 0xA1C3 --- 0xFFE3 # FULLWIDTH MACRON + * 0xA1C5 --- 0x02CD # MODIFIER LETTER LOW MACRON + * 0xA1E3 0x223C # TILDE OPERATOR 0xFF5E # FULLWIDTH TILDE + * 0xA1F2 0x2641 # EARTH 0x2295 # CIRCLED PLUS + * 0xA1F3 0x2609 # SUN 0x2299 # CIRCLED DOT OPERATOR + * 0xA1FE --- 0xFF0F # FULLWIDTH SOLIDUS + * 0xA240 --- 0xFF3C # FULLWIDTH REVERSE SOLIDUS + * 0xA241 0xFF0F # FULLWIDTH SOLIDUS 0x2215 # DIVISION SLASH + * 0xA242 0xFF3C # FULLWIDTH REVERSE SOLIDUS + * 0xFE68 # SMALL REVERSE SOLIDUS + * 0xA244 0x00A5 # YEN SIGN 0xFFE5 # FULLWIDTH YEN SIGN + * 0xA246 0x00A2 # CENT SIGN 0xFFE0 # FULLWIDTH CENT SIGN + * 0xA247 0x00A3 # POUND SIGN 0xFFE1 # FULLWIDTH POUND SIGN + * 0xA2A4 0x2550 # BOX DRAWINGS DOUBLE HORIZONTAL + * 0x2501 # BOX DRAWINGS HEAVY HORIZONTAL + * 0xA2A5 0x255E # BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE + * 0x251D # BOX DRAWINGS VERTICAL LIGHT AND RIGHT HEAVY + * 0xA2A6 0x256A # BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE + * 0x253F # BOX DRAWINGS VERTICAL LIGHT AND HORIZONTAL HEAVY + * 0xA2A7 0x2561 # BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE + * 0x2525 # BOX DRAWINGS VERTICAL LIGHT AND LEFT HEAVY + * 0xA2CC --- 0x3038 # HANGZHOU NUMERAL TEN + * 0xA2CD 0x5344 0x3039 # HANGZHOU NUMERAL TWENTY + * 0xA2CE --- 0x303A # HANGZHOU NUMERAL THIRTY + * + * 2. A control symbols area is added: + * + * code + * 0xA3C0..0xA3E0 U+2400..U+2421 + * + * 3. The Euro sign is added: + * + * code + * 0xA3E1 0x20AC # EURO SIGN + * + * 4. Some characters in the main area are defined differently: + * + * code BIG5.TXT BIG5-2003.TXT + * 0xC255 0x5F5D 0x5F5E + * + * 5. The area 0xC6A1..0xC7FE is organized differently: + * + * code + * 0xC6A1..0xC6BE numerals (was in BIG5.TXT at 0xC7E9..0xC7FC) + * 0xC6BF..0xC6D7 radicals + * 0xC6D8..0xC6E6 rarely used symbols + * 0xC6E7..0xC77A hiragana (U+3041..U+3093, was in BIG5.TXT at 0xC6A5..0xC6F7) + * 0xC77B..0xC7F2 katakana (U+30A1..U+30F6, was in BIG5.TXT at 0xC6F8..0xC7B0) + * + * 6. Some characters are added at 0xF9D6..0xF9DC. + * + * 7. Box drawing characters are added at 0xF9DD..0xF9FE. + * + * Note: 4 of these characters are mapped in a non-inversible way, because + * Unicode does not yet include the corresponding characters: + * + * code Unicode approximation + * 0xF9FA BOX DRAWINGS DOUBLE ARC DOWN AND RIGHT 0x2554 + * 0xF9FB BOX DRAWINGS DOUBLE ARC DOWN AND LEFT 0x2557 + * 0xF9FC BOX DRAWINGS DOUBLE ARC UP AND RIGHT 0x255A + * 0xF9FD BOX DRAWINGS DOUBLE ARC UP AND LEFT 0x255D + * + * 8. Private area mappings are added: + * + * code Unicode + * 0x{81..8D}{40..7E,A1..FE} U+EEB8..U+F6B0 + * 0x{8E..A0}{40..7E,A1..FE} U+E311..U+EEB7 + * 0x{FA..FE}{40..7E,A1..FE} U+E000..U+E310 + * + * These mappings are not contained in the BSMI Big5-2003 standard. However, + * they were contained in a draft of it. + */ + +#ifndef _BIG5_2003_H_ +#define _BIG5_2003_H_ + +#include "converters/ascii.h" +#include "converters/big5.h" +#include "reiconv_defines.h" + +#include + +static const unsigned short big5_2003_2uni_pagea1[314] = +{ + /* 0xa1 */ + 0x3000, 0xff0c, 0x3001, 0x3002, 0xff0e, 0x2027, 0xff1b, 0xff1a, + 0xff1f, 0xff01, 0xfe30, 0x2026, 0x2025, 0xfe50, 0xfe51, 0xfe52, + 0x00b7, 0xfe54, 0xfe55, 0xfe56, 0xfe57, 0xff5c, 0x2015, 0xfe31, + 0x2014, 0xfe33, 0x2574, 0xfe34, 0xfe4f, 0xff08, 0xff09, 0xfe35, + 0xfe36, 0xff5b, 0xff5d, 0xfe37, 0xfe38, 0x3014, 0x3015, 0xfe39, + 0xfe3a, 0x3010, 0x3011, 0xfe3b, 0xfe3c, 0x300a, 0x300b, 0xfe3d, + 0xfe3e, 0x3008, 0x3009, 0xfe3f, 0xfe40, 0x300c, 0x300d, 0xfe41, + 0xfe42, 0x300e, 0x300f, 0xfe43, 0xfe44, 0xfe59, 0xfe5a, 0xfe5b, + 0xfe5c, 0xfe5d, 0xfe5e, 0x2018, 0x2019, 0x201c, 0x201d, 0x301d, + 0x301e, 0x2035, 0x2032, 0xff03, 0xff06, 0xff0a, 0x203b, 0x00a7, + 0x3003, 0x25cb, 0x25cf, 0x25b3, 0x25b2, 0x25ce, 0x2606, 0x2605, + 0x25c7, 0x25c6, 0x25a1, 0x25a0, 0x25bd, 0x25bc, 0x32a3, 0x2105, + 0x203e, 0xffe3, 0xff3f, 0x02cd, 0xfe49, 0xfe4a, 0xfe4d, 0xfe4e, + 0xfe4b, 0xfe4c, 0xfe5f, 0xfe60, 0xfe61, 0xff0b, 0xff0d, 0x00d7, + 0x00f7, 0x00b1, 0x221a, 0xff1c, 0xff1e, 0xff1d, 0x2266, 0x2267, + 0x2260, 0x221e, 0x2252, 0x2261, 0xfe62, 0xfe63, 0xfe64, 0xfe65, + 0xfe66, 0xff5e, 0x2229, 0x222a, 0x22a5, 0x2220, 0x221f, 0x22bf, + 0x33d2, 0x33d1, 0x222b, 0x222e, 0x2235, 0x2234, 0x2640, 0x2642, + 0x2295, 0x2299, 0x2191, 0x2193, 0x2190, 0x2192, 0x2196, 0x2197, + 0x2199, 0x2198, 0x2225, 0x2223, 0xff0f, + /* 0xa2 */ + 0xff3c, 0x2215, 0xfe68, 0xff04, 0xffe5, 0x3012, 0xffe0, 0xffe1, + 0xff05, 0xff20, 0x2103, 0x2109, 0xfe69, 0xfe6a, 0xfe6b, 0x33d5, + 0x339c, 0x339d, 0x339e, 0x33ce, 0x33a1, 0x338e, 0x338f, 0x33c4, + 0x00b0, 0x5159, 0x515b, 0x515e, 0x515d, 0x5161, 0x5163, 0x55e7, + 0x74e9, 0x7cce, 0x2581, 0x2582, 0x2583, 0x2584, 0x2585, 0x2586, + 0x2587, 0x2588, 0x258f, 0x258e, 0x258d, 0x258c, 0x258b, 0x258a, + 0x2589, 0x253c, 0x2534, 0x252c, 0x2524, 0x251c, 0x2594, 0x2500, + 0x2502, 0x2595, 0x250c, 0x2510, 0x2514, 0x2518, 0x256d, 0x256e, + 0x2570, 0x256f, 0x2501, 0x251d, 0x253f, 0x2525, 0x25e2, 0x25e3, + 0x25e5, 0x25e4, 0x2571, 0x2572, 0x2573, 0xff10, 0xff11, 0xff12, + 0xff13, 0xff14, 0xff15, 0xff16, 0xff17, 0xff18, 0xff19, 0x2160, + 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, + 0x2169, 0x3021, 0x3022, 0x3023, 0x3024, 0x3025, 0x3026, 0x3027, + 0x3028, 0x3029, 0x3038, 0x3039, 0x303a, 0xff21, 0xff22, 0xff23, + 0xff24, 0xff25, 0xff26, 0xff27, 0xff28, 0xff29, 0xff2a, 0xff2b, + 0xff2c, 0xff2d, 0xff2e, 0xff2f, 0xff30, 0xff31, 0xff32, 0xff33, + 0xff34, 0xff35, 0xff36, 0xff37, 0xff38, 0xff39, 0xff3a, 0xff41, + 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48, 0xff49, + 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50, 0xff51, + 0xff52, 0xff53, 0xff54, 0xff55, 0xff56, +}; + +static const unsigned short big5_2003_2uni_pagec6[70] = +{ + /* 0xc6a1 */ + 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, + 0x2468, 0x2469, 0x2474, 0x2475, 0x2476, 0x2477, 0x2478, 0x2479, + 0x247a, 0x247b, 0x247c, 0x247d, 0x2170, 0x2171, 0x2172, 0x2173, + 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x2f02, 0x2f03, + 0x2f05, 0x2f07, 0x2f0c, 0x2f0d, 0x2f0e, 0x2f13, 0x2f16, 0x2f19, + 0x2f1b, 0x2f22, 0x2f27, 0x2f2e, 0x2f33, 0x2f34, 0x2f35, 0x2f39, + 0x2f3a, 0x2f41, 0x2f46, 0x2f67, 0x2f68, 0x2fa1, 0x2faa, 0x00a8, + 0xff3e, 0x30fd, 0x30fe, 0x309d, 0x309e, 0xfffd, 0xfffd, 0x3005, + 0x3006, 0x3007, 0x30fc, 0xff3b, 0xff3d, 0x273d, +}; + +static const unsigned short big5_2003_2uni_pagef9[41] = +{ + /* 0xf9d6 */ + 0x7881, 0x92b9, 0x88cf, 0x58bb, 0x6052, 0x7ca7, 0x5afa, + /* 0xf9dd */ + 0x2554, 0x2566, 0x2557, 0x2560, 0x256c, 0x2563, 0x255a, 0x2569, + 0x255d, 0x2552, 0x2564, 0x2555, 0x255e, 0x256a, 0x2561, 0x2558, + 0x2567, 0x255b, 0x2553, 0x2565, 0x2556, 0x255f, 0x256b, 0x2562, + 0x2559, 0x2568, 0x255c, 0x2551, 0x2550, + 0x2554, 0x2557, 0x255a, 0x255d, /* not invertible */ + 0x2593, +}; + +static int big5_2003_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + /* Code set 0 (ASCII) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (BIG5 extended) */ + if (c >= 0x81 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) + { + if (c >= 0xa1) + { + if (c < 0xa3) + { + unsigned int i = 157 * (c - 0xa1) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); + unsigned short wc = big5_2003_2uni_pagea1[i]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + if (!((c == 0xc6 && c2 >= 0xa1) || c == 0xc7)) + { + if (!(c == 0xc2 && c2 == 0x55)) + { + int ret = big5_mbtowc(conv, pwc, s, 2); + if (ret != RET_ILSEQ) + return ret; + if (c == 0xa3) + { + if (c2 >= 0xc0 && c2 <= 0xe1) + { + *pwc = (c2 == 0xe1 ? 0x20ac : c2 == 0xe0 ? 0x2421 : 0x2340 + c2); + return 2; + } + } + else if (c == 0xf9) + { + if (c2 >= 0xd6) + { + *pwc = big5_2003_2uni_pagef9[c2 - 0xd6]; + return 2; + } + } + else if (c >= 0xfa) + { + *pwc = 0xe000 + 157 * (c - 0xfa) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); + return 2; + } + } + else + { + /* c == 0xc2 && c2 == 0x55. */ + *pwc = 0x5f5e; + return 2; + } + } + else + { + /* (c == 0xc6 && c2 >= 0xa1) || c == 0xc7. */ + unsigned int i = 157 * (c - 0xc6) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); + if (i < 133) + { + /* 63 <= i < 133. */ + unsigned short wc = big5_2003_2uni_pagec6[i - 63]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + else if (i < 216) + { + /* 133 <= i < 216. Hiragana. */ + *pwc = 0x3041 - 133 + i; + return 2; + } + else if (i < 302) + { + /* 216 <= i < 302. Katakana. */ + *pwc = 0x30a1 - 216 + i; + return 2; + } + } + } + else + { + /* 0x81 <= c < 0xa1. */ + *pwc = (c >= 0x8e ? 0xdb18 : 0xeeb8) + 157 * (c - 0x81) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); + return 2; + } + } + } + } + return RET_ILSEQ; +} + +static const unsigned char big5_2003_2charset_page25[29] = { + /* 0x2550 */ + 0xf9, 0xf8, 0xe6, 0xef, 0xdd, 0xe8, 0xf1, 0xdf, 0xec, 0xf5, 0xe3, 0xee, 0xf7, 0xe5, 0xe9, + 0xf2, 0xe0, 0xeb, 0xf4, 0xe2, 0xe7, 0xf0, 0xde, 0xed, 0xf6, 0xe4, 0xea, 0xf3, 0xe1, +}; + +static int big5_2003_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[2]; + int ret; + + /* Code set 0 (ASCII) */ + ret = ascii_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + /* Code set 1 (BIG5 extended) */ + switch (wc >> 8) + { + case 0x00: + if (wc == 0x00a8) + { + buf[0] = 0xc6; + buf[1] = 0xd8; + ret = 2; + break; + } + if (wc == 0x00a2 || wc == 0x00a3 || wc == 0x00a5) + return RET_ILUNI; + break; + case 0x02: + if (wc == 0x02cd) + { + buf[0] = 0xa1; + buf[1] = 0xc5; + ret = 2; + break; + } + break; + case 0x04: + return RET_ILUNI; + case 0x20: + if (wc == 0x2015) + { + buf[0] = 0xa1; + buf[1] = 0x56; + ret = 2; + break; + } + if (wc == 0x2027) + { + buf[0] = 0xa1; + buf[1] = 0x45; + ret = 2; + break; + } + if (wc == 0x20ac) + { + buf[0] = 0xa3; + buf[1] = 0xe1; + ret = 2; + break; + } + if (wc == 0x2013 || wc == 0x2022) + return RET_ILUNI; + break; + case 0x21: + if (wc >= 0x2170 && wc <= 0x2179) + { + buf[0] = 0xc6; + buf[1] = wc - 0x20bb; + ret = 2; + break; + } + break; + case 0x22: + if (wc == 0x2215) + { + buf[0] = 0xa2; + buf[1] = 0x41; + ret = 2; + break; + } + if (wc == 0x2295) + { + buf[0] = 0xa1; + buf[1] = 0xf2; + ret = 2; + break; + } + if (wc == 0x2299) + { + buf[0] = 0xa1; + buf[1] = 0xf3; + ret = 2; + break; + } + if (wc == 0x223c) + return RET_ILUNI; + break; + case 0x24: + if (wc <= 0x241f) + { + buf[0] = 0xa3; + buf[1] = wc - 0x2340; + ret = 2; + break; + } + if (wc == 0x2421) + { + buf[0] = 0xa3; + buf[1] = 0xe0; + ret = 2; + break; + } + if (wc >= 0x2460 && wc <= 0x2469) + { + buf[0] = 0xc6; + buf[1] = wc - 0x23bf; + ret = 2; + break; + } + if (wc >= 0x2474 && wc <= 0x247d) + { + buf[0] = 0xc6; + buf[1] = wc - 0x23c9; + ret = 2; + break; + } + break; + case 0x25: + if (wc == 0x2501) + { + buf[0] = 0xa2; + buf[1] = 0xa4; + ret = 2; + break; + } + if (wc == 0x251d) + { + buf[0] = 0xa2; + buf[1] = 0xa5; + ret = 2; + break; + } + if (wc == 0x2525) + { + buf[0] = 0xa2; + buf[1] = 0xa7; + ret = 2; + break; + } + if (wc == 0x253f) + { + buf[0] = 0xa2; + buf[1] = 0xa6; + ret = 2; + break; + } + if (wc >= 0x2550 && wc <= 0x256c) + { + buf[0] = 0xf9; + buf[1] = big5_2003_2charset_page25[wc - 0x2550]; + ret = 2; + break; + } + if (wc == 0x2574) + { + buf[0] = 0xa1; + buf[1] = 0x5a; + ret = 2; + break; + } + if (wc == 0x2593) + { + buf[0] = 0xf9; + buf[1] = 0xfe; + ret = 2; + break; + } + break; + case 0x26: + if (wc == 0x2609 || wc == 0x2641) + return RET_ILUNI; + break; + case 0x27: + if (wc == 0x273d) + { + buf[0] = 0xc6; + buf[1] = 0xe6; + ret = 2; + break; + } + break; + case 0x2f: + if (wc == 0x2f02) + { + buf[0] = 0xc6; + buf[1] = 0xbf; + ret = 2; + break; + } + if (wc == 0x2f03) + { + buf[0] = 0xc6; + buf[1] = 0xc0; + ret = 2; + break; + } + if (wc == 0x2f05) + { + buf[0] = 0xc6; + buf[1] = 0xc1; + ret = 2; + break; + } + if (wc == 0x2f07) + { + buf[0] = 0xc6; + buf[1] = 0xc2; + ret = 2; + break; + } + if (wc == 0x2f0c) + { + buf[0] = 0xc6; + buf[1] = 0xc3; + ret = 2; + break; + } + if (wc == 0x2f0d) + { + buf[0] = 0xc6; + buf[1] = 0xc4; + ret = 2; + break; + } + if (wc == 0x2f0e) + { + buf[0] = 0xc6; + buf[1] = 0xc5; + ret = 2; + break; + } + if (wc == 0x2f13) + { + buf[0] = 0xc6; + buf[1] = 0xc6; + ret = 2; + break; + } + if (wc == 0x2f16) + { + buf[0] = 0xc6; + buf[1] = 0xc7; + ret = 2; + break; + } + if (wc == 0x2f19) + { + buf[0] = 0xc6; + buf[1] = 0xc8; + ret = 2; + break; + } + if (wc == 0x2f1b) + { + buf[0] = 0xc6; + buf[1] = 0xc9; + ret = 2; + break; + } + if (wc == 0x2f22) + { + buf[0] = 0xc6; + buf[1] = 0xca; + ret = 2; + break; + } + if (wc == 0x2f27) + { + buf[0] = 0xc6; + buf[1] = 0xcb; + ret = 2; + break; + } + if (wc == 0x2f2e) + { + buf[0] = 0xc6; + buf[1] = 0xcc; + ret = 2; + break; + } + if (wc == 0x2f33) + { + buf[0] = 0xc6; + buf[1] = 0xcd; + ret = 2; + break; + } + if (wc == 0x2f34) + { + buf[0] = 0xc6; + buf[1] = 0xce; + ret = 2; + break; + } + if (wc == 0x2f35) + { + buf[0] = 0xc6; + buf[1] = 0xcf; + ret = 2; + break; + } + if (wc == 0x2f39) + { + buf[0] = 0xc6; + buf[1] = 0xd0; + ret = 2; + break; + } + if (wc == 0x2f3a) + { + buf[0] = 0xc6; + buf[1] = 0xd1; + ret = 2; + break; + } + if (wc == 0x2f41) + { + buf[0] = 0xc6; + buf[1] = 0xd2; + ret = 2; + break; + } + if (wc == 0x2f46) + { + buf[0] = 0xc6; + buf[1] = 0xd3; + ret = 2; + break; + } + if (wc == 0x2f67) + { + buf[0] = 0xc6; + buf[1] = 0xd4; + ret = 2; + break; + } + if (wc == 0x2f68) + { + buf[0] = 0xc6; + buf[1] = 0xd5; + ret = 2; + break; + } + if (wc == 0x2fa1) + { + buf[0] = 0xc6; + buf[1] = 0xd6; + ret = 2; + break; + } + if (wc == 0x2faa) + { + buf[0] = 0xc6; + buf[1] = 0xd7; + ret = 2; + break; + } + break; + case 0x30: + if (wc >= 0x3005 && wc <= 0x3007) + { + buf[0] = 0xc6; + buf[1] = wc - 0x2f25; + ret = 2; + break; + } + if (wc >= 0x3038 && wc <= 0x303a) + { + buf[0] = 0xa2; + buf[1] = wc - 0x2f6c; + ret = 2; + break; + } + if (wc >= 0x3041 && wc <= 0x3093) + { + if (wc < 0x3059) + { + buf[0] = 0xc6; + buf[1] = wc - 0x2f5a; + } + else + { + buf[0] = 0xc7; + buf[1] = wc - 0x3019; + } + ret = 2; + break; + } + if (wc == 0x309d) + { + buf[0] = 0xc6; + buf[1] = 0xdc; + ret = 2; + break; + } + if (wc == 0x309e) + { + buf[0] = 0xc6; + buf[1] = 0xdd; + ret = 2; + break; + } + if (wc >= 0x30a1 && wc <= 0x30f6) + { + buf[0] = 0xc7; + buf[1] = wc - (wc < 0x30a5 ? 0x3026 : 0x3004); + ret = 2; + break; + } + if (wc == 0x30fc) + { + buf[0] = 0xc6; + buf[1] = 0xe3; + ret = 2; + break; + } + if (wc == 0x30fd) + { + buf[0] = 0xc6; + buf[1] = 0xda; + ret = 2; + break; + } + if (wc == 0x30fe) + { + buf[0] = 0xc6; + buf[1] = 0xdb; + ret = 2; + break; + } + break; + case 0x53: + if (wc == 0x5344) + return RET_ILUNI; + break; + case 0x58: + if (wc == 0x58bb) + { + buf[0] = 0xf9; + buf[1] = 0xd9; + ret = 2; + break; + } + break; + case 0x5a: + if (wc == 0x5afa) + { + buf[0] = 0xf9; + buf[1] = 0xdc; + ret = 2; + break; + } + break; + case 0x5f: + if (wc == 0x5f5e) + { + buf[0] = 0xc2; + buf[1] = 0x55; + ret = 2; + break; + } + if (wc == 0x5f5d) + return RET_ILUNI; + break; + case 0x60: + if (wc == 0x6052) + { + buf[0] = 0xf9; + buf[1] = 0xda; + ret = 2; + break; + } + break; + case 0x78: + if (wc == 0x7881) + { + buf[0] = 0xf9; + buf[1] = 0xd6; + ret = 2; + break; + } + break; + case 0x7c: + if (wc == 0x7ca7) + { + buf[0] = 0xf9; + buf[1] = 0xdb; + ret = 2; + break; + } + break; + case 0x88: + if (wc == 0x88cf) + { + buf[0] = 0xf9; + buf[1] = 0xd8; + ret = 2; + break; + } + break; + case 0x92: + if (wc == 0x92b9) + { + buf[0] = 0xf9; + buf[1] = 0xd7; + ret = 2; + break; + } + break; + case 0xe0: + case 0xe1: + case 0xe2: + case 0xe3: + case 0xe4: + case 0xe5: + case 0xe6: + case 0xe7: + case 0xe8: + case 0xe9: + case 0xea: + case 0xeb: + case 0xec: + case 0xed: + case 0xee: + case 0xef: + case 0xf0: + case 0xf1: + case 0xf2: + case 0xf3: + case 0xf4: + case 0xf5: + case 0xf6: { + unsigned int i = wc - 0xe000; + if (i < 5809) + { + unsigned int c1 = i / 157; + unsigned int c2 = i % 157; + buf[0] = c1 + (c1 < 5 ? 0xfa : c1 < 24 ? 0x89 : 0x69); + buf[1] = c2 + (c2 < 0x3f ? 0x40 : 0x62); + ret = 2; + break; + } + } + break; + case 0xfe: + if (wc == 0xfe51) + { + buf[0] = 0xa1; + buf[1] = 0x4e; + ret = 2; + break; + } + if (wc == 0xfe68) + { + buf[0] = 0xa2; + buf[1] = 0x42; + ret = 2; + break; + } + break; + case 0xff: + if (wc == 0xff0f) + { + buf[0] = 0xa1; + buf[1] = 0xfe; + ret = 2; + break; + } + if (wc == 0xff3b) + { + buf[0] = 0xc6; + buf[1] = 0xe4; + ret = 2; + break; + } + if (wc == 0xff3c) + { + buf[0] = 0xa2; + buf[1] = 0x40; + ret = 2; + break; + } + if (wc == 0xff3d) + { + buf[0] = 0xc6; + buf[1] = 0xe5; + ret = 2; + break; + } + if (wc == 0xff3e) + { + buf[0] = 0xc6; + buf[1] = 0xd9; + ret = 2; + break; + } + if (wc == 0xff5e) + { + buf[0] = 0xa1; + buf[1] = 0xe3; + ret = 2; + break; + } + if (wc == 0xffe0) + { + buf[0] = 0xa2; + buf[1] = 0x46; + ret = 2; + break; + } + if (wc == 0xffe1) + { + buf[0] = 0xa2; + buf[1] = 0x47; + ret = 2; + break; + } + if (wc == 0xffe3) + { + buf[0] = 0xa1; + buf[1] = 0xc3; + ret = 2; + break; + } + if (wc == 0xffe5) + { + buf[0] = 0xa2; + buf[1] = 0x44; + ret = 2; + break; + } + if (wc == 0xff64) + return RET_ILUNI; + break; + } + if (ret == RET_ILUNI) + ret = big5_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0]; + r[1] = buf[1]; + return 2; + } + + return RET_ILUNI; +} + +#endif /* _BIG5_2003_H_ */ diff --git a/lib/converters/big5hkscs1999.h b/lib/converters/big5hkscs1999.h new file mode 100644 index 00000000..1d456faf --- /dev/null +++ b/lib/converters/big5hkscs1999.h @@ -0,0 +1,235 @@ +/** + * @file big5hkscs1999.h + * @brief BIG5-HKSCS:1999 + * @copyright Copyright (C) 1999-2002, 2006, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * BIG5-HKSCS:1999 can be downloaded from + * http://www.info.gov.hk/digital21/eng/hkscs/download.html + * http://www.info.gov.hk/digital21/eng/hkscs/index.html + * + * It extends BIG5 (without the rows 0xC6..0xC7) through the ranges + * + * 0x{88..8D}{40..7E,A1..FE} 641 characters + * 0x{8E..A0}{40..7E,A1..FE} 2898 characters + * 0x{C6..C8}{40..7E,A1..FE} 359 characters + * 0xF9{D6..FE} 41 characters + * 0x{FA..FE}{40..7E,A1..FE} 763 characters + * + * Note that some HKSCS characters are not contained in Unicode 3.2 + * and are therefore best represented as sequences of Unicode characters: + * 0x8862 U+00CA U+0304 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND MACRON + * 0x8864 U+00CA U+030C LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND CARON + * 0x88A3 U+00EA U+0304 LATIN SMALL LETTER E WITH CIRCUMFLEX AND MACRON + * 0x88A5 U+00EA U+030C LATIN SMALL LETTER E WITH CIRCUMFLEX AND CARON + */ + +#ifndef _BIG5HKSCS1999_H_ +#define _BIG5HKSCS1999_H_ + +#include "converters/ascii.h" +#include "converters/big5.h" +#include "reiconv_defines.h" + +#include "flushwc.h" // IWYU pragma: keep. +#include "hkscs1999.h" + +#include + +static int big5hkscs1999_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + ucs4_t last_wc = conv->istate; + if (last_wc) + { + /* Output the buffered character. */ + conv->istate = 0; + *pwc = last_wc; + return 0; /* Don't advance the input pointer. */ + } + else + { + unsigned char c = *s; + /* Code set 0 (ASCII) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (BIG5 extended) */ + if (c >= 0xa1 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) + { + if (!((c == 0xc6 && c2 >= 0xa1) || c == 0xc7)) + { + int ret = big5_mbtowc(conv, pwc, s, 2); + if (ret != RET_ILSEQ) + return ret; + } + } + } + } + { + int ret = hkscs1999_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + } + if (c == 0x88) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c2 == 0x62 || c2 == 0x64 || c2 == 0xa3 || c2 == 0xa5) + { + /* It's a composed character. */ + ucs4_t wc1 = ((c2 >> 3) << 2) + 0x009a; /* = 0x00ca or 0x00ea */ + ucs4_t wc2 = ((c2 & 6) << 2) + 0x02fc; /* = 0x0304 or 0x030c */ + /* We cannot output two Unicode characters at once. So, + output the first character and buffer the second one. */ + *pwc = wc1; + conv->istate = wc2; + return 2; + } + } + } + return RET_ILSEQ; + } +} + +#define big5hkscs1999_flushwc normal_flushwc + +static int big5hkscs1999_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + int count = 0; + unsigned char last = conv->ostate; + + if (last) + { + /* last is = 0x66 or = 0xa7. */ + if (wc == 0x0304 || wc == 0x030c) + { + /* Output the combined character. */ + if (n >= 2) + { + r[0] = 0x88; + r[1] = last + ((wc & 24) >> 2) - 4; /* = 0x62 or 0x64 or 0xa3 or 0xa5 */ + conv->ostate = 0; + return 2; + } + else + return RET_TOOSMALL; + } + + /* Output the buffered character. */ + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x88; + r[1] = last; + r += 2; + count = 2; + } + + /* Code set 0 (ASCII) */ + if (wc < 0x0080) + { + /* Plain ASCII character. */ + if (n > count) + { + r[0] = (unsigned char)wc; + conv->ostate = 0; + return count + 1; + } + else + return RET_TOOSMALL; + } + else + { + unsigned char buf[2]; + int ret; + + /* Code set 1 (BIG5 extended) */ + ret = big5_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (!((buf[0] == 0xc6 && buf[1] >= 0xa1) || buf[0] == 0xc7)) + { + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + } + ret = hkscs1999_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if ((wc & ~0x0020) == 0x00ca) + { + /* A possible first character of a multi-character sequence. We have to + buffer it. */ + if (!(buf[0] == 0x88 && (buf[1] == 0x66 || buf[1] == 0xa7))) + abort(); + conv->ostate = buf[1]; /* = 0x66 or = 0xa7 */ + return count + 0; + } + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + return RET_ILUNI; + } +} + +static int big5hkscs1999_reset(conv_t conv, unsigned char *r, size_t n) +{ + unsigned char last = conv->ostate; + + if (last) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x88; + r[1] = last; + /* conv->ostate = 0; will be done by the caller */ + return 2; + } + else + return 0; +} + +#endif /* _BIG5HKSCS1999_H_ */ diff --git a/lib/converters/big5hkscs2001.h b/lib/converters/big5hkscs2001.h new file mode 100644 index 00000000..c6f2bf93 --- /dev/null +++ b/lib/converters/big5hkscs2001.h @@ -0,0 +1,257 @@ +/** + * @file big5hkscs2001.h + * @brief BIG5-HKSCS:2001 + * @copyright Copyright (C) 1999-2002, 2006, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * BIG5-HKSCS:2001 can be downloaded from + * http://www.info.gov.hk/digital21/eng/hkscs/download.html + * http://www.info.gov.hk/digital21/eng/hkscs/index.html + * + * It extends BIG5-HKSCS:1999 through 116 characters. + * + * It extends BIG5 (without the rows 0xC6..0xC7) through the ranges + * + * 0x{88..8D}{40..7E,A1..FE} 757 characters + * 0x{8E..A0}{40..7E,A1..FE} 2898 characters + * 0x{C6..C8}{40..7E,A1..FE} 359 characters + * 0xF9{D6..FE} 41 characters + * 0x{FA..FE}{40..7E,A1..FE} 763 characters + * + * Note that some HKSCS characters are not contained in Unicode 3.2 + * and are therefore best represented as sequences of Unicode characters: + * 0x8862 U+00CA U+0304 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND MACRON + * 0x8864 U+00CA U+030C LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND CARON + * 0x88A3 U+00EA U+0304 LATIN SMALL LETTER E WITH CIRCUMFLEX AND MACRON + * 0x88A5 U+00EA U+030C LATIN SMALL LETTER E WITH CIRCUMFLEX AND CARON + */ + +#ifndef _BIG5HKSCS2001_H_ +#define _BIG5HKSCS2001_H_ + +#include "converters/ascii.h" +#include "converters/big5.h" +#include "converters/hkscs1999.h" +#include "reiconv_defines.h" +#include "flushwc.h" // IWYU pragma: keep +#include "hkscs2001.h" + +#include + +static int big5hkscs2001_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + ucs4_t last_wc = conv->istate; + if (last_wc) + { + /* Output the buffered character. */ + conv->istate = 0; + *pwc = last_wc; + return 0; /* Don't advance the input pointer. */ + } + else + { + unsigned char c = *s; + /* Code set 0 (ASCII) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (BIG5 extended) */ + if (c >= 0xa1 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) + { + if (!((c == 0xc6 && c2 >= 0xa1) || c == 0xc7)) + { + int ret = big5_mbtowc(conv, pwc, s, 2); + if (ret != RET_ILSEQ) + return ret; + } + } + } + } + { + int ret = hkscs1999_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + } + { + int ret = hkscs2001_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + } + if (c == 0x88) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c2 == 0x62 || c2 == 0x64 || c2 == 0xa3 || c2 == 0xa5) + { + /* It's a composed character. */ + ucs4_t wc1 = ((c2 >> 3) << 2) + 0x009a; /* = 0x00ca or 0x00ea */ + ucs4_t wc2 = ((c2 & 6) << 2) + 0x02fc; /* = 0x0304 or 0x030c */ + /* We cannot output two Unicode characters at once. So, + output the first character and buffer the second one. */ + *pwc = wc1; + conv->istate = wc2; + return 2; + } + } + } + return RET_ILSEQ; + } +} + +#define big5hkscs2001_flushwc normal_flushwc + +static int big5hkscs2001_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + int count = 0; + unsigned char last = conv->ostate; + + if (last) + { + /* last is = 0x66 or = 0xa7. */ + if (wc == 0x0304 || wc == 0x030c) + { + /* Output the combined character. */ + if (n >= 2) + { + r[0] = 0x88; + r[1] = last + ((wc & 24) >> 2) - 4; /* = 0x62 or 0x64 or 0xa3 or 0xa5 */ + conv->ostate = 0; + return 2; + } + else + return RET_TOOSMALL; + } + + /* Output the buffered character. */ + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x88; + r[1] = last; + r += 2; + count = 2; + } + + /* Code set 0 (ASCII) */ + if (wc < 0x0080) + { + /* Plain ASCII character. */ + if (n > count) + { + r[0] = (unsigned char)wc; + conv->ostate = 0; + return count + 1; + } + else + return RET_TOOSMALL; + } + else + { + unsigned char buf[2]; + int ret; + + /* Code set 1 (BIG5 extended) */ + ret = big5_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (!((buf[0] == 0xc6 && buf[1] >= 0xa1) || buf[0] == 0xc7)) + { + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + } + ret = hkscs1999_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if ((wc & ~0x0020) == 0x00ca) + { + /* A possible first character of a multi-character sequence. We have to + buffer it. */ + if (!(buf[0] == 0x88 && (buf[1] == 0x66 || buf[1] == 0xa7))) + abort(); + conv->ostate = buf[1]; /* = 0x66 or = 0xa7 */ + return count + 0; + } + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + ret = hkscs2001_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + return RET_ILUNI; + } +} + +static int big5hkscs2001_reset(conv_t conv, unsigned char *r, size_t n) +{ + unsigned char last = conv->ostate; + + if (last) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x88; + r[1] = last; + /* conv->ostate = 0; will be done by the caller */ + return 2; + } + else + return 0; +} + +#endif /* _BIG5HKSCS2001_H_ */ diff --git a/lib/converters/big5hkscs2004.h b/lib/converters/big5hkscs2004.h new file mode 100644 index 00000000..9282126d --- /dev/null +++ b/lib/converters/big5hkscs2004.h @@ -0,0 +1,279 @@ +/** + * @file big5hkscs2004.h + * @brief BIG5-HKSCS:2004 + * @copyright Copyright (C) 1999-2002, 2006, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * BIG5-HKSCS:2004 can be downloaded from + * http://www.info.gov.hk/digital21/eng/hkscs/download.html + * http://www.info.gov.hk/digital21/eng/hkscs/index.html + * + * It extends BIG5-HKSCS:2001 through 123 characters. + * + * It extends BIG5 (without the rows 0xC6..0xC7) through the ranges + * + * 0x{87..8D}{40..7E,A1..FE} 880 characters + * 0x{8E..A0}{40..7E,A1..FE} 2898 characters + * 0x{C6..C8}{40..7E,A1..FE} 359 characters + * 0xF9{D6..FE} 41 characters + * 0x{FA..FE}{40..7E,A1..FE} 763 characters + * + * Note that some HKSCS characters are not contained in Unicode 3.2 + * and are therefore best represented as sequences of Unicode characters: + * 0x8862 U+00CA U+0304 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND MACRON + * 0x8864 U+00CA U+030C LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND CARON + * 0x88A3 U+00EA U+0304 LATIN SMALL LETTER E WITH CIRCUMFLEX AND MACRON + * 0x88A5 U+00EA U+030C LATIN SMALL LETTER E WITH CIRCUMFLEX AND CARON + */ + +#ifndef _BIG5HKSCS2004_H_ +#define _BIG5HKSCS2004_H_ + +#include "converters/ascii.h" +#include "converters/big5.h" +#include "converters/hkscs1999.h" +#include "converters/hkscs2001.h" +#include "reiconv_defines.h" + +#include "flushwc.h" // IWYU pragma: keep. +#include "hkscs2004.h" + +#include + +static int big5hkscs2004_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + ucs4_t last_wc = conv->istate; + if (last_wc) + { + /* Output the buffered character. */ + conv->istate = 0; + *pwc = last_wc; + return 0; /* Don't advance the input pointer. */ + } + else + { + unsigned char c = *s; + /* Code set 0 (ASCII) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (BIG5 extended) */ + if (c >= 0xa1 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) + { + if (!((c == 0xc6 && c2 >= 0xa1) || c == 0xc7)) + { + int ret = big5_mbtowc(conv, pwc, s, 2); + if (ret != RET_ILSEQ) + return ret; + } + } + } + } + { + int ret = hkscs1999_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + } + { + int ret = hkscs2001_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + } + { + int ret = hkscs2004_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + } + if (c == 0x88) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c2 == 0x62 || c2 == 0x64 || c2 == 0xa3 || c2 == 0xa5) + { + /* It's a composed character. */ + ucs4_t wc1 = ((c2 >> 3) << 2) + 0x009a; /* = 0x00ca or 0x00ea */ + ucs4_t wc2 = ((c2 & 6) << 2) + 0x02fc; /* = 0x0304 or 0x030c */ + /* We cannot output two Unicode characters at once. So, + output the first character and buffer the second one. */ + *pwc = wc1; + conv->istate = wc2; + return 2; + } + } + } + return RET_ILSEQ; + } +} + +#define big5hkscs2004_flushwc normal_flushwc + +static int big5hkscs2004_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + int count = 0; + unsigned char last = conv->ostate; + + if (last) + { + /* last is = 0x66 or = 0xa7. */ + if (wc == 0x0304 || wc == 0x030c) + { + /* Output the combined character. */ + if (n >= 2) + { + r[0] = 0x88; + r[1] = last + ((wc & 24) >> 2) - 4; /* = 0x62 or 0x64 or 0xa3 or 0xa5 */ + conv->ostate = 0; + return 2; + } + else + return RET_TOOSMALL; + } + + /* Output the buffered character. */ + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x88; + r[1] = last; + r += 2; + count = 2; + } + + /* Code set 0 (ASCII) */ + if (wc < 0x0080) + { + /* Plain ASCII character. */ + if (n > count) + { + r[0] = (unsigned char)wc; + conv->ostate = 0; + return count + 1; + } + else + return RET_TOOSMALL; + } + else + { + unsigned char buf[2]; + int ret; + + /* Code set 1 (BIG5 extended) */ + ret = big5_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (!((buf[0] == 0xc6 && buf[1] >= 0xa1) || buf[0] == 0xc7)) + { + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + } + ret = hkscs1999_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if ((wc & ~0x0020) == 0x00ca) + { + /* A possible first character of a multi-character sequence. We have to + buffer it. */ + if (!(buf[0] == 0x88 && (buf[1] == 0x66 || buf[1] == 0xa7))) + abort(); + conv->ostate = buf[1]; /* = 0x66 or = 0xa7 */ + return count + 0; + } + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + ret = hkscs2001_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + ret = hkscs2004_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + return RET_ILUNI; + } +} + +static int big5hkscs2004_reset(conv_t conv, unsigned char *r, size_t n) +{ + unsigned char last = conv->ostate; + + if (last) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x88; + r[1] = last; + /* conv->ostate = 0; will be done by the caller */ + return 2; + } + else + return 0; +} + +#endif /* _BIG5HKSCS2004_H_ */ diff --git a/lib/converters/big5hkscs2008.h b/lib/converters/big5hkscs2008.h new file mode 100644 index 00000000..6cd7aa59 --- /dev/null +++ b/lib/converters/big5hkscs2008.h @@ -0,0 +1,299 @@ +/** + * @file big5hkscs2008.h + * @brief BIG5-HKSCS:2008 + * @copyright Copyright (C) 1999-2002, 2006, 2010 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * BIG5-HKSCS:2008 can be downloaded from + * http://www.ogcio.gov.hk/ccli/eng/hkscs/download.html + * http://www.ogcio.gov.hk/ccli/eng/hkscs/introduction.html + * + * It extends BIG5-HKSCS:2004 through 68 characters. + * + * It extends BIG5 (without the rows 0xC6..0xC7) through the ranges + * + * 0x{87..8D}{40..7E,A1..FE} 880 characters + * 0x{8E..A0}{40..7E,A1..FE} 2898 characters + * 0x{C6..C8}{40..7E,A1..FE} 359 characters + * 0xF9{D6..FE} 41 characters + * 0x{FA..FE}{40..7E,A1..FE} 763 characters + * + * Note that some HKSCS characters are not contained in Unicode 3.2 + * and are therefore best represented as sequences of Unicode characters: + * 0x8862 U+00CA U+0304 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND MACRON + * 0x8864 U+00CA U+030C LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND CARON + * 0x88A3 U+00EA U+0304 LATIN SMALL LETTER E WITH CIRCUMFLEX AND MACRON + * 0x88A5 U+00EA U+030C LATIN SMALL LETTER E WITH CIRCUMFLEX AND CARON + */ + +#ifndef _BIG5HKSCS2008_H_ +#define _BIG5HKSCS2008_H_ + +#include "converters/ascii.h" +#include "converters/big5.h" +#include "converters/hkscs1999.h" +#include "converters/hkscs2001.h" +#include "converters/hkscs2004.h" +#include "flushwc.h" // IWYU pragma: keep +#include "hkscs2008.h" +#include "reiconv_defines.h" + +#include + +static int big5hkscs2008_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + ucs4_t last_wc = conv->istate; + if (last_wc) + { + /* Output the buffered character. */ + conv->istate = 0; + *pwc = last_wc; + return 0; /* Don't advance the input pointer. */ + } + else + { + unsigned char c = *s; + /* Code set 0 (ASCII) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (BIG5 extended) */ + if (c >= 0xa1 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) + { + if (!((c == 0xc6 && c2 >= 0xa1) || c == 0xc7)) + { + int ret = big5_mbtowc(conv, pwc, s, 2); + if (ret != RET_ILSEQ) + return ret; + } + } + } + } + { + int ret = hkscs1999_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + } + { + int ret = hkscs2001_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + } + { + int ret = hkscs2004_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + } + { + int ret = hkscs2008_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + } + if (c == 0x88) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c2 == 0x62 || c2 == 0x64 || c2 == 0xa3 || c2 == 0xa5) + { + /* It's a composed character. */ + ucs4_t wc1 = ((c2 >> 3) << 2) + 0x009a; /* = 0x00ca or 0x00ea */ + ucs4_t wc2 = ((c2 & 6) << 2) + 0x02fc; /* = 0x0304 or 0x030c */ + /* We cannot output two Unicode characters at once. So, + output the first character and buffer the second one. */ + *pwc = wc1; + conv->istate = wc2; + return 2; + } + } + } + return RET_ILSEQ; + } +} + +#define big5hkscs2008_flushwc normal_flushwc + +static int big5hkscs2008_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + int count = 0; + unsigned char last = conv->ostate; + + if (last) + { + /* last is = 0x66 or = 0xa7. */ + if (wc == 0x0304 || wc == 0x030c) + { + /* Output the combined character. */ + if (n >= 2) + { + r[0] = 0x88; + r[1] = last + ((wc & 24) >> 2) - 4; /* = 0x62 or 0x64 or 0xa3 or 0xa5 */ + conv->ostate = 0; + return 2; + } + else + return RET_TOOSMALL; + } + + /* Output the buffered character. */ + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x88; + r[1] = last; + r += 2; + count = 2; + } + + /* Code set 0 (ASCII) */ + if (wc < 0x0080) + { + /* Plain ASCII character. */ + if (n > count) + { + r[0] = (unsigned char)wc; + conv->ostate = 0; + return count + 1; + } + else + return RET_TOOSMALL; + } + else + { + unsigned char buf[2]; + int ret; + + /* Code set 1 (BIG5 extended) */ + ret = big5_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (!((buf[0] == 0xc6 && buf[1] >= 0xa1) || buf[0] == 0xc7)) + { + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + } + ret = hkscs1999_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if ((wc & ~0x0020) == 0x00ca) + { + /* A possible first character of a multi-character sequence. We have to + buffer it. */ + if (!(buf[0] == 0x88 && (buf[1] == 0x66 || buf[1] == 0xa7))) + abort(); + conv->ostate = buf[1]; /* = 0x66 or = 0xa7 */ + return count + 0; + } + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + ret = hkscs2001_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + ret = hkscs2004_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + ret = hkscs2008_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n >= count + 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + return RET_ILUNI; + } +} + +static int big5hkscs2008_reset(conv_t conv, unsigned char *r, size_t n) +{ + unsigned char last = conv->ostate; + + if (last) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x88; + r[1] = last; + /* conv->ostate = 0; will be done by the caller */ + return 2; + } + else + return 0; +} + +#endif /* _BIG5HKSCS2008_H_ */ diff --git a/lib/converters/c99.h b/lib/converters/c99.h new file mode 100644 index 00000000..673d1436 --- /dev/null +++ b/lib/converters/c99.h @@ -0,0 +1,150 @@ +/** + * @file c99.h + * @brief C99 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * This is ASCII with \uXXXX and \UXXXXXXXX escape sequences, denoting Unicode + * characters. See ISO/IEC 9899:1999, section 6.4.3. + * The treatment of control characters in the range U+0080..U+009F is not + * specified; we pass them through unmodified. + */ + +#ifndef _C99_H_ +#define _C99_H_ + +#include "reiconv_defines.h" + +static int c99_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c; + ucs4_t wc; + int i; + + c = s[0]; + if (c < 0xa0) + { + if (c != '\\') + { + *pwc = c; + return 1; + } + if (n < 2) + return RET_TOOFEW(0); + c = s[1]; + if (c == 'u') + { + wc = 0; + for (i = 2; i < 6; i++) + { + if (n <= i) + return RET_TOOFEW(0); + c = s[i]; + if (c >= '0' && c <= '9') + c -= '0'; + else if (c >= 'A' && c <= 'Z') + c -= 'A' - 10; + else if (c >= 'a' && c <= 'z') + c -= 'a' - 10; + else + goto simply_backslash; + wc |= (ucs4_t)c << (4 * (5 - i)); + } + if ((wc >= 0x00a0 && !(wc >= 0xd800 && wc < 0xe000)) || wc == 0x0024 || wc == 0x0040 || wc == 0x0060) + { + *pwc = wc; + return 6; + } + } + else if (c == 'U') + { + wc = 0; + for (i = 2; i < 10; i++) + { + if (n <= i) + return RET_TOOFEW(0); + c = s[i]; + if (c >= '0' && c <= '9') + c -= '0'; + else if (c >= 'A' && c <= 'Z') + c -= 'A' - 10; + else if (c >= 'a' && c <= 'z') + c -= 'a' - 10; + else + goto simply_backslash; + wc |= (ucs4_t)c << (4 * (9 - i)); + } + if ((wc >= 0x00a0 && !(wc >= 0xd800 && wc < 0xe000)) || wc == 0x0024 || wc == 0x0040 || wc == 0x0060) + { + *pwc = wc; + return 10; + } + } + else + goto simply_backslash; + } + return RET_ILSEQ; +simply_backslash: + *pwc = '\\'; + return 1; +} + +static int c99_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0xa0) + { + *r = wc; + return 1; + } + else + { + int result; + unsigned char u; + if (wc < 0x10000) + { + result = 6; + u = 'u'; + } + else + { + result = 10; + u = 'U'; + } + if (n >= result) + { + int count; + r[0] = '\\'; + r[1] = u; + r += 2; + for (count = result - 3; count >= 0; count--) + { + unsigned int i = (wc >> (4 * count)) & 0x0f; + *r++ = (i < 10 ? '0' + i : 'a' - 10 + i); + } + return result; + } + else + return RET_TOOSMALL; + } +} + +#endif /* _C99_H_ */ diff --git a/lib/converters/ces_big5.h b/lib/converters/ces_big5.h new file mode 100644 index 00000000..238c95e7 --- /dev/null +++ b/lib/converters/ces_big5.h @@ -0,0 +1,82 @@ +/** + * @file ces_big5.h + * @brief BIG-5 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _CES_BIG5_H_ +#define _CES_BIG5_H_ + +#include "converters/ascii.h" +#include "converters/big5.h" +#include "reiconv_defines.h" + +#include + +static int ces_big5_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + /* Code set 0 (ASCII) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (BIG5) */ + if (c >= 0xa1 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) + return big5_mbtowc(conv, pwc, s, 2); + else + return RET_ILSEQ; + } + } + return RET_ILSEQ; +} + +static int ces_big5_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[2]; + int ret; + + /* Code set 0 (ASCII) */ + ret = ascii_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + /* Code set 1 (BIG5) */ + ret = big5_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0]; + r[1] = buf[1]; + return 2; + } + + return RET_ILUNI; +} + +#endif /* _CES_BIG5_H_ */ diff --git a/lib/converters/ces_gbk.h b/lib/converters/ces_gbk.h new file mode 100644 index 00000000..ee6882bd --- /dev/null +++ b/lib/converters/ces_gbk.h @@ -0,0 +1,77 @@ +/** + * @file ces_gbk.h + * @brief GBK + * @copyright Copyright (C) 1999-2001, 2005, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _CES_GBK_H_ +#define _CES_GBK_H_ + +#include "converters/ascii.h" +#include "converters/gbk.h" +#include "reiconv_defines.h" + +#include + +static int ces_gbk_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + + /* Code set 0 (ASCII or GB 1988-89) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (GBK) */ + if (c >= 0x81 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + return gbk_mbtowc(conv, pwc, s, 2); + } + return RET_ILSEQ; +} + +static int ces_gbk_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[2]; + int ret; + + /* Code set 0 (ASCII or GB 1988-89) */ + ret = ascii_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + /* Code set 1 (GBK) */ + ret = gbk_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0]; + r[1] = buf[1]; + return 2; + } + + return RET_ILUNI; +} + +#endif /* _CES_GBK_H_ */ diff --git a/lib/cjk_variants.h b/lib/converters/cjk_variants.h similarity index 99% rename from lib/cjk_variants.h rename to lib/converters/cjk_variants.h index d4b5543f..67bbcd0c 100644 --- a/lib/cjk_variants.h +++ b/lib/converters/cjk_variants.h @@ -1,5 +1,10 @@ +/** + * @file cjk_variants.h + * @brief CJK variants table + * @copyright Copyright (C) 1999-2001 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,12 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CJK variants table - */ +#ifndef _CJK_VARIANTS_H_ +#define _CJK_VARIANTS_H_ static const unsigned short cjk_variants[12038] = { 0x9e44, 0x1e2a, 0x200b, 0xcb87, 0xaf0c, 0x9e0a, 0x9e0b, 0xd42c, @@ -4238,3 +4242,5 @@ static const short cjk_variants_indx[0x5200] = { -1, -1, -1, -1, -1, -1, -1, -1, }; + +#endif /* _CJK_VARIANTS_H_ */ diff --git a/lib/cns11643.h b/lib/converters/cns11643.h similarity index 57% rename from lib/cns11643.h rename to lib/converters/cns11643.h index c3c3c627..5b4f1f1c 100644 --- a/lib/cns11643.h +++ b/lib/converters/cns11643.h @@ -1,5 +1,10 @@ +/** + * @file cns11643.h + * @brief CNS 11643-1992 + * @copyright Copyright (C) 1999-2001 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,28 +18,31 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CNS 11643-1992 - */ - /* ISO-2022-CN and EUC-TW use CNS 11643-1992 planes 1 to 7. We also * have a table for the older plane 15. We use a trick to keep the * Unicode -> CNS 11643 table as small as possible (see cns11643_inv.h). */ -#include "cns11643_1.h" -#include "cns11643_2.h" -#include "cns11643_3.h" -#include "cns11643_4.h" -#include "cns11643_5.h" -#include "cns11643_6.h" -#include "cns11643_7.h" -#include "cns11643_15.h" -#include "cns11643_inv.h" +#ifndef _CNS11643_H_ +#define _CNS11643_H_ + +#include "reiconv_defines.h" // IWYU pragma: keep + +#include "cns11643_1.h" // IWYU pragma: keep +#include "cns11643_2.h" // IWYU pragma: keep +#include "cns11643_3.h" // IWYU pragma: keep +#include "cns11643_4.h" // IWYU pragma: keep +#include "cns11643_5.h" // IWYU pragma: keep +#include "cns11643_6.h" // IWYU pragma: keep +#include "cns11643_7.h" // IWYU pragma: keep +#include "cns11643_15.h" // IWYU pragma: keep +#include "cns11643_inv.h" // IWYU pragma: keep /* Returns the plane number (1,...,7,15) in r[0], the two bytes in r[1],r[2]. */ #define cns11643_wctomb cns11643_inv_wctomb + +#endif /* _CNS11643_H_ */ diff --git a/lib/cns11643_1.h b/lib/converters/cns11643_1.h similarity index 96% rename from lib/cns11643_1.h rename to lib/converters/cns11643_1.h index 80349fb5..66a3f606 100644 --- a/lib/cns11643_1.h +++ b/lib/converters/cns11643_1.h @@ -1,5 +1,10 @@ +/** + * @file cns11643_1.h + * @brief CNS 11643-1992 plane 1 + * @copyright Copyright (C) 1999-2005, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2005, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CNS 11643-1992 plane 1 - */ +#ifndef _CNS11643_1_H_ +#define _CNS11643_1_H_ + +#include "reiconv_defines.h" static const unsigned short cns11643_1_2uni_page21[500] = { /* 0x21 */ @@ -852,41 +858,50 @@ static const unsigned short cns11643_1_2uni_page44[5401] = { 0x9e1b, 0x9e1e, 0x7c72, }; -static int -cns11643_1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cns11643_1_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x21 && c1 <= 0x27) || (c1 == 0x42) || (c1 >= 0x44 && c1 <= 0x7d)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 < 0x7f) { - unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); - unsigned short wc = 0xfffd; - if (i < 3102) { - if (i < 500) - wc = cns11643_1_2uni_page21[i]; - else if (i == 571) - wc = 0x4ea0; - else if (i == 578) - wc = 0x51ab; - else if (i == 583) - wc = 0x52f9; - } else if (i < 3290) { - if (i < 3136) - wc = cns11643_1_2uni_page42[i-3102]; - } else { - if (i < 8691) - wc = cns11643_1_2uni_page44[i-3290]; - } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; + unsigned char c1 = s[0]; + if ((c1 >= 0x21 && c1 <= 0x27) || (c1 == 0x42) || (c1 >= 0x44 && c1 <= 0x7d)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 < 0x7f) + { + unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); + unsigned short wc = 0xfffd; + if (i < 3102) + { + if (i < 500) + wc = cns11643_1_2uni_page21[i]; + else if (i == 571) + wc = 0x4ea0; + else if (i == 578) + wc = 0x51ab; + else if (i == 583) + wc = 0x52f9; + } + else if (i < 3290) + { + if (i < 3136) + wc = cns11643_1_2uni_page42[i - 3102]; + } + else + { + if (i < 8691) + wc = cns11643_1_2uni_page44[i - 3290]; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } +#endif /* _CNS11643_1_H_ */ diff --git a/lib/cns11643_15.h b/lib/converters/cns11643_15.h similarity index 98% rename from lib/cns11643_15.h rename to lib/converters/cns11643_15.h index 2bbb128a..cff72076 100644 --- a/lib/cns11643_15.h +++ b/lib/converters/cns11643_15.h @@ -1,5 +1,10 @@ +/** + * @file cns11643_15.h + * @brief CNS 11643-1992 plane 15 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CNS 11643-1992 plane 15 - */ +#ifndef _CNS11643_15_H_ +#define _CNS11643_15_H_ -static const unsigned short cns11643_15_2uni_page21[7169] = { +#include "reiconv_defines.h" + +static const unsigned short cns11643_15_2uni_page21[7169] = +{ /* 0x21 */ 0x5302, 0x538c, 0x53d4, 0x54a5, 0x5392, 0x5393, 0x53d8, 0x53d9, 0x54a7, 0x592b, 0x592c, 0x592d, 0x5930, 0x592e, 0x59ab, 0x1a01, @@ -1052,31 +1059,34 @@ static const ucs4_t cns11643_15_2uni_upages[253] = { 0x2a500, 0x2a600, 0x2f800, 0x2f900, 0x2fa00, }; -static int -cns11643_15_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cns11643_15_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x21 && c1 <= 0x6d)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 < 0x7f) { - unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); - ucs4_t wc = 0xfffd; - unsigned short swc; + unsigned char c1 = s[0]; + if ((c1 >= 0x21 && c1 <= 0x6d)) + { + if (n >= 2) { - if (i < 7169) - swc = cns11643_15_2uni_page21[i], - wc = cns11643_15_2uni_upages[swc>>8] | (swc & 0xff); - } - if (wc != 0xfffd) { - *pwc = wc; - return 2; + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 < 0x7f) + { + unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); + ucs4_t wc = 0xfffd; + unsigned short swc; + { + if (i < 7169) + swc = cns11643_15_2uni_page21[i], wc = cns11643_15_2uni_upages[swc >> 8] | (swc & 0xff); + } + if (wc != 0xfffd) + { + *pwc = wc; + return 2; + } + } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } +#endif /* _CNS11643_15_H_ */ diff --git a/lib/cns11643_2.h b/lib/converters/cns11643_2.h similarity index 98% rename from lib/cns11643_2.h rename to lib/converters/cns11643_2.h index 1426e640..6814a081 100644 --- a/lib/cns11643_2.h +++ b/lib/converters/cns11643_2.h @@ -1,5 +1,10 @@ +/** + * @file cns11643_2.h + * @brief CNS 11643-1992 plane 2 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CNS 11643-1992 plane 2 - */ +#ifndef _CNS11643_2_H_ +#define _CNS11643_2_H_ -static const unsigned short cns11643_2_2uni_page21[7650] = { +#include "reiconv_defines.h" + +static const unsigned short cns11643_2_2uni_page21[7650] = +{ /* 0x21 */ 0x4e42, 0x4e5c, 0x51f5, 0x531a, 0x5382, 0x4e07, 0x4e0c, 0x4e47, 0x4e8d, 0x56d7, 0x5c6e, 0x5f73, 0x4e0f, 0x5187, 0x4e0e, 0x4e2e, @@ -1083,29 +1090,33 @@ static const unsigned short cns11643_2_2uni_page21[7650] = { 0x9ea4, 0x9f7e, 0x9f49, 0x9f98, }; -static int -cns11643_2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cns11643_2_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x21 && c1 <= 0x72)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 < 0x7f) { - unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); - unsigned short wc = 0xfffd; + unsigned char c1 = s[0]; + if ((c1 >= 0x21 && c1 <= 0x72)) + { + if (n >= 2) { - if (i < 7650) - wc = cns11643_2_2uni_page21[i]; - } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 < 0x7f) + { + unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); + unsigned short wc = 0xfffd; + { + if (i < 7650) + wc = cns11643_2_2uni_page21[i]; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } +#endif /* _CNS11643_2_H_ */ diff --git a/lib/cns11643_3.h b/lib/converters/cns11643_3.h similarity index 97% rename from lib/cns11643_3.h rename to lib/converters/cns11643_3.h index 20e55de6..3af4b9c0 100644 --- a/lib/cns11643_3.h +++ b/lib/converters/cns11643_3.h @@ -1,5 +1,10 @@ +/** + * @file cns11643_3.h + * @brief CNS 11643-1992 plane 3 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CNS 11643-1992 plane 3 - */ +#ifndef _CNS11643_3_H_ +#define _CNS11643_3_H_ -static const unsigned short cns11643_3_2uni_page21[6148] = { +#include "reiconv_defines.h" + +static const unsigned short cns11643_3_2uni_page21[6148] = +{ /* 0x21 */ 0x1a28, 0x1a36, 0x1a3f, 0x1a85, 0x1a05, 0x1a04, 0x1d82, 0x1d96, 0x1f38, 0x1f69, 0x1fb6, 0x1a2a, 0x1a87, 0x1a49, 0x1de2, 0x1a46, @@ -939,35 +946,40 @@ static const ucs4_t cns11643_3_2uni_upages[136] = { 0x25900, 0x25c00, 0x26500, 0x28c00, 0x29900, 0x2f800, 0x2f900, 0x2fa00, }; -static int -cns11643_3_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cns11643_3_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x21 && c1 <= 0x62) || (c1 >= 0x64 && c1 <= 0x67)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 < 0x7f) { - unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); - ucs4_t wc = 0xfffd; - unsigned short swc; - if (i < 6298) { - if (i < 6148) - swc = cns11643_3_2uni_page21[i], - wc = cns11643_3_2uni_upages[swc>>8] | (swc & 0xff); - } else { - if (i < 6590) - swc = cns11643_3_2uni_page64[i-6298], - wc = cns11643_3_2uni_upages[swc>>8] | (swc & 0xff); - } - if (wc != 0xfffd) { - *pwc = wc; - return 2; + unsigned char c1 = s[0]; + if ((c1 >= 0x21 && c1 <= 0x62) || (c1 >= 0x64 && c1 <= 0x67)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 < 0x7f) + { + unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); + ucs4_t wc = 0xfffd; + unsigned short swc; + if (i < 6298) + { + if (i < 6148) + swc = cns11643_3_2uni_page21[i], wc = cns11643_3_2uni_upages[swc >> 8] | (swc & 0xff); + } + else + { + if (i < 6590) + swc = cns11643_3_2uni_page64[i - 6298], wc = cns11643_3_2uni_upages[swc >> 8] | (swc & 0xff); + } + if (wc != 0xfffd) + { + *pwc = wc; + return 2; + } + } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } +#endif /* _CNS11643_3_H_ */ diff --git a/lib/converters/cns11643_4.h b/lib/converters/cns11643_4.h new file mode 100644 index 00000000..432722d9 --- /dev/null +++ b/lib/converters/cns11643_4.h @@ -0,0 +1,70 @@ +/** + * @file cns11643_4.h + * @brief CNS 11643-1992 plane 4 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * The table has been split into two parts. Each part's entries fit it 16 bits. + * But the combined table would need 17 bits per entry. + */ + +#ifndef _CNS11643_4_H_ +#define _CNS11643_4_H_ + +#include "reiconv_defines.h" + +#include "cns11643_4a.h" +#include "cns11643_4b.h" + +static int cns11643_4_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c1 = s[0]; + if ((c1 >= 0x21 && c1 <= 0x6e)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 < 0x7f) + { + unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); + ucs4_t wc = 0xfffd; + unsigned short swc; + { + if (i < 2914) + swc = cns11643_4a_2uni_page21[i], wc = cns11643_4a_2uni_upages[swc >> 8] | (swc & 0xff); + else if (i < 7298) + swc = cns11643_4b_2uni_page40[i - 2914], wc = cns11643_4b_2uni_upages[swc >> 8] | (swc & 0xff); + } + if (wc != 0xfffd) + { + *pwc = wc; + return 2; + } + } + return RET_ILSEQ; + } + return RET_TOOFEW(0); + } + return RET_ILSEQ; +} + +#endif /* _CNS11643_4_H_ */ diff --git a/lib/cns11643_4a.h b/lib/converters/cns11643_4a.h similarity index 98% rename from lib/cns11643_4a.h rename to lib/converters/cns11643_4a.h index 956f2a74..bacedc12 100644 --- a/lib/cns11643_4a.h +++ b/lib/converters/cns11643_4a.h @@ -1,5 +1,10 @@ +/** + * @file cns11643_4a.h + * @brief CNS 11643-1992 plane 4 part a + * @copyright Copyright (C) 1999-2002 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CNS 11643-1992 plane 4 part a - */ +#ifndef _CNS11643_4A_H_ +#define _CNS11643_4A_H_ + +#include "reiconv_defines.h" -static const unsigned short cns11643_4a_2uni_page21[2914] = { +static const unsigned short cns11643_4a_2uni_page21[2914] = +{ /* 0x21 */ 0x5a86, 0x1840, 0x1841, 0x185a, 0x75e8, 0x1802, 0x1829, 0x5b0e, 0x6027, 0x1c02, 0x013e, 0x27dc, 0x5f3c, 0x6075, 0xd128, 0x1d42, @@ -457,3 +464,4 @@ static const ucs4_t cns11643_4a_2uni_upages[212] = { 0x29d00, 0x2f800, 0x2f900, 0x2fa00, }; +#endif /* _CNS11643_4A_H_ */ diff --git a/lib/cns11643_4b.h b/lib/converters/cns11643_4b.h similarity index 98% rename from lib/cns11643_4b.h rename to lib/converters/cns11643_4b.h index e7e010f5..cd519798 100644 --- a/lib/cns11643_4b.h +++ b/lib/converters/cns11643_4b.h @@ -1,5 +1,10 @@ +/** + * @file cns11643_4b.h + * @brief CNS 11643-1992 plane 4 part b + * @copyright Copyright (C) 1999-2002 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CNS 11643-1992 plane 4 part b - */ +#ifndef _CNS11643_4B_H_ +#define _CNS11643_4B_H_ + +#include "reiconv_defines.h" -static const unsigned short cns11643_4b_2uni_page40[4384] = { +static const unsigned short cns11643_4b_2uni_page40[4384] = +{ /* 0x40 */ 0xb65b, 0xb66a, 0x1011, 0xb668, 0x101b, 0x1012, 0x100e, 0x1015, 0x3f68, 0x1010, 0xb681, 0x1017, 0x4046, 0x4043, 0x1070, 0x10ed, @@ -631,7 +638,8 @@ static const unsigned short cns11643_4b_2uni_page40[4384] = { 0x1911, 0x19ab, 0x189c, 0xdfd4, }; -static const ucs4_t cns11643_4b_2uni_upages[248] = { +static const ucs4_t cns11643_4b_2uni_upages[248] = +{ 0x03400, 0x03500, 0x03600, 0x03700, 0x03800, 0x03900, 0x03a00, 0x03b00, 0x03c00, 0x03d00, 0x03e00, 0x03f00, 0x04000, 0x04100, 0x04200, 0x04300, 0x04400, 0x04500, 0x04600, 0x04700, 0x04800, 0x04900, 0x04a00, 0x04b00, @@ -665,3 +673,4 @@ static const ucs4_t cns11643_4b_2uni_upages[248] = { 0x2a200, 0x2a300, 0x2a400, 0x2a500, 0x2a600, 0x2f800, 0x2f900, 0x2fa00, }; +#endif /* _CNS11643_4B_H_ */ diff --git a/lib/cns11643_5.h b/lib/converters/cns11643_5.h similarity index 98% rename from lib/cns11643_5.h rename to lib/converters/cns11643_5.h index ed686fe4..96de48f5 100644 --- a/lib/cns11643_5.h +++ b/lib/converters/cns11643_5.h @@ -1,5 +1,10 @@ +/** + * @file cns11643_5.h + * @brief CNS 11643-1992 plane 5 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CNS 11643-1992 plane 5 - */ +#ifndef _CNS11643_5_H_ +#define _CNS11643_5_H_ + +#include "reiconv_defines.h" -static const unsigned short cns11643_5_2uni_page21[8603] = { +static const unsigned short cns11643_5_2uni_page21[8603] = +{ /* 0x21 */ 0x3bd1, 0x3bcb, 0x3bc9, 0x3c0c, 0x3b00, 0x3b87, 0x3c0d, 0x3c0f, 0xe21d, 0x5e98, 0x3bd2, 0x3c11, 0x3b7e, 0x45d3, 0x5052, 0x57fe, @@ -1215,7 +1222,8 @@ static const unsigned short cns11643_5_2uni_page21[8603] = { 0xe1a5, }; -static const ucs4_t cns11643_5_2uni_upages[229] = { +static const ucs4_t cns11643_5_2uni_upages[229] = +{ 0x03400, 0x03500, 0x03600, 0x03700, 0x03800, 0x03900, 0x03a00, 0x03b00, 0x03c00, 0x03d00, 0x03e00, 0x03f00, 0x04000, 0x04100, 0x04200, 0x04300, 0x04400, 0x04500, 0x04600, 0x04700, 0x04800, 0x04900, 0x04a00, 0x04b00, @@ -1247,31 +1255,34 @@ static const ucs4_t cns11643_5_2uni_upages[229] = { 0x2a500, 0x2a600, 0x2f800, 0x2f900, 0x2fa00, }; -static int -cns11643_5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cns11643_5_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x21 && c1 <= 0x7c)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 < 0x7f) { - unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); - ucs4_t wc = 0xfffd; - unsigned short swc; + unsigned char c1 = s[0]; + if ((c1 >= 0x21 && c1 <= 0x7c)) + { + if (n >= 2) { - if (i < 8603) - swc = cns11643_5_2uni_page21[i], - wc = cns11643_5_2uni_upages[swc>>8] | (swc & 0xff); - } - if (wc != 0xfffd) { - *pwc = wc; - return 2; + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 < 0x7f) + { + unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); + ucs4_t wc = 0xfffd; + unsigned short swc; + { + if (i < 8603) + swc = cns11643_5_2uni_page21[i], wc = cns11643_5_2uni_upages[swc >> 8] | (swc & 0xff); + } + if (wc != 0xfffd) + { + *pwc = wc; + return 2; + } + } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } +#endif /* _CNS11643_5_H_ */ diff --git a/lib/cns11643_6.h b/lib/converters/cns11643_6.h similarity index 97% rename from lib/cns11643_6.h rename to lib/converters/cns11643_6.h index e4ca85d8..e346c230 100644 --- a/lib/cns11643_6.h +++ b/lib/converters/cns11643_6.h @@ -1,5 +1,10 @@ +/** + * @file cns11643_6.h + * @brief CNS 11643-1992 plane 6 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CNS 11643-1992 plane 6 - */ +#ifndef _CNS11643_6_H_ +#define _CNS11643_6_H_ + +#include "reiconv_defines.h" -static const unsigned short cns11643_6_2uni_page21[6388] = { +static const unsigned short cns11643_6_2uni_page21[6388] = +{ /* 0x21 */ 0xc902, 0x3362, 0x0005, 0x3388, 0x33d0, 0x33cf, 0x341e, 0x341f, 0x3420, 0x3c0e, 0x3c2c, 0x3361, 0x3304, 0x3305, 0x3303, 0x0004, @@ -908,7 +915,8 @@ static const unsigned short cns11643_6_2uni_page21[6388] = { 0xc7d1, 0x4737, }; -static const ucs4_t cns11643_6_2uni_upages[204] = { +static const ucs4_t cns11643_6_2uni_upages[204] = +{ 0x03400, 0x03500, 0x03600, 0x03700, 0x03800, 0x03900, 0x03a00, 0x03b00, 0x03c00, 0x03d00, 0x03e00, 0x03f00, 0x04000, 0x04100, 0x04200, 0x04300, 0x04400, 0x04500, 0x04600, 0x04700, 0x04800, 0x04900, 0x04a00, 0x04b00, @@ -937,31 +945,34 @@ static const ucs4_t cns11643_6_2uni_upages[204] = { 0x2a500, 0x2f800, 0x2f900, 0x2fa00, }; -static int -cns11643_6_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cns11643_6_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x21 && c1 <= 0x64)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 < 0x7f) { - unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); - ucs4_t wc = 0xfffd; - unsigned short swc; + unsigned char c1 = s[0]; + if ((c1 >= 0x21 && c1 <= 0x64)) + { + if (n >= 2) { - if (i < 6388) - swc = cns11643_6_2uni_page21[i], - wc = cns11643_6_2uni_upages[swc>>8] | (swc & 0xff); - } - if (wc != 0xfffd) { - *pwc = wc; - return 2; + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 < 0x7f) + { + unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); + ucs4_t wc = 0xfffd; + unsigned short swc; + { + if (i < 6388) + swc = cns11643_6_2uni_page21[i], wc = cns11643_6_2uni_upages[swc >> 8] | (swc & 0xff); + } + if (wc != 0xfffd) + { + *pwc = wc; + return 2; + } + } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } +#endif /* _CNS11643_6_H_ */ diff --git a/lib/cns11643_7.h b/lib/converters/cns11643_7.h similarity index 97% rename from lib/cns11643_7.h rename to lib/converters/cns11643_7.h index 5ce1bd9d..3d99e2c9 100644 --- a/lib/cns11643_7.h +++ b/lib/converters/cns11643_7.h @@ -1,5 +1,10 @@ +/** + * @file cns11643_7.h + * @brief CNS 11643-1992 plane 7 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CNS 11643-1992 plane 7 - */ +#ifndef _CNS11643_7_H_ +#define _CNS11643_7_H_ + +#include "reiconv_defines.h" -static const unsigned short cns11643_7_2uni_page21[6539] = { +static const unsigned short cns11643_7_2uni_page21[6539] = +{ /* 0x21 */ 0x2b55, 0x2c82, 0x2c89, 0x2c87, 0x2dbe, 0x2dbd, 0x2dca, 0x2dd4, 0x2dbc, 0x2dc4, 0x2dc1, 0x2dc2, 0x2dd7, 0x2d70, 0x2dba, 0x2de3, @@ -929,7 +936,8 @@ static const unsigned short cns11643_7_2uni_page21[6539] = { 0xadd3, 0xc0ca, 0x87c4, 0x94b1, 0xb264, }; -static const ucs4_t cns11643_7_2uni_upages[198] = { +static const ucs4_t cns11643_7_2uni_upages[198] = +{ 0x03400, 0x03500, 0x03600, 0x03700, 0x03800, 0x03900, 0x03a00, 0x03b00, 0x03c00, 0x03d00, 0x03e00, 0x03f00, 0x04000, 0x04100, 0x04200, 0x04300, 0x04400, 0x04500, 0x04600, 0x04700, 0x04800, 0x04900, 0x04a00, 0x04b00, @@ -957,31 +965,34 @@ static const ucs4_t cns11643_7_2uni_upages[198] = { 0x2a400, 0x2a500, 0x2a600, 0x2f800, 0x2f900, 0x2fa00, }; -static int -cns11643_7_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cns11643_7_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x21 && c1 <= 0x66)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 < 0x7f) { - unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); - ucs4_t wc = 0xfffd; - unsigned short swc; + unsigned char c1 = s[0]; + if ((c1 >= 0x21 && c1 <= 0x66)) + { + if (n >= 2) { - if (i < 6539) - swc = cns11643_7_2uni_page21[i], - wc = cns11643_7_2uni_upages[swc>>8] | (swc & 0xff); - } - if (wc != 0xfffd) { - *pwc = wc; - return 2; + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 < 0x7f) + { + unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); + ucs4_t wc = 0xfffd; + unsigned short swc; + { + if (i < 6539) + swc = cns11643_7_2uni_page21[i], wc = cns11643_7_2uni_upages[swc >> 8] | (swc & 0xff); + } + if (wc != 0xfffd) + { + *pwc = wc; + return 2; + } + } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } +#endif /* _CNS11643_7_H_ */ diff --git a/lib/cns11643_inv.h b/lib/converters/cns11643_inv.h similarity index 99% rename from lib/cns11643_inv.h rename to lib/converters/cns11643_inv.h index d13f490f..f95f5696 100644 --- a/lib/cns11643_inv.h +++ b/lib/converters/cns11643_inv.h @@ -1,5 +1,10 @@ +/** + * @file cns11643_inv.h + * @brief CNS 11643-1992 planes 1-7, CNS 11643-1986 plane 15 + * @copyright Copyright (C) 1999-2005, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2005, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CNS 11643-1992 planes 1-7, CNS 11643-1986 plane 15 - */ +#ifndef _CNS11643_INV_H_ +#define _CNS11643_INV_H_ + +#include "reiconv_defines.h" -static const unsigned char cns11643_inv_2charset[3*55442] = { +static const unsigned char cns11643_inv_2charset[3 * 55442] = +{ 0x1,0x21,0x70, 0x1,0x22,0x78, 0x1,0x22,0x34, 0x1,0x21,0x31, 0x1,0x22,0x32, 0x1,0x22,0x33, 0x1,0x25,0x6f, 0x1,0x25,0x6d, 0x1,0x25,0x6e, 0x1,0x25,0x70, 0x1,0x25,0x6c, 0x1,0x24,0x75, @@ -13885,14 +13892,16 @@ static const unsigned char cns11643_inv_2charset[3*55442] = { 0x4,0x48,0x77, 0x7,0x5e,0x4d, }; -static const Summary16 cns11643_inv_uni2indx_page00[16] = { +static const Summary16 cns11643_inv_uni2indx_page00[16] = +{ /* 0x0000 */ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0080 }, { 1, 0x0083 }, { 4, 0x0000 }, { 4, 0x0080 }, { 5, 0x0000 }, { 5, 0x0080 }, }; -static const Summary16 cns11643_inv_uni2indx_page02[29] = { +static const Summary16 cns11643_inv_uni2indx_page02[29] = +{ /* 0x0200 */ { 6, 0x0000 }, { 6, 0x0000 }, { 6, 0x0000 }, { 6, 0x0000 }, { 6, 0x0000 }, { 6, 0x0000 }, { 6, 0x0000 }, { 6, 0x0000 }, @@ -13904,7 +13913,8 @@ static const Summary16 cns11643_inv_uni2indx_page02[29] = { { 11, 0x0000 }, { 11, 0xfffe }, { 26, 0x03fb }, { 35, 0xfffe }, { 50, 0x03fb }, }; -static const Summary16 cns11643_inv_uni2indx_page20[44] = { +static const Summary16 cns11643_inv_uni2indx_page20[44] = +{ /* 0x2000 */ { 59, 0x0000 }, { 59, 0x3358 }, { 66, 0x0060 }, { 68, 0x4824 }, { 72, 0x0000 }, { 72, 0x0000 }, { 72, 0x0000 }, { 72, 0x0000 }, @@ -13920,7 +13930,8 @@ static const Summary16 cns11643_inv_uni2indx_page20[44] = { { 116, 0x0000 }, { 116, 0x0004 }, { 117, 0x00c3 }, { 121, 0x0000 }, { 121, 0x0000 }, { 121, 0x0000 }, { 121, 0x0020 }, { 122, 0x8000 }, }; -static const Summary16 cns11643_inv_uni2indx_page24[37] = { +static const Summary16 cns11643_inv_uni2indx_page24[37] = +{ /* 0x2400 */ { 123, 0xffff }, { 139, 0xffff }, { 155, 0x0002 }, { 156, 0x0000 }, { 156, 0x0000 }, { 156, 0x0000 }, { 156, 0x03ff }, { 166, 0x3ff0 }, @@ -13935,7 +13946,8 @@ static const Summary16 cns11643_inv_uni2indx_page24[37] = { { 230, 0x0260 }, { 233, 0x0000 }, { 233, 0x0000 }, { 233, 0x0000 }, { 233, 0x0007 }, }; -static const Summary16 cns11643_inv_uni2indx_page30[1787] = { +static const Summary16 cns11643_inv_uni2indx_page30[1787] = +{ /* 0x3000 */ { 236, 0xff0f }, { 248, 0x6037 }, { 255, 0x03fe }, { 264, 0x0000 }, { 264, 0x0000 }, { 264, 0x0000 }, { 264, 0x0000 }, { 264, 0x0000 }, @@ -14496,11 +14508,13 @@ static const Summary16 cns11643_inv_uni2indx_page30[1787] = { { 24505, 0xffff }, { 24521, 0xfffd }, { 24536, 0xfffb }, { 24551, 0x7fff }, { 24566, 0xe000 }, { 24569, 0x73ff }, { 24582, 0x003f }, }; -static const Summary16 cns11643_inv_uni2indx_pagefa[3] = { +static const Summary16 cns11643_inv_uni2indx_pagefa[3] = +{ /* 0xfa00 */ { 24588, 0x0000 }, { 24588, 0x0000 }, { 24588, 0x0100 }, }; -static const Summary16 cns11643_inv_uni2indx_pagefe[31] = { +static const Summary16 cns11643_inv_uni2indx_pagefe[31] = +{ /* 0xfe00 */ { 24589, 0x0000 }, { 24589, 0x0000 }, { 24589, 0x0000 }, { 24589, 0xffe7 }, { 24603, 0x7e1f }, { 24614, 0xfef7 }, { 24628, 0x0f7f }, { 24639, 0x0000 }, @@ -14512,7 +14526,8 @@ static const Summary16 cns11643_inv_uni2indx_pagefe[31] = { { 24726, 0x0000 }, { 24726, 0x0000 }, { 24726, 0x0000 }, { 24726, 0x0000 }, { 24726, 0x0000 }, { 24726, 0x0000 }, { 24726, 0x0023 }, }; -static const Summary16 cns11643_inv_uni2indx_page200[2670] = { +static const Summary16 cns11643_inv_uni2indx_page200[2670] = +{ /* 0x20000 */ { 24729, 0x8bbd }, { 24739, 0x0715 }, { 24745, 0x722f }, { 24754, 0x0860 }, { 24757, 0x39ca }, { 24765, 0x08ec }, { 24771, 0xeaf6 }, { 24782, 0xe0d7 }, @@ -15364,48 +15379,52 @@ static const Summary16 cns11643_inv_uni2indx_page2f8[34] = { { 55412, 0xffff }, { 55428, 0x3fff }, }; -static int -cns11643_inv_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cns11643_inv_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc >= 0x0000 && wc < 0x0100) - summary = &cns11643_inv_uni2indx_page00[(wc>>4)]; - else if (wc >= 0x0200 && wc < 0x03d0) - summary = &cns11643_inv_uni2indx_page02[(wc>>4)-0x020]; - else if (wc >= 0x2000 && wc < 0x22c0) - summary = &cns11643_inv_uni2indx_page20[(wc>>4)-0x200]; - else if (wc >= 0x2400 && wc < 0x2650) - summary = &cns11643_inv_uni2indx_page24[(wc>>4)-0x240]; - else if (wc >= 0x3000 && wc < 0x9fb0) - summary = &cns11643_inv_uni2indx_page30[(wc>>4)-0x300]; - else if (wc >= 0xfa00 && wc < 0xfa30) - summary = &cns11643_inv_uni2indx_pagefa[(wc>>4)-0xfa0]; - else if (wc >= 0xfe00 && wc < 0xfff0) - summary = &cns11643_inv_uni2indx_pagefe[(wc>>4)-0xfe0]; - else if (wc >= 0x20000 && wc < 0x2a6e0) - summary = &cns11643_inv_uni2indx_page200[(wc>>4)-0x2000]; - else if (wc >= 0x2f800 && wc < 0x2fa20) - summary = &cns11643_inv_uni2indx_page2f8[(wc>>4)-0x2f80]; - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - used += summary->indx; - r[0] = cns11643_inv_2charset[3*used]; - r[1] = cns11643_inv_2charset[3*used+1]; - r[2] = cns11643_inv_2charset[3*used+2]; - return 3; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc >= 0x0000 && wc < 0x0100) + summary = &cns11643_inv_uni2indx_page00[(wc >> 4)]; + else if (wc >= 0x0200 && wc < 0x03d0) + summary = &cns11643_inv_uni2indx_page02[(wc >> 4) - 0x020]; + else if (wc >= 0x2000 && wc < 0x22c0) + summary = &cns11643_inv_uni2indx_page20[(wc >> 4) - 0x200]; + else if (wc >= 0x2400 && wc < 0x2650) + summary = &cns11643_inv_uni2indx_page24[(wc >> 4) - 0x240]; + else if (wc >= 0x3000 && wc < 0x9fb0) + summary = &cns11643_inv_uni2indx_page30[(wc >> 4) - 0x300]; + else if (wc >= 0xfa00 && wc < 0xfa30) + summary = &cns11643_inv_uni2indx_pagefa[(wc >> 4) - 0xfa0]; + else if (wc >= 0xfe00 && wc < 0xfff0) + summary = &cns11643_inv_uni2indx_pagefe[(wc >> 4) - 0xfe0]; + else if (wc >= 0x20000 && wc < 0x2a6e0) + summary = &cns11643_inv_uni2indx_page200[(wc >> 4) - 0x2000]; + else if (wc >= 0x2f800 && wc < 0x2fa20) + summary = &cns11643_inv_uni2indx_page2f8[(wc >> 4) - 0x2f80]; + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + used += summary->indx; + r[0] = cns11643_inv_2charset[3 * used]; + r[1] = cns11643_inv_2charset[3 * used + 1]; + r[2] = cns11643_inv_2charset[3 * used + 2]; + return 3; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _CNS11643_INV_H_ */ diff --git a/lib/cp1046.h b/lib/converters/cp1046.h similarity index 75% rename from lib/cp1046.h rename to lib/converters/cp1046.h index d882af2d..13dbfbb3 100644 --- a/lib/cp1046.h +++ b/lib/converters/cp1046.h @@ -1,5 +1,10 @@ +/** + * @file cp1046.h + * @brief CP1046 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP1046 - */ +#ifndef _CP1046_H_ +#define _CP1046_H_ + +#include "reiconv_defines.h" -static const unsigned short cp1046_2uni[128] = { +static const unsigned short cp1046_2uni[128] = +{ /* 0x80 */ 0xfe88, 0x00d7, 0x00f7, 0xf8f6, 0xf8f5, 0xf8f4, 0xf8f7, 0xfe71, 0x0088, 0x25a0, 0x2502, 0x2500, 0x2510, 0x250c, 0x2514, 0x2518, @@ -48,25 +55,28 @@ static const unsigned short cp1046_2uni[128] = { 0xfef7, 0xfef9, 0xfefb, 0xfee3, 0xfee7, 0xfeec, 0xfee9, 0xfffd, }; -static int -cp1046_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1046_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = cp1046_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; + } + else + { + unsigned short wc = cp1046_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } } - } - return RET_ILSEQ; + return RET_ILSEQ; } -static const unsigned char cp1046_page00[112] = { +static const unsigned char cp1046_page00[112] = +{ 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ @@ -82,7 +92,8 @@ static const unsigned char cp1046_page00[112] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, /* 0xf0-0xf7 */ }; -static const unsigned char cp1046_page06[104] = { +static const unsigned char cp1046_page06[104] = +{ 0x00, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0xbf, /* 0x18-0x1f */ @@ -97,17 +108,20 @@ static const unsigned char cp1046_page06[104] = { 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0x60-0x67 */ 0xb8, 0xb9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ }; -static const unsigned char cp1046_page25[32] = { +static const unsigned char cp1046_page25[32] = +{ 0x8b, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x8c, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x8f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ }; -static const unsigned char cp1046_pagef8[16] = { +static const unsigned char cp1046_pagef8[16] = +{ 0x00, 0x00, 0x00, 0x00, 0x85, 0x84, 0x83, 0x86, /* 0xf0-0xf7 */ 0xa3, 0xa2, 0xa1, 0xa5, 0xf6, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; -static const unsigned char cp1046_pagefe[144] = { +static const unsigned char cp1046_pagefe[144] = +{ 0x00, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x94, /* 0x70-0x77 */ 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, /* 0x78-0x7f */ 0x00, 0x00, 0xdc, 0x00, 0xdd, 0x00, 0x00, 0x00, /* 0x80-0x87 */ @@ -128,29 +142,32 @@ static const unsigned char cp1046_pagefe[144] = { 0x9d, 0xf9, 0x9e, 0xfa, 0x9f, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; -static int -cp1046_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1046_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x0088 && wc < 0x00f8) - c = cp1046_page00[wc-0x0088]; - else if (wc >= 0x0608 && wc < 0x0670) - c = cp1046_page06[wc-0x0608]; - else if (wc >= 0x2500 && wc < 0x2520) - c = cp1046_page25[wc-0x2500]; - else if (wc == 0x25a0) - c = 0x89; - else if (wc >= 0xf8f0 && wc < 0xf900) - c = cp1046_pagef8[wc-0xf8f0]; - else if (wc >= 0xfe70 && wc < 0xff00) - c = cp1046_pagefe[wc-0xfe70]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x0088 && wc < 0x00f8) + c = cp1046_page00[wc - 0x0088]; + else if (wc >= 0x0608 && wc < 0x0670) + c = cp1046_page06[wc - 0x0608]; + else if (wc >= 0x2500 && wc < 0x2520) + c = cp1046_page25[wc - 0x2500]; + else if (wc == 0x25a0) + c = 0x89; + else if (wc >= 0xf8f0 && wc < 0xf900) + c = cp1046_pagef8[wc - 0xf8f0]; + else if (wc >= 0xfe70 && wc < 0xff00) + c = cp1046_pagefe[wc - 0xfe70]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1046_H_ */ diff --git a/lib/cp1124.h b/lib/converters/cp1124.h similarity index 72% rename from lib/cp1124.h rename to lib/converters/cp1124.h index 4a47a396..eea7c13a 100644 --- a/lib/cp1124.h +++ b/lib/converters/cp1124.h @@ -1,5 +1,10 @@ +/** + * @file cp1124.h + * @brief CP1124 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP1124 - */ +#ifndef _CP1124_H_ +#define _CP1124_H_ -static const unsigned short cp1124_2uni[96] = { +#include "reiconv_defines.h" + +static const unsigned short cp1124_2uni[96] = +{ /* 0xa0 */ 0x00a0, 0x0401, 0x0402, 0x0490, 0x0404, 0x0405, 0x0406, 0x0407, 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x00ad, 0x040e, 0x040f, @@ -42,22 +49,23 @@ static const unsigned short cp1124_2uni[96] = { 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x00a7, 0x045e, 0x045f, }; -static int -cp1124_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1124_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp1124_2uni[c-0xa0]; - return 1; + unsigned char c = *s; + if (c < 0xa0) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp1124_2uni[c - 0xa0]; + return 1; } -static const unsigned char cp1124_page00[16] = { +static const unsigned char cp1124_page00[16] = +{ 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, /* 0xa8-0xaf */ }; -static const unsigned char cp1124_page04[152] = { +static const unsigned char cp1124_page04[152] = +{ 0x00, 0xa1, 0xa2, 0x00, 0xa4, 0xa5, 0xa6, 0xa7, /* 0x00-0x07 */ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0x00, 0xae, 0xaf, /* 0x08-0x0f */ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0x10-0x17 */ @@ -79,23 +87,26 @@ static const unsigned char cp1124_page04[152] = { 0xa3, 0xf3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ }; -static int -cp1124_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1124_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00b0) - c = cp1124_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x0498) - c = cp1124_page04[wc-0x0400]; - else if (wc == 0x2116) - c = 0xf0; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00b0) + c = cp1124_page00[wc - 0x00a0]; + else if (wc >= 0x0400 && wc < 0x0498) + c = cp1124_page04[wc - 0x0400]; + else if (wc == 0x2116) + c = 0xf0; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1124_H_ */ diff --git a/lib/cp1125.h b/lib/converters/cp1125.h similarity index 75% rename from lib/cp1125.h rename to lib/converters/cp1125.h index 836dcce9..38bd8233 100644 --- a/lib/cp1125.h +++ b/lib/converters/cp1125.h @@ -1,5 +1,10 @@ +/** + * @file cp1125.h + * @brief CP1125 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP1125 - */ +#ifndef _CP1125_H_ +#define _CP1125_H_ -static const unsigned short cp1125_2uni[80] = { +#include "reiconv_defines.h" + +static const unsigned short cp1125_2uni[80] = +{ /* 0xb0 */ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510, @@ -39,25 +46,26 @@ static const unsigned short cp1125_2uni[80] = { 0x0407, 0x0457, 0x00b7, 0x221a, 0x2116, 0x00a4, 0x25a0, 0x00a0, }; -static int -cp1125_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1125_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else if (c < 0xb0) - *pwc = (ucs4_t) c + 0x0390; - else - *pwc = (ucs4_t) cp1125_2uni[c-0xb0]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else if (c < 0xb0) + *pwc = (ucs4_t)c + 0x0390; + else + *pwc = (ucs4_t)cp1125_2uni[c - 0xb0]; + return 1; } -static const unsigned char cp1125_page00[24] = { +static const unsigned char cp1125_page00[24] = +{ 0xff, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, /* 0xb0-0xb7 */ }; -static const unsigned char cp1125_page04[152] = { +static const unsigned char cp1125_page04[152] = +{ 0x00, 0xf0, 0x00, 0x00, 0xf4, 0x00, 0xf6, 0xf8, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x10-0x17 */ @@ -78,7 +86,8 @@ static const unsigned char cp1125_page04[152] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0xf2, 0xf3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ }; -static const unsigned char cp1125_page25[168] = { +static const unsigned char cp1125_page25[168] = +{ 0xc4, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0xbf, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, /* 0x10-0x17 */ @@ -102,27 +111,30 @@ static const unsigned char cp1125_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp1125_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1125_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00b8) - c = cp1125_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x0498) - c = cp1125_page04[wc-0x0400]; - else if (wc == 0x2116) - c = 0xfc; - else if (wc == 0x221a) - c = 0xfb; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp1125_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00b8) + c = cp1125_page00[wc - 0x00a0]; + else if (wc >= 0x0400 && wc < 0x0498) + c = cp1125_page04[wc - 0x0400]; + else if (wc == 0x2116) + c = 0xfc; + else if (wc == 0x221a) + c = 0xfb; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp1125_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1125_H_ */ diff --git a/lib/cp1129.h b/lib/converters/cp1129.h similarity index 78% rename from lib/cp1129.h rename to lib/converters/cp1129.h index 8795d5f7..18e0ddf6 100644 --- a/lib/cp1129.h +++ b/lib/converters/cp1129.h @@ -1,5 +1,10 @@ +/** + * @file cp1129.h + * @brief CP1129 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP1129 - */ +#ifndef _CP1129_H_ +#define _CP1129_H_ -static const unsigned short cp1129_2uni[96] = { +#include "reiconv_defines.h" + +static const unsigned short cp1129_2uni[96] = +{ /* 0xa0 */ 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x0153, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, @@ -42,18 +49,18 @@ static const unsigned short cp1129_2uni[96] = { 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x01b0, 0x20ab, 0x00ff, }; -static int -cp1129_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1129_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp1129_2uni[c-0xa0]; - return 1; + unsigned char c = *s; + if (c < 0xa0) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp1129_2uni[c - 0xa0]; + return 1; } -static const unsigned char cp1129_page00[272] = { +static const unsigned char cp1129_page00[272] = +{ 0x00, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */ 0xb0, 0xb1, 0xb2, 0xb3, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ 0x00, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* 0xb8-0xbf */ @@ -90,7 +97,9 @@ static const unsigned char cp1129_page00[272] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdd, /* 0xa8-0xaf */ 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ }; -static const unsigned char cp1129_page03[40] = { + +static const unsigned char cp1129_page03[40] = +{ 0xcc, 0xec, 0x00, 0xde, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0xd2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ @@ -98,23 +107,26 @@ static const unsigned char cp1129_page03[40] = { 0x00, 0x00, 0x00, 0xf2, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ }; -static int -cp1129_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1129_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a8) { - *r = wc; - return 1; - } - else if (wc >= 0x00a8 && wc < 0x01b8) - c = cp1129_page00[wc-0x00a8]; - else if (wc >= 0x0300 && wc < 0x0328) - c = cp1129_page03[wc-0x0300]; - else if (wc == 0x20ab) - c = 0xfe; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a8) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a8 && wc < 0x01b8) + c = cp1129_page00[wc - 0x00a8]; + else if (wc >= 0x0300 && wc < 0x0328) + c = cp1129_page03[wc - 0x0300]; + else if (wc == 0x20ab) + c = 0xfe; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1129_H_ */ diff --git a/lib/cp1131.h b/lib/converters/cp1131.h similarity index 78% rename from lib/cp1131.h rename to lib/converters/cp1131.h index 7be44ab4..7316ab86 100644 --- a/lib/cp1131.h +++ b/lib/converters/cp1131.h @@ -1,5 +1,10 @@ +/** + * @file cp1131.h + * @brief CP1131 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP1131 - */ +#ifndef _CP1131_H_ +#define _CP1131_H_ + +#include "reiconv_defines.h" -static const unsigned short cp1131_2uni[128] = { +static const unsigned short cp1131_2uni[128] = +{ /* 0x80 */ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, @@ -48,23 +55,25 @@ static const unsigned short cp1131_2uni[128] = { 0x0406, 0x0456, 0x00b7, 0x00a4, 0x0490, 0x0491, 0x2219, 0x00a0, }; -static int -cp1131_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1131_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp1131_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp1131_2uni[c - 0x80]; + return 1; } -static const unsigned char cp1131_page00[24] = { +static const unsigned char cp1131_page00[24] = +{ 0xff, 0x00, 0x00, 0x00, 0xfb, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, /* 0xb0-0xb7 */ }; -static const unsigned char cp1131_page04[152] = { + +static const unsigned char cp1131_page04[152] = +{ 0x00, 0xf0, 0x00, 0x00, 0xf2, 0x00, 0xf8, 0xf4, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x00, /* 0x08-0x0f */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x10-0x17 */ @@ -85,7 +94,8 @@ static const unsigned char cp1131_page04[152] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0xfc, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ }; -static const unsigned char cp1131_page25[152] = { +static const unsigned char cp1131_page25[152] = +{ 0xc4, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0xbf, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, /* 0x10-0x17 */ @@ -107,25 +117,28 @@ static const unsigned char cp1131_page25[152] = { 0xde, 0xb0, 0xb1, 0xb2, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ }; -static int -cp1131_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1131_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00b8) - c = cp1131_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x0498) - c = cp1131_page04[wc-0x0400]; - else if (wc == 0x2219) - c = 0xfe; - else if (wc >= 0x2500 && wc < 0x2598) - c = cp1131_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00b8) + c = cp1131_page00[wc - 0x00a0]; + else if (wc >= 0x0400 && wc < 0x0498) + c = cp1131_page04[wc - 0x0400]; + else if (wc == 0x2219) + c = 0xfe; + else if (wc >= 0x2500 && wc < 0x2598) + c = cp1131_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1131_H_ */ diff --git a/lib/cp1133.h b/lib/converters/cp1133.h similarity index 60% rename from lib/cp1133.h rename to lib/converters/cp1133.h index 53323680..381053ab 100644 --- a/lib/cp1133.h +++ b/lib/converters/cp1133.h @@ -1,5 +1,10 @@ +/** + * @file cp1133.h + * @brief IBM-CP1133 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,17 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-CP1133 - */ +#ifndef _CP1133_H_ +#define _CP1133_H_ + +#include "reiconv_defines.h" -static const unsigned short cp1133_2uni_1[64] = { +static const unsigned short cp1133_2uni_1[64] = +{ /* 0xa0 */ 0x00a0, 0x0e81, 0x0e82, 0x0e84, 0x0e87, 0x0e88, 0x0eaa, 0x0e8a, 0x0e8d, 0x0e94, 0x0e95, 0x0e96, 0x0e97, 0x0e99, 0x0e9a, 0x0e9b, @@ -35,44 +42,53 @@ static const unsigned short cp1133_2uni_1[64] = { 0x0ec0, 0x0ec1, 0x0ec2, 0x0ec3, 0x0ec4, 0x0ec8, 0x0ec9, 0x0eca, 0x0ecb, 0x0ecc, 0x0ecd, 0x0ec6, 0xfffd, 0x0edc, 0x0edd, 0x20ad, }; -static const unsigned short cp1133_2uni_2[16] = { + +static const unsigned short cp1133_2uni_2[16] = +{ /* 0xf0 */ 0x0ed0, 0x0ed1, 0x0ed2, 0x0ed3, 0x0ed4, 0x0ed5, 0x0ed6, 0x0ed7, 0x0ed8, 0x0ed9, 0xfffd, 0xfffd, 0x00a2, 0x00ac, 0x00a6, 0xfffd, }; -static int -cp1133_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1133_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) { - *pwc = (ucs4_t) c; - return 1; - } - else if (c < 0xe0) { - unsigned short wc = cp1133_2uni_1[c-0xa0]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0xa0) + { + *pwc = (ucs4_t)c; + return 1; } - } - else if (c < 0xf0) { - } - else { - unsigned short wc = cp1133_2uni_2[c-0xf0]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + else if (c < 0xe0) + { + unsigned short wc = cp1133_2uni_1[c - 0xa0]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } } - } - return RET_ILSEQ; + else if (c < 0xf0) + { + } + else + { + unsigned short wc = cp1133_2uni_2[c - 0xf0]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } -static const unsigned char cp1133_page00[16] = { +static const unsigned char cp1133_page00[16] = +{ 0xa0, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfe, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ }; -static const unsigned char cp1133_page0e[96] = { +static const unsigned char cp1133_page0e[96] = +{ 0x00, 0xa1, 0xa2, 0x00, 0xa3, 0x00, 0x00, 0xa4, /* 0x80-0x87 */ 0xa5, 0x00, 0xa7, 0x00, 0x00, 0xa8, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x00, 0x00, 0xa9, 0xaa, 0xab, 0xac, /* 0x90-0x97 */ @@ -87,23 +103,26 @@ static const unsigned char cp1133_page0e[96] = { 0xf8, 0xf9, 0x00, 0x00, 0xdd, 0xde, 0x00, 0x00, /* 0xd8-0xdf */ }; -static int -cp1133_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1133_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00b0) - c = cp1133_page00[wc-0x00a0]; - else if (wc >= 0x0e80 && wc < 0x0ee0) - c = cp1133_page0e[wc-0x0e80]; - else if (wc == 0x20ad) - c = 0xdf; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00b0) + c = cp1133_page00[wc - 0x00a0]; + else if (wc >= 0x0e80 && wc < 0x0ee0) + c = cp1133_page0e[wc - 0x0e80]; + else if (wc == 0x20ad) + c = 0xdf; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1133_H_ */ diff --git a/lib/cp1161.h b/lib/converters/cp1161.h similarity index 56% rename from lib/cp1161.h rename to lib/converters/cp1161.h index c877ac71..d7d2a282 100644 --- a/lib/cp1161.h +++ b/lib/converters/cp1161.h @@ -1,5 +1,10 @@ +/** + * @file cp1161.h + * @brief CP1161 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,15 +18,18 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP1161 - */ +#ifndef _CP1161_H_ +#define _CP1161_H_ + +#include "converters/cp874.h" +#include "reiconv_defines.h" -static const unsigned short cp1161_2uni[96] = { +static const unsigned short cp1161_2uni[96] = +{ /* 0xa0 */ 0x0e48, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, @@ -42,47 +50,53 @@ static const unsigned short cp1161_2uni[96] = { 0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0x00a2, 0x00ac, 0x00a6, 0x00a0, }; -static int -cp1161_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1161_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else if (c < 0xa0) { - } - else { - *pwc = (ucs4_t) cp1161_2uni[c-0xa0]; - return 1; - } - return RET_ILSEQ; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; + } + else if (c < 0xa0) + { + } + else + { + *pwc = (ucs4_t)cp1161_2uni[c - 0xa0]; + return 1; + } + return RET_ILSEQ; } -static const unsigned char cp1161_page00[16] = { +static const unsigned char cp1161_page00[16] = +{ 0xff, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfe, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ }; -static int -cp1161_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1161_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00b0) - c = cp1161_page00[wc-0x00a0]; - else if (wc >= 0x0e48 && wc < 0x0e4c) - c = wc-0x0d60; - else if (wc >= 0x0e00 && wc < 0x0e60) - c = cp874_page0e[wc-0x0e00]; - else if (wc == 0x20ac) - c = 0xde; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00b0) + c = cp1161_page00[wc - 0x00a0]; + else if (wc >= 0x0e48 && wc < 0x0e4c) + c = wc - 0x0d60; + else if (wc >= 0x0e00 && wc < 0x0e60) + c = cp874_page0e[wc - 0x0e00]; + else if (wc == 0x20ac) + c = 0xde; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1161_H_ */ diff --git a/lib/converters/cp1162.h b/lib/converters/cp1162.h new file mode 100644 index 00000000..554eb53d --- /dev/null +++ b/lib/converters/cp1162.h @@ -0,0 +1,81 @@ +/** + * @file cp1162.h + * @brief CP1162 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _CP1162_H_ +#define _CP1162_H_ + +#include "reiconv_defines.h" + +static int cp1162_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; + } + else + { + unsigned short wc = cp874_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + if (c < 0xa0) + { + *pwc = (ucs4_t)c; + return 1; + } + } + return RET_ILSEQ; +} + +static int cp1162_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x0080 && wc < 0x00a0 && cp874_2uni[wc - 0x0080] == 0xfffd) + c = wc; + else if (wc == 0x00a0) + c = 0xa0; + else if (wc >= 0x0e00 && wc < 0x0e60) + c = cp874_page0e[wc - 0x0e00]; + else if (wc >= 0x2010 && wc < 0x2028) + c = cp874_page20[wc - 0x2010]; + else if (wc == 0x20ac) + c = 0x80; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; +} + +#endif /* _CP1162_H_ */ diff --git a/lib/converters/cp1163.h b/lib/converters/cp1163.h new file mode 100644 index 00000000..d124191a --- /dev/null +++ b/lib/converters/cp1163.h @@ -0,0 +1,71 @@ +/** + * @file cp1163.h + * @brief CP1163 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _CP1163_H_ +#define _CP1163_H_ + +#include "converters/cp1129.h" +#include "reiconv_defines.h" + +static int cp1163_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + if (c < 0xa0) + *pwc = (ucs4_t)c; + else if (c == 0xa4) + *pwc = 0x20ac; + else + *pwc = (ucs4_t)cp1129_2uni[c - 0xa0]; + return 1; +} + +static const unsigned char cp1163_page20[8] = { + 0x00, 0x00, 0x00, 0xfe, 0xa4, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ +}; + +static int cp1163_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char c = 0; + if (wc < 0x00a0 || (wc < 0x00a8 && wc != 0x00a4) || wc == 0x00d0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a8 && wc < 0x01b8) + c = cp1129_page00[wc - 0x00a8]; + else if (wc >= 0x0300 && wc < 0x0328) + c = cp1129_page03[wc - 0x0300]; + else if (wc == 0x203e) + c = 0xaf; + else if (wc >= 0x20a8 && wc < 0x20b0) + c = cp1163_page20[wc - 0x20a8]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; +} + +#endif /* _CP1163_H_ */ diff --git a/lib/cp1250.h b/lib/converters/cp1250.h similarity index 78% rename from lib/cp1250.h rename to lib/converters/cp1250.h index 5f6755f3..7c04b857 100644 --- a/lib/cp1250.h +++ b/lib/converters/cp1250.h @@ -1,5 +1,10 @@ +/** + * @file cp1250.h + * @brief CP1250 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP1250 - */ +#ifndef _CP1250_H_ +#define _CP1250_H_ + +#include "reiconv_defines.h" static const unsigned short cp1250_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short cp1250_2uni[128] = { 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9, }; -static int -cp1250_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1250_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = cp1250_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = cp1250_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char cp1250_page00[224] = { @@ -112,27 +120,30 @@ static const unsigned char cp1250_page20[48] = { 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ }; -static int -cp1250_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1250_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0180) - c = cp1250_page00[wc-0x00a0]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = cp1250_page02[wc-0x02c0]; - else if (wc >= 0x2010 && wc < 0x2040) - c = cp1250_page20[wc-0x2010]; - else if (wc == 0x20ac) - c = 0x80; - else if (wc == 0x2122) - c = 0x99; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0180) + c = cp1250_page00[wc - 0x00a0]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = cp1250_page02[wc - 0x02c0]; + else if (wc >= 0x2010 && wc < 0x2040) + c = cp1250_page20[wc - 0x2010]; + else if (wc == 0x20ac) + c = 0x80; + else if (wc == 0x2122) + c = 0x99; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1250_H_ */ diff --git a/lib/cp1251.h b/lib/converters/cp1251.h similarity index 75% rename from lib/cp1251.h rename to lib/converters/cp1251.h index 0f2d5eca..60e42430 100644 --- a/lib/cp1251.h +++ b/lib/converters/cp1251.h @@ -1,5 +1,10 @@ +/** + * @file cp1251.h + * @brief CP1251 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP1251 - */ +#ifndef _CP1251_H_ +#define _CP1251_H_ + +#include "reiconv_defines.h" static const unsigned short cp1251_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short cp1251_2uni[128] = { 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, }; -static int -cp1251_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1251_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = cp1251_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = cp1251_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char cp1251_page00[32] = { @@ -102,29 +110,32 @@ static const unsigned char cp1251_page20[48] = { 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ }; -static int -cp1251_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1251_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00c0) - c = cp1251_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x0498) - c = cp1251_page04[wc-0x0400]; - else if (wc >= 0x2010 && wc < 0x2040) - c = cp1251_page20[wc-0x2010]; - else if (wc == 0x20ac) - c = 0x88; - else if (wc == 0x2116) - c = 0xb9; - else if (wc == 0x2122) - c = 0x99; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00c0) + c = cp1251_page00[wc - 0x00a0]; + else if (wc >= 0x0400 && wc < 0x0498) + c = cp1251_page04[wc - 0x0400]; + else if (wc >= 0x2010 && wc < 0x2040) + c = cp1251_page20[wc - 0x2010]; + else if (wc == 0x20ac) + c = 0x88; + else if (wc == 0x2116) + c = 0xb9; + else if (wc == 0x2122) + c = 0x99; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1251_H_ */ diff --git a/lib/cp1252.h b/lib/converters/cp1252.h similarity index 64% rename from lib/cp1252.h rename to lib/converters/cp1252.h index de494ee4..2ee3554f 100644 --- a/lib/cp1252.h +++ b/lib/converters/cp1252.h @@ -1,5 +1,10 @@ +/** + * @file cp1252.h + * @brief CP1252 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP1252 - */ +#ifndef _CP1252_H_ +#define _CP1252_H_ + +#include "reiconv_defines.h" static const unsigned short cp1252_2uni[32] = { /* 0x80 */ @@ -30,22 +36,24 @@ static const unsigned short cp1252_2uni[32] = { 0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0xfffd, 0x017e, 0x0178, }; -static int -cp1252_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1252_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80 || c >= 0xa0) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = cp1252_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80 || c >= 0xa0) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = cp1252_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char cp1252_page01[72] = { @@ -74,29 +82,32 @@ static const unsigned char cp1252_page20[48] = { 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ }; -static int -cp1252_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1252_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = wc; - else if (wc >= 0x0150 && wc < 0x0198) - c = cp1252_page01[wc-0x0150]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = cp1252_page02[wc-0x02c0]; - else if (wc >= 0x2010 && wc < 0x2040) - c = cp1252_page20[wc-0x2010]; - else if (wc == 0x20ac) - c = 0x80; - else if (wc == 0x2122) - c = 0x99; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = wc; + else if (wc >= 0x0150 && wc < 0x0198) + c = cp1252_page01[wc - 0x0150]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = cp1252_page02[wc - 0x02c0]; + else if (wc >= 0x2010 && wc < 0x2040) + c = cp1252_page20[wc - 0x2010]; + else if (wc == 0x20ac) + c = 0x80; + else if (wc == 0x2122) + c = 0x99; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1252_H_ */ diff --git a/lib/cp1253.h b/lib/converters/cp1253.h similarity index 71% rename from lib/cp1253.h rename to lib/converters/cp1253.h index 1f27e375..58116096 100644 --- a/lib/cp1253.h +++ b/lib/converters/cp1253.h @@ -1,5 +1,10 @@ +/** + * @file cp1253.h + * @brief CP1253 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP1253 - */ +#ifndef _CP1253_H_ +#define _CP1253_H_ + +#include "reiconv_defines.h" static const unsigned short cp1253_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short cp1253_2uni[128] = { 0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0xfffd, }; -static int -cp1253_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1253_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = cp1253_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = cp1253_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char cp1253_page00[32] = { @@ -93,29 +101,32 @@ static const unsigned char cp1253_page20[48] = { 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ }; -static int -cp1253_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1253_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00c0) - c = cp1253_page00[wc-0x00a0]; - else if (wc == 0x0192) - c = 0x83; - else if (wc >= 0x0380 && wc < 0x03d0) - c = cp1253_page03[wc-0x0380]; - else if (wc >= 0x2010 && wc < 0x2040) - c = cp1253_page20[wc-0x2010]; - else if (wc == 0x20ac) - c = 0x80; - else if (wc == 0x2122) - c = 0x99; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00c0) + c = cp1253_page00[wc - 0x00a0]; + else if (wc == 0x0192) + c = 0x83; + else if (wc >= 0x0380 && wc < 0x03d0) + c = cp1253_page03[wc - 0x0380]; + else if (wc >= 0x2010 && wc < 0x2040) + c = cp1253_page20[wc - 0x2010]; + else if (wc == 0x20ac) + c = 0x80; + else if (wc == 0x2122) + c = 0x99; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1253_H_ */ diff --git a/lib/cp1254.h b/lib/converters/cp1254.h similarity index 67% rename from lib/cp1254.h rename to lib/converters/cp1254.h index afeac5c4..c0182596 100644 --- a/lib/cp1254.h +++ b/lib/converters/cp1254.h @@ -1,5 +1,10 @@ +/** + * @file cp1254.h + * @brief CP1254 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP1254 - */ +#ifndef _CP1254_H_ +#define _CP1254_H_ + +#include "reiconv_defines.h" static const unsigned short cp1254_2uni_1[32] = { /* 0x80 */ @@ -40,38 +46,44 @@ static const unsigned short cp1254_2uni_3[16] = { 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff, }; -static int -cp1254_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1254_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else if (c < 0xa0) { - unsigned short wc = cp1254_2uni_1[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; + } + else if (c < 0xa0) + { + unsigned short wc = cp1254_2uni_1[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + else if (c < 0xd0) + { + *pwc = (ucs4_t)c; + return 1; } - } - else if (c < 0xd0) { - *pwc = (ucs4_t) c; - return 1; - } - else if (c < 0xe0) { - *pwc = (ucs4_t) cp1254_2uni_2[c-0xd0]; - return 1; - } - else if (c < 0xf0) { - *pwc = (ucs4_t) c; - return 1; - } - else { - *pwc = (ucs4_t) cp1254_2uni_3[c-0xf0]; - return 1; - } - return RET_ILSEQ; + else if (c < 0xe0) + { + *pwc = (ucs4_t)cp1254_2uni_2[c - 0xd0]; + return 1; + } + else if (c < 0xf0) + { + *pwc = (ucs4_t)c; + return 1; + } + else + { + *pwc = (ucs4_t)cp1254_2uni_3[c - 0xf0]; + return 1; + } + return RET_ILSEQ; } static const unsigned char cp1254_page00[48] = { @@ -115,31 +127,34 @@ static const unsigned char cp1254_page20[48] = { 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ }; -static int -cp1254_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1254_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00d0) - c = wc; - else if (wc >= 0x00d0 && wc < 0x0100) - c = cp1254_page00[wc-0x00d0]; - else if (wc >= 0x0118 && wc < 0x0198) - c = cp1254_page01[wc-0x0118]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = cp1254_page02[wc-0x02c0]; - else if (wc >= 0x2010 && wc < 0x2040) - c = cp1254_page20[wc-0x2010]; - else if (wc == 0x20ac) - c = 0x80; - else if (wc == 0x2122) - c = 0x99; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00d0) + c = wc; + else if (wc >= 0x00d0 && wc < 0x0100) + c = cp1254_page00[wc - 0x00d0]; + else if (wc >= 0x0118 && wc < 0x0198) + c = cp1254_page01[wc - 0x0118]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = cp1254_page02[wc - 0x02c0]; + else if (wc >= 0x2010 && wc < 0x2040) + c = cp1254_page20[wc - 0x2010]; + else if (wc == 0x20ac) + c = 0x80; + else if (wc == 0x2122) + c = 0x99; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1254_H_ */ diff --git a/lib/converters/cp1255.h b/lib/converters/cp1255.h new file mode 100644 index 00000000..d0fd58af --- /dev/null +++ b/lib/converters/cp1255.h @@ -0,0 +1,413 @@ +/** + * @file cp1255.h + * @brief CP1255 + * @copyright Copyright (C) 1999-2001, 2004, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _CP1255_H_ +#define _CP1255_H_ + +#include "reiconv_defines.h" + +#include "flushwc.h" // IWYU pragma: keep + +/* Combining characters used in Hebrew encoding CP1255. */ + +/* Relevant combining characters: + 0x05b4, 0x05b7, 0x05b8, 0x05b9, 0x05bc, 0x05bf, 0x05c1, 0x05c2. */ + +/* Composition tables for each of the relevant combining characters. */ +static const struct +{ + unsigned short base; + unsigned short composed; +} cp1255_comp_table_data[] = { +#define cp1255_comp_table05b4_idx 0 +#define cp1255_comp_table05b4_len 1 + {0x05D9, 0xFB1D}, +#define cp1255_comp_table05b7_idx (cp1255_comp_table05b4_idx + cp1255_comp_table05b4_len) +#define cp1255_comp_table05b7_len 2 + {0x05D0, 0xFB2E}, {0x05F2, 0xFB1F}, +#define cp1255_comp_table05b8_idx (cp1255_comp_table05b7_idx + cp1255_comp_table05b7_len) +#define cp1255_comp_table05b8_len 1 + {0x05D0, 0xFB2F}, +#define cp1255_comp_table05b9_idx (cp1255_comp_table05b8_idx + cp1255_comp_table05b8_len) +#define cp1255_comp_table05b9_len 1 + {0x05D5, 0xFB4B}, +#define cp1255_comp_table05bc_idx (cp1255_comp_table05b9_idx + cp1255_comp_table05b9_len) +#define cp1255_comp_table05bc_len 24 + {0x05D0, 0xFB30}, {0x05D1, 0xFB31}, {0x05D2, 0xFB32}, {0x05D3, 0xFB33}, {0x05D4, 0xFB34}, {0x05D5, 0xFB35}, + {0x05D6, 0xFB36}, {0x05D8, 0xFB38}, {0x05D9, 0xFB39}, {0x05DA, 0xFB3A}, {0x05DB, 0xFB3B}, {0x05DC, 0xFB3C}, + {0x05DE, 0xFB3E}, {0x05E0, 0xFB40}, {0x05E1, 0xFB41}, {0x05E3, 0xFB43}, {0x05E4, 0xFB44}, {0x05E6, 0xFB46}, + {0x05E7, 0xFB47}, {0x05E8, 0xFB48}, {0x05E9, 0xFB49}, {0x05EA, 0xFB4A}, {0xFB2A, 0xFB2C}, {0xFB2B, 0xFB2D}, +#define cp1255_comp_table05bf_idx (cp1255_comp_table05bc_idx + cp1255_comp_table05bc_len) +#define cp1255_comp_table05bf_len 3 + {0x05D1, 0xFB4C}, {0x05DB, 0xFB4D}, {0x05E4, 0xFB4E}, +#define cp1255_comp_table05c1_idx (cp1255_comp_table05bf_idx + cp1255_comp_table05bf_len) +#define cp1255_comp_table05c1_len 2 + {0x05E9, 0xFB2A}, {0xFB49, 0xFB2C}, +#define cp1255_comp_table05c2_idx (cp1255_comp_table05c1_idx + cp1255_comp_table05c1_len) +#define cp1255_comp_table05c2_len 2 + {0x05E9, 0xFB2B}, {0xFB49, 0xFB2D}, +}; +static const struct +{ + unsigned int len; + unsigned int idx; +} cp1255_comp_table[] = { + {cp1255_comp_table05b4_len, cp1255_comp_table05b4_idx}, {cp1255_comp_table05b7_len, cp1255_comp_table05b7_idx}, + {cp1255_comp_table05b8_len, cp1255_comp_table05b8_idx}, {cp1255_comp_table05b9_len, cp1255_comp_table05b9_idx}, + {cp1255_comp_table05bc_len, cp1255_comp_table05bc_idx}, {cp1255_comp_table05bf_len, cp1255_comp_table05bf_idx}, + {cp1255_comp_table05c1_len, cp1255_comp_table05c1_idx}, {cp1255_comp_table05c2_len, cp1255_comp_table05c2_idx}, +}; + +/* Decomposition table for the relevant Unicode characters. */ +struct cp1255_decomp +{ + unsigned short composed; + unsigned short base; + int comb1 : 8; + signed int comb2 : 8; +}; +static const struct cp1255_decomp cp1255_decomp_table[] = { + { 0xFB1D, 0x05D9, 0, -1 }, + { 0xFB1F, 0x05F2, 1, -1 }, + { 0xFB2A, 0x05E9, 6, -1 }, + { 0xFB2B, 0x05E9, 7, -1 }, + { 0xFB2C, 0x05E9, 4, 6 }, + { 0xFB2D, 0x05E9, 4, 7 }, + { 0xFB2E, 0x05D0, 1, -1 }, + { 0xFB2F, 0x05D0, 2, -1 }, + { 0xFB30, 0x05D0, 4, -1 }, + { 0xFB31, 0x05D1, 4, -1 }, + { 0xFB32, 0x05D2, 4, -1 }, + { 0xFB33, 0x05D3, 4, -1 }, + { 0xFB34, 0x05D4, 4, -1 }, + { 0xFB35, 0x05D5, 4, -1 }, + { 0xFB36, 0x05D6, 4, -1 }, + { 0xFB38, 0x05D8, 4, -1 }, + { 0xFB39, 0x05D9, 4, -1 }, + { 0xFB3A, 0x05DA, 4, -1 }, + { 0xFB3B, 0x05DB, 4, -1 }, + { 0xFB3C, 0x05DC, 4, -1 }, + { 0xFB3E, 0x05DE, 4, -1 }, + { 0xFB40, 0x05E0, 4, -1 }, + { 0xFB41, 0x05E1, 4, -1 }, + { 0xFB43, 0x05E3, 4, -1 }, + { 0xFB44, 0x05E4, 4, -1 }, + { 0xFB46, 0x05E6, 4, -1 }, + { 0xFB47, 0x05E7, 4, -1 }, + { 0xFB48, 0x05E8, 4, -1 }, + { 0xFB49, 0x05E9, 4, -1 }, + { 0xFB4A, 0x05EA, 4, -1 }, + { 0xFB4B, 0x05D5, 3, -1 }, + { 0xFB4C, 0x05D1, 5, -1 }, + { 0xFB4D, 0x05DB, 5, -1 }, + { 0xFB4E, 0x05E4, 5, -1 }, +}; + +static const unsigned char cp1255_comb_table[] = { + 0xc4, 0xc7, 0xc8, 0xc9, 0xcc, 0xcf, 0xd1, 0xd2, +}; + +static const unsigned short cp1255_2uni[128] = { + /* 0x80 */ + 0x20ac, 0xfffd, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, + 0x02c6, 0x2030, 0xfffd, 0x2039, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + /* 0x90 */ + 0xfffd, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, + 0x02dc, 0x2122, 0xfffd, 0x203a, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + /* 0xa0 */ + 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20aa, 0x00a5, 0x00a6, 0x00a7, + 0x00a8, 0x00a9, 0x00d7, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, + /* 0xb0 */ + 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, + 0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, + /* 0xc0 */ + 0x05b0, 0x05b1, 0x05b2, 0x05b3, 0x05b4, 0x05b5, 0x05b6, 0x05b7, + 0x05b8, 0x05b9, 0x05ba, 0x05bb, 0x05bc, 0x05bd, 0x05be, 0x05bf, + /* 0xd0 */ + 0x05c0, 0x05c1, 0x05c2, 0x05c3, 0x05f0, 0x05f1, 0x05f2, 0x05f3, + 0x05f4, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + /* 0xe0 */ + 0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7, + 0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df, + /* 0xf0 */ + 0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7, + 0x05e8, 0x05e9, 0x05ea, 0xfffd, 0xfffd, 0x200e, 0x200f, 0xfffd, +}; + +/* In the CP1255 to Unicode direction, the state contains a buffered + character, or 0 if none. */ + +static int cp1255_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + unsigned short wc; + unsigned short last_wc; + if (c < 0x80) + { + wc = c; + } + else + { + wc = cp1255_2uni[c - 0x80]; + if (wc == 0xfffd) + return RET_ILSEQ; + } + last_wc = conv->istate; + if (last_wc) + { + if (wc >= 0x05b0 && wc < 0x05c5) + { + /* See whether last_wc and wc can be combined. */ + unsigned int k; + unsigned int i1, i2; + switch (wc) + { + case 0x05b4: + k = 0; + break; + case 0x05b7: + k = 1; + break; + case 0x05b8: + k = 2; + break; + case 0x05b9: + k = 3; + break; + case 0x05bc: + k = 4; + break; + case 0x05bf: + k = 5; + break; + case 0x05c1: + k = 6; + break; + case 0x05c2: + k = 7; + break; + default: + goto not_combining; + } + i1 = cp1255_comp_table[k].idx; + i2 = i1 + cp1255_comp_table[k].len - 1; + if (last_wc >= cp1255_comp_table_data[i1].base && last_wc <= cp1255_comp_table_data[i2].base) + { + unsigned int i; + for (;;) + { + i = (i1 + i2) >> 1; + if (last_wc == cp1255_comp_table_data[i].base) + break; + if (last_wc < cp1255_comp_table_data[i].base) + { + if (i1 == i) + goto not_combining; + i2 = i; + } + else + { + if (i1 != i) + i1 = i; + else + { + i = i2; + if (last_wc == cp1255_comp_table_data[i].base) + break; + goto not_combining; + } + } + } + last_wc = cp1255_comp_table_data[i].composed; + if (last_wc == 0xfb2a || last_wc == 0xfb2b || last_wc == 0xfb49) + { + /* Buffer the combined character. */ + conv->istate = last_wc; + return RET_TOOFEW(1); + } + else + { + /* Output the combined character. */ + conv->istate = 0; + *pwc = (ucs4_t)last_wc; + return 1; + } + } + } + not_combining: + /* Output the buffered character. */ + conv->istate = 0; + *pwc = (ucs4_t)last_wc; + return 0; /* Don't advance the input pointer. */ + } + if ((wc >= 0x05d0 && wc <= 0x05ea && ((0x07db5f7f >> (wc - 0x05d0)) & 1)) || wc == 0x05f2) + { + /* wc is a possible match in cp1255_comp_table_data. Buffer it. */ + conv->istate = wc; + return RET_TOOFEW(1); + } + else + { + /* Output wc immediately. */ + *pwc = (ucs4_t)wc; + return 1; + } +} + +#define cp1255_flushwc normal_flushwc + +static const unsigned char cp1255_page00[88] = { + 0xa0, 0xa1, 0xa2, 0xa3, 0x00, 0xa5, 0xa6, 0xa7, /* 0xa0-0xa7 */ + 0xa8, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */ + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ + 0xb8, 0xb9, 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* 0xb8-0xbf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, /* 0xd0-0xd7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, /* 0xf0-0xf7 */ +}; +static const unsigned char cp1255_page02[32] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, /* 0xc0-0xc7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ + 0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ +}; +static const unsigned char cp1255_page05[72] = { + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xb0-0xb7 */ + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xb8-0xbf */ + 0xd0, 0xd1, 0xd2, 0xd3, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xd0-0xd7 */ + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xd8-0xdf */ + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xe0-0xe7 */ + 0xf8, 0xf9, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ + 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ +}; +static const unsigned char cp1255_page20[56] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, 0xfe, /* 0x08-0x0f */ + 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */ + 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ + 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ + 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ +}; + +static int cp1255_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00f8) + c = cp1255_page00[wc - 0x00a0]; + else if (wc == 0x0192) + c = 0x83; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = cp1255_page02[wc - 0x02c0]; + else if (wc >= 0x05b0 && wc < 0x05f8) + c = cp1255_page05[wc - 0x05b0]; + else if (wc >= 0x2008 && wc < 0x2040) + c = cp1255_page20[wc - 0x2008]; + else if (wc == 0x20aa) + c = 0xa4; + else if (wc == 0x20ac) + c = 0x80; + else if (wc == 0x2122) + c = 0x99; + if (c != 0) + { + *r = c; + return 1; + } + /* Try canonical decomposition. */ + { + /* Binary search through cp1255_decomp_table. */ + unsigned int i1 = 0; + unsigned int i2 = sizeof(cp1255_decomp_table) / sizeof(cp1255_decomp_table[0]) - 1; + if (wc >= cp1255_decomp_table[i1].composed && wc <= cp1255_decomp_table[i2].composed) + { + unsigned int i; + for (;;) + { + /* Here i2 - i1 > 0. */ + i = (i1 + i2) >> 1; + if (wc == cp1255_decomp_table[i].composed) + break; + if (wc < cp1255_decomp_table[i].composed) + { + if (i1 == i) + return RET_ILUNI; + /* Here i1 < i < i2. */ + i2 = i; + } + else + { + /* Here i1 <= i < i2. */ + if (i1 != i) + i1 = i; + else + { + /* Here i2 - i1 = 1. */ + i = i2; + if (wc == cp1255_decomp_table[i].composed) + break; + else + return RET_ILUNI; + } + } + } + /* Found a canonical decomposition. */ + wc = cp1255_decomp_table[i].base; + /* wc is one of 0x05d0..0x05d6, 0x05d8..0x05dc, 0x05de, 0x05e0..0x05e1, + 0x05e3..0x05e4, 0x05e6..0x05ea, 0x05f2. */ + c = cp1255_page05[wc - 0x05b0]; + if (cp1255_decomp_table[i].comb2 < 0) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = c; + r[1] = cp1255_comb_table[cp1255_decomp_table[i].comb1]; + return 2; + } + else + { + if (n < 3) + return RET_TOOSMALL; + r[0] = c; + r[1] = cp1255_comb_table[cp1255_decomp_table[i].comb1]; + r[2] = cp1255_comb_table[cp1255_decomp_table[i].comb2]; + return 3; + } + } + } + return RET_ILUNI; +} + +#endif /* _CP1255_H_ */ diff --git a/lib/cp1256.h b/lib/converters/cp1256.h similarity index 81% rename from lib/cp1256.h rename to lib/converters/cp1256.h index 0254e1db..8e327297 100644 --- a/lib/cp1256.h +++ b/lib/converters/cp1256.h @@ -1,5 +1,10 @@ +/** + * @file cp1256.h + * @brief CP1256 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP1256 - */ +#ifndef _CP1256_H_ +#define _CP1256_H_ + +#include "reiconv_defines.h" static const unsigned short cp1256_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short cp1256_2uni[128] = { 0x0651, 0x00f9, 0x0652, 0x00fb, 0x00fc, 0x200e, 0x200f, 0x06d2, }; -static int -cp1256_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1256_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp1256_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp1256_2uni[c - 0x80]; + return 1; } static const unsigned char cp1256_page00[96] = { @@ -122,31 +127,34 @@ static const unsigned char cp1256_page20[56] = { 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ }; -static int -cp1256_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1256_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = cp1256_page00[wc-0x00a0]; - else if (wc >= 0x0150 && wc < 0x0198) - c = cp1256_page01[wc-0x0150]; - else if (wc == 0x02c6) - c = 0x88; - else if (wc >= 0x0608 && wc < 0x06d8) - c = cp1256_page06[wc-0x0608]; - else if (wc >= 0x2008 && wc < 0x2040) - c = cp1256_page20[wc-0x2008]; - else if (wc == 0x20ac) - c = 0x80; - else if (wc == 0x2122) - c = 0x99; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = cp1256_page00[wc - 0x00a0]; + else if (wc >= 0x0150 && wc < 0x0198) + c = cp1256_page01[wc - 0x0150]; + else if (wc == 0x02c6) + c = 0x88; + else if (wc >= 0x0608 && wc < 0x06d8) + c = cp1256_page06[wc - 0x0608]; + else if (wc >= 0x2008 && wc < 0x2040) + c = cp1256_page20[wc - 0x2008]; + else if (wc == 0x20ac) + c = 0x80; + else if (wc == 0x2122) + c = 0x99; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1256_H_ */ diff --git a/lib/cp1257.h b/lib/converters/cp1257.h similarity index 78% rename from lib/cp1257.h rename to lib/converters/cp1257.h index 4f6a282a..a15fc67f 100644 --- a/lib/cp1257.h +++ b/lib/converters/cp1257.h @@ -1,5 +1,10 @@ +/** + * @file cp1257.h + * @brief CP1257 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP1257 - */ +#ifndef _CP1257_H_ +#define _CP1257_H_ + +#include "reiconv_defines.h" static const unsigned short cp1257_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short cp1257_2uni[128] = { 0x0173, 0x0142, 0x015b, 0x016b, 0x00fc, 0x017c, 0x017e, 0x02d9, }; -static int -cp1257_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp1257_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = cp1257_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = cp1257_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char cp1257_page00[224] = { @@ -112,27 +120,30 @@ static const unsigned char cp1257_page20[48] = { 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ }; -static int -cp1257_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp1257_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0180) - c = cp1257_page00[wc-0x00a0]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = cp1257_page02[wc-0x02c0]; - else if (wc >= 0x2010 && wc < 0x2040) - c = cp1257_page20[wc-0x2010]; - else if (wc == 0x20ac) - c = 0x80; - else if (wc == 0x2122) - c = 0x99; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0180) + c = cp1257_page00[wc - 0x00a0]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = cp1257_page02[wc - 0x02c0]; + else if (wc >= 0x2010 && wc < 0x2040) + c = cp1257_page20[wc - 0x2010]; + else if (wc == 0x20ac) + c = 0x80; + else if (wc == 0x2122) + c = 0x99; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP1257_H_ */ diff --git a/lib/converters/cp1258.h b/lib/converters/cp1258.h new file mode 100644 index 00000000..312a81dd --- /dev/null +++ b/lib/converters/cp1258.h @@ -0,0 +1,326 @@ +/** + * @file cp1258.h + * @brief CP1258 + * @copyright Copyright (C) 1999-2001, 2004, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _CP1258_H_ +#define _CP1258_H_ + +#include "reiconv_defines.h" + +#include "flushwc.h" // IWYU pragma: keep +#include "vietcomb.h" + +#include + +static const unsigned char cp1258_comb_table[] = { + 0xcc, 0xec, 0xde, 0xd2, 0xf2, +}; + +/* The possible bases in viet_comp_table_data: + 0x0041..0x0045, 0x0047..0x0049, 0x004B..0x0050, 0x0052..0x0057, + 0x0059..0x005A, 0x0061..0x0065, 0x0067..0x0069, 0x006B..0x0070, + 0x0072..0x0077, 0x0079..0x007A, 0x00A5, 0x00A8, 0x00C2, 0x00C5..0x00C7, + 0x00CA, 0x00CF, 0x00D3..0x00D4, 0x00D6, 0x00D8, 0x00DA, 0x00DC, 0x00E2, + 0x00E5..0x00E7, 0x00EA, 0x00EF, 0x00F3..0x00F4, 0x00F6, 0x00F8, 0x00FA, + 0x00FC, 0x0102..0x0103, 0x01A0..0x01A1, 0x01AF..0x01B0. */ +static const unsigned int cp1258_comp_bases[] = { + 0x06fdfbbe, 0x06fdfbbe, 0x00000000, 0x00000120, 0x155884e4, 0x155884e4, + 0x0000000c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00018003 +}; + +static const unsigned short cp1258_2uni[128] = { + /* 0x80 */ + 0x20ac, 0xfffd, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, + 0x02c6, 0x2030, 0xfffd, 0x2039, 0x0152, 0xfffd, 0xfffd, 0xfffd, + /* 0x90 */ + 0xfffd, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, + 0x02dc, 0x2122, 0xfffd, 0x203a, 0x0153, 0xfffd, 0xfffd, 0x0178, + /* 0xa0 */ + 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, + 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, + /* 0xb0 */ + 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, + 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, + /* 0xc0 */ + 0x00c0, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x00c5, 0x00c6, 0x00c7, + 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x0300, 0x00cd, 0x00ce, 0x00cf, + /* 0xd0 */ + 0x0110, 0x00d1, 0x0309, 0x00d3, 0x00d4, 0x01a0, 0x00d6, 0x00d7, + 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x01af, 0x0303, 0x00df, + /* 0xe0 */ + 0x00e0, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x00e5, 0x00e6, 0x00e7, + 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x0301, 0x00ed, 0x00ee, 0x00ef, + /* 0xf0 */ + 0x0111, 0x00f1, 0x0323, 0x00f3, 0x00f4, 0x01a1, 0x00f6, 0x00f7, + 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x01b0, 0x20ab, 0x00ff, +}; + +/* In the CP1258 to Unicode direction, the state contains a buffered + character, or 0 if none. */ + +static int cp1258_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + unsigned short wc; + unsigned short last_wc; + if (c < 0x80) + { + wc = c; + } + else + { + wc = cp1258_2uni[c - 0x80]; + if (wc == 0xfffd) + return RET_ILSEQ; + } + last_wc = conv->istate; + if (last_wc) + { + if (wc >= 0x0300 && wc < 0x0340) + { + /* See whether last_wc and wc can be combined. */ + unsigned int k; + unsigned int i1, i2; + switch (wc) + { + case 0x0300: + k = 0; + break; + case 0x0301: + k = 1; + break; + case 0x0303: + k = 2; + break; + case 0x0309: + k = 3; + break; + case 0x0323: + k = 4; + break; + default: + abort(); + } + i1 = viet_comp_table[k].idx; + i2 = i1 + viet_comp_table[k].len - 1; + if (last_wc >= viet_comp_table_data[i1].base && last_wc <= viet_comp_table_data[i2].base) + { + unsigned int i; + for (;;) + { + i = (i1 + i2) >> 1; + if (last_wc == viet_comp_table_data[i].base) + break; + if (last_wc < viet_comp_table_data[i].base) + { + if (i1 == i) + goto not_combining; + i2 = i; + } + else + { + if (i1 != i) + i1 = i; + else + { + i = i2; + if (last_wc == viet_comp_table_data[i].base) + break; + goto not_combining; + } + } + } + last_wc = viet_comp_table_data[i].composed; + /* Output the combined character. */ + conv->istate = 0; + *pwc = (ucs4_t)last_wc; + return 1; + } + } + not_combining: + /* Output the buffered character. */ + conv->istate = 0; + *pwc = (ucs4_t)last_wc; + return 0; /* Don't advance the input pointer. */ + } + if (wc >= 0x0041 && wc <= 0x01b0 && ((cp1258_comp_bases[(wc - 0x0040) >> 5] >> (wc & 0x1f)) & 1)) + { + /* wc is a possible match in viet_comp_table_data. Buffer it. */ + conv->istate = wc; + return RET_TOOFEW(1); + } + else + { + /* Output wc immediately. */ + *pwc = (ucs4_t)wc; + return 1; + } +} + +#define cp1258_flushwc normal_flushwc + +static const unsigned char cp1258_page00[88] = { + 0xc0, 0xc1, 0xc2, 0x00, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0-0xc7 */ + 0xc8, 0xc9, 0xca, 0xcb, 0x00, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */ + 0x00, 0xd1, 0x00, 0xd3, 0xd4, 0x00, 0xd6, 0xd7, /* 0xd0-0xd7 */ + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0x00, 0x00, 0xdf, /* 0xd8-0xdf */ + 0xe0, 0xe1, 0xe2, 0x00, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0-0xe7 */ + 0xe8, 0xe9, 0xea, 0xeb, 0x00, 0xed, 0xee, 0xef, /* 0xe8-0xef */ + 0x00, 0xf1, 0x00, 0xf3, 0xf4, 0x00, 0xf6, 0xf7, /* 0xf0-0xf7 */ + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0x00, 0xff, /* 0xf8-0xff */ + /* 0x0100 */ + 0x00, 0x00, 0xc3, 0xe3, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ + 0xd0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ +}; +static const unsigned char cp1258_page01[104] = { + 0x00, 0x00, 0x8c, 0x9c, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ + 0x9f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ + 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ + 0xd5, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdd, /* 0xa8-0xaf */ + 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ +}; +static const unsigned char cp1258_page02[32] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, /* 0xc0-0xc7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ + 0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ +}; +static const unsigned char cp1258_page03[40] = { + 0xcc, 0xec, 0x00, 0xde, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ + 0x00, 0xd2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ + 0x00, 0x00, 0x00, 0xf2, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ +}; +static const unsigned char cp1258_page20[48] = { + 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */ + 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ + 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ + 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ +}; + +static int cp1258_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00c0) + c = wc; + else if (wc >= 0x00c0 && wc < 0x0118) + c = cp1258_page00[wc - 0x00c0]; + else if (wc >= 0x0150 && wc < 0x01b8) + c = cp1258_page01[wc - 0x0150]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = cp1258_page02[wc - 0x02c0]; + else if (wc >= 0x0300 && wc < 0x0328) + c = cp1258_page03[wc - 0x0300]; + else if (wc >= 0x0340 && wc < 0x0342) /* deprecated Vietnamese tone marks */ + c = cp1258_page03[wc - 0x0340]; + else if (wc >= 0x2010 && wc < 0x2040) + c = cp1258_page20[wc - 0x2010]; + else if (wc == 0x20ab) + c = 0xfe; + else if (wc == 0x20ac) + c = 0x80; + else if (wc == 0x2122) + c = 0x99; + if (c != 0) + { + *r = c; + return 1; + } + /* Try canonical decomposition. */ + { + /* Binary search through viet_decomp_table. */ + unsigned int i1 = 0; + unsigned int i2 = sizeof(viet_decomp_table) / sizeof(viet_decomp_table[0]) - 1; + if (wc >= viet_decomp_table[i1].composed && wc <= viet_decomp_table[i2].composed) + { + unsigned int i; + for (;;) + { + /* Here i2 - i1 > 0. */ + i = (i1 + i2) >> 1; + if (wc == viet_decomp_table[i].composed) + break; + if (wc < viet_decomp_table[i].composed) + { + if (i1 == i) + return RET_ILUNI; + /* Here i1 < i < i2. */ + i2 = i; + } + else + { + /* Here i1 <= i < i2. */ + if (i1 != i) + i1 = i; + else + { + /* Here i2 - i1 = 1. */ + i = i2; + if (wc == viet_decomp_table[i].composed) + break; + else + return RET_ILUNI; + } + } + } + /* Found a canonical decomposition. */ + wc = viet_decomp_table[i].base; + /* wc is one of 0x0020, 0x0041..0x005a, 0x0061..0x007a, 0x00a5, 0x00a8, + 0x00c2, 0x00c5..0x00c7, 0x00ca, 0x00cf, 0x00d3, 0x00d4, 0x00d6, + 0x00d8, 0x00da, 0x00dc, 0x00e2, 0x00e5..0x00e7, 0x00ea, 0x00ef, + 0x00f3, 0x00f4, 0x00f6, 0x00f8, 0x00fc, 0x0102, 0x0103, 0x01a0, + 0x01a1, 0x01af, 0x01b0. */ + if (wc < 0x0100) + c = wc; + else if (wc < 0x0118) + c = cp1258_page00[wc - 0x00c0]; + else + c = cp1258_page01[wc - 0x0150]; + if (n < 2) + return RET_TOOSMALL; + r[0] = c; + r[1] = cp1258_comb_table[viet_decomp_table[i].comb1]; + return 2; + } + } + return RET_ILUNI; +} + +#endif /* _CP1258_H_ */ diff --git a/lib/cp437.h b/lib/converters/cp437.h similarity index 81% rename from lib/cp437.h rename to lib/converters/cp437.h index 146ce0de..0e3c9b9b 100644 --- a/lib/cp437.h +++ b/lib/converters/cp437.h @@ -1,5 +1,10 @@ +/** + * @file cp437.h + * @brief CP437 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP437 - */ +#ifndef _CP437_H_ +#define _CP437_H_ + +#include "reiconv_defines.h" static const unsigned short cp437_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short cp437_2uni[128] = { 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0, }; -static int -cp437_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp437_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp437_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp437_2uni[c - 0x80]; + return 1; } static const unsigned char cp437_page00[96] = { @@ -123,33 +128,36 @@ static const unsigned char cp437_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp437_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp437_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = cp437_page00[wc-0x00a0]; - else if (wc == 0x0192) - c = 0x9f; - else if (wc >= 0x0390 && wc < 0x03c8) - c = cp437_page03[wc-0x0390]; - else if (wc == 0x207f) - c = 0xfc; - else if (wc == 0x20a7) - c = 0x9e; - else if (wc >= 0x2218 && wc < 0x2268) - c = cp437_page22[wc-0x2218]; - else if (wc >= 0x2310 && wc < 0x2328) - c = cp437_page23[wc-0x2310]; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp437_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = cp437_page00[wc - 0x00a0]; + else if (wc == 0x0192) + c = 0x9f; + else if (wc >= 0x0390 && wc < 0x03c8) + c = cp437_page03[wc - 0x0390]; + else if (wc == 0x207f) + c = 0xfc; + else if (wc == 0x20a7) + c = 0x9e; + else if (wc >= 0x2218 && wc < 0x2268) + c = cp437_page22[wc - 0x2218]; + else if (wc >= 0x2310 && wc < 0x2328) + c = cp437_page23[wc - 0x2310]; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp437_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP437_H_ */ diff --git a/lib/cp50221_0208_ext.h b/lib/converters/cp50221_0208_ext.h similarity index 77% rename from lib/cp50221_0208_ext.h rename to lib/converters/cp50221_0208_ext.h index eb221908..40d9cc69 100644 --- a/lib/cp50221_0208_ext.h +++ b/lib/converters/cp50221_0208_ext.h @@ -1,5 +1,10 @@ +/** + * @file cp50221_0208_ext.h + * @brief CP50221 JISX0208 extensions + * @copyright Copyright (C) 1999-2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP50221 JISX0208 extensions - */ +#ifndef _CP50221_0208_EXT_H_ +#define _CP50221_0208_EXT_H_ + +#include "reiconv_defines.h" static const unsigned short cp50221_0208_ext_2uni[96] = { /* 0x00 */ @@ -42,18 +48,19 @@ static const unsigned short cp50221_0208_ext_2uni[96] = { 0x221f, 0x22bf, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, }; -static int -cp50221_0208_ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp50221_0208_ext_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x60) { - unsigned short wc = cp50221_0208_ext_2uni[c]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x60) + { + unsigned short wc = cp50221_0208_ext_2uni[c]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } } - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned char cp50221_0208_ext_page21[96] = { @@ -121,29 +128,31 @@ static const unsigned char cp50221_0208_ext_page33[208] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, /* 0xc8-0xcf */ }; -static int -cp50221_0208_ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp50221_0208_ext_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc >= 0x2110 && wc < 0x2170) - c = cp50221_0208_ext_page21[wc-0x2110]; - else if (wc >= 0x2210 && wc < 0x2230) - c = cp50221_0208_ext_page22[wc-0x2210]; - else if (wc == 0x22bf) - c = 0x59; - else if (wc >= 0x2460 && wc < 0x2478) - c = cp50221_0208_ext_page24[wc-0x2460]; - else if (wc >= 0x3018 && wc < 0x3020) - c = cp50221_0208_ext_page30[wc-0x3018]; - else if (wc >= 0x3230 && wc < 0x3240) - c = cp50221_0208_ext_page32[wc-0x3230]; - else if (wc >= 0x32a0 && wc < 0x32b0) - c = cp50221_0208_ext_page32_1[wc-0x32a0]; - else if (wc >= 0x3300 && wc < 0x33d0) - c = cp50221_0208_ext_page33[wc-0x3300]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc >= 0x2110 && wc < 0x2170) + c = cp50221_0208_ext_page21[wc - 0x2110]; + else if (wc >= 0x2210 && wc < 0x2230) + c = cp50221_0208_ext_page22[wc - 0x2210]; + else if (wc == 0x22bf) + c = 0x59; + else if (wc >= 0x2460 && wc < 0x2478) + c = cp50221_0208_ext_page24[wc - 0x2460]; + else if (wc >= 0x3018 && wc < 0x3020) + c = cp50221_0208_ext_page30[wc - 0x3018]; + else if (wc >= 0x3230 && wc < 0x3240) + c = cp50221_0208_ext_page32[wc - 0x3230]; + else if (wc >= 0x32a0 && wc < 0x32b0) + c = cp50221_0208_ext_page32_1[wc - 0x32a0]; + else if (wc >= 0x3300 && wc < 0x33d0) + c = cp50221_0208_ext_page33[wc - 0x3300]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP50221_0208_EXT_H_ */ diff --git a/lib/cp50221_0212_ext.h b/lib/converters/cp50221_0212_ext.h similarity index 55% rename from lib/cp50221_0212_ext.h rename to lib/converters/cp50221_0212_ext.h index 355a98f1..f450ea0d 100644 --- a/lib/cp50221_0212_ext.h +++ b/lib/converters/cp50221_0212_ext.h @@ -1,5 +1,10 @@ +/** + * @file cp50221_0212_ext.h + * @brief CP50221 JISX0212 extensions + * @copyright Copyright (C) 1999-2011, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2011, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP50221 JISX0212 extensions - */ +#ifndef _CP50221_0212_EXT_H_ +#define _CP50221_0212_EXT_H_ + +#include "reiconv_defines.h" static const unsigned short cp50221_0212_ext_2uni[112] = { /* 0x00 */ @@ -45,22 +51,24 @@ static const unsigned short cp50221_0212_ext_2uni[112] = { 0x9b72, 0xfa2d, 0x9ed1, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, }; -static int -cp50221_0212_ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp50221_0212_ext_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x70) { - unsigned short wc = cp50221_0212_ext_2uni[c]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x70) + { + unsigned short wc = cp50221_0212_ext_2uni[c]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } } - } - else if (c == 0xa1) { - *pwc = 0x974d; - return 1; - } - return RET_ILSEQ; + else if (c == 0xa1) + { + *pwc = 0x974d; + return 1; + } + return RET_ILSEQ; } static const unsigned char cp50221_0212_ext_page21[16] = { @@ -110,103 +118,105 @@ static const unsigned char cp50221_0212_ext_pageff[8] = { 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x15, /* 0x00-0x07 */ }; -static int -cp50221_0212_ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp50221_0212_ext_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc >= 0x2170 && wc < 0x2180) - c = cp50221_0212_ext_page21[wc-0x2170]; - else if (wc == 0x4efc) - c = 0x1b; - else if (wc == 0x50f4) - c = 0x1c; - else if (wc == 0x51ec) - c = 0x1d; - else if (wc >= 0x5300 && wc < 0x5328) - c = cp50221_0212_ext_page53[wc-0x5300]; - else if (wc == 0x548a) - c = 0x21; - else if (wc == 0x5759) - c = 0x22; - else if (wc == 0x589e) - c = 0x25; - else if (wc == 0x5bec) - c = 0x26; - else if (wc == 0x5cf5) - c = 0x27; - else if (wc == 0x5d53) - c = 0x28; - else if (wc == 0x5fb7) - c = 0x2a; - else if (wc == 0x6085) - c = 0x2b; - else if (wc == 0x6120) - c = 0x2c; - else if (wc == 0x654e) - c = 0x2d; - else if (wc == 0x6665) - c = 0x2f; - else if (wc == 0x6801) - c = 0x32; - else if (wc == 0x6a6b) - c = 0x35; - else if (wc == 0x6ae2) - c = 0x36; - else if (wc >= 0x6df0 && wc < 0x6e00) - c = cp50221_0212_ext_page6d[wc-0x6df0]; - else if (wc == 0x7028) - c = 0x39; - else if (wc == 0x70bb) - c = 0x1a; - else if (wc == 0x7501) - c = 0x3c; - else if (wc >= 0x7680 && wc < 0x76a0) - c = cp50221_0212_ext_page76[wc-0x7680]; - else if (wc == 0x7930) - c = 0x40; - else if (wc == 0x7ae7) - c = 0x45; - else if (wc >= 0x7da0 && wc < 0x7dd8) - c = cp50221_0212_ext_page7d[wc-0x7da0]; - else if (wc == 0x8362) - c = 0x4b; - else if (wc == 0x85b0) - c = 0x4d; - else if (wc == 0x8807) - c = 0x50; - else if (wc == 0x8b7f) - c = 0x52; - else if (wc == 0x8cf4) - c = 0x53; - else if (wc == 0x8d76) - c = 0x54; - else if (wc == 0x90de) - c = 0x58; - else if (wc == 0x9115) - c = 0x5a; - else if (wc == 0x9592) - c = 0x5d; - else if (wc >= 0x9738 && wc < 0x9758) - c = cp50221_0212_ext_page97[wc-0x9738]; - else if (wc == 0x999e) - c = 0x66; - else if (wc == 0x9ad9) - c = 0x67; - else if (wc == 0x9b72) - c = 0x68; - else if (wc == 0x9ed1) - c = 0x6a; - else if (wc == 0xf929) - c = 0x31; - else if (wc == 0xf9dc) - c = 0x5e; - else if (wc >= 0xfa08 && wc < 0xfa30) - c = cp50221_0212_ext_pagefa[wc-0xfa08]; - else if (wc >= 0xff00 && wc < 0xff08) - c = cp50221_0212_ext_pageff[wc-0xff00]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc >= 0x2170 && wc < 0x2180) + c = cp50221_0212_ext_page21[wc - 0x2170]; + else if (wc == 0x4efc) + c = 0x1b; + else if (wc == 0x50f4) + c = 0x1c; + else if (wc == 0x51ec) + c = 0x1d; + else if (wc >= 0x5300 && wc < 0x5328) + c = cp50221_0212_ext_page53[wc - 0x5300]; + else if (wc == 0x548a) + c = 0x21; + else if (wc == 0x5759) + c = 0x22; + else if (wc == 0x589e) + c = 0x25; + else if (wc == 0x5bec) + c = 0x26; + else if (wc == 0x5cf5) + c = 0x27; + else if (wc == 0x5d53) + c = 0x28; + else if (wc == 0x5fb7) + c = 0x2a; + else if (wc == 0x6085) + c = 0x2b; + else if (wc == 0x6120) + c = 0x2c; + else if (wc == 0x654e) + c = 0x2d; + else if (wc == 0x6665) + c = 0x2f; + else if (wc == 0x6801) + c = 0x32; + else if (wc == 0x6a6b) + c = 0x35; + else if (wc == 0x6ae2) + c = 0x36; + else if (wc >= 0x6df0 && wc < 0x6e00) + c = cp50221_0212_ext_page6d[wc - 0x6df0]; + else if (wc == 0x7028) + c = 0x39; + else if (wc == 0x70bb) + c = 0x1a; + else if (wc == 0x7501) + c = 0x3c; + else if (wc >= 0x7680 && wc < 0x76a0) + c = cp50221_0212_ext_page76[wc - 0x7680]; + else if (wc == 0x7930) + c = 0x40; + else if (wc == 0x7ae7) + c = 0x45; + else if (wc >= 0x7da0 && wc < 0x7dd8) + c = cp50221_0212_ext_page7d[wc - 0x7da0]; + else if (wc == 0x8362) + c = 0x4b; + else if (wc == 0x85b0) + c = 0x4d; + else if (wc == 0x8807) + c = 0x50; + else if (wc == 0x8b7f) + c = 0x52; + else if (wc == 0x8cf4) + c = 0x53; + else if (wc == 0x8d76) + c = 0x54; + else if (wc == 0x90de) + c = 0x58; + else if (wc == 0x9115) + c = 0x5a; + else if (wc == 0x9592) + c = 0x5d; + else if (wc >= 0x9738 && wc < 0x9758) + c = cp50221_0212_ext_page97[wc - 0x9738]; + else if (wc == 0x999e) + c = 0x66; + else if (wc == 0x9ad9) + c = 0x67; + else if (wc == 0x9b72) + c = 0x68; + else if (wc == 0x9ed1) + c = 0x6a; + else if (wc == 0xf929) + c = 0x31; + else if (wc == 0xf9dc) + c = 0x5e; + else if (wc >= 0xfa08 && wc < 0xfa30) + c = cp50221_0212_ext_pagefa[wc - 0xfa08]; + else if (wc >= 0xff00 && wc < 0xff08) + c = cp50221_0212_ext_pageff[wc - 0xff00]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP50221_0212_EXT_H_ */ diff --git a/lib/cp737.h b/lib/converters/cp737.h similarity index 80% rename from lib/cp737.h rename to lib/converters/cp737.h index 5552ea17..532bdb82 100644 --- a/lib/cp737.h +++ b/lib/converters/cp737.h @@ -1,5 +1,10 @@ +/** + * @file cp737.h + * @brief CP737 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP737 - */ +#ifndef _CP737_H_ +#define _CP737_H_ + +#include "reiconv_defines.h" static const unsigned short cp737_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short cp737_2uni[128] = { 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0, }; -static int -cp737_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp737_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp737_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp737_2uni[c - 0x80]; + return 1; } static const unsigned char cp737_page00[24] = { @@ -112,29 +117,32 @@ static const unsigned char cp737_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp737_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp737_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00b8) - c = cp737_page00[wc-0x00a0]; - else if (wc == 0x00f7) - c = 0xf6; - else if (wc >= 0x0380 && wc < 0x03d0) - c = cp737_page03[wc-0x0380]; - else if (wc == 0x207f) - c = 0xfc; - else if (wc >= 0x2218 && wc < 0x2268) - c = cp737_page22[wc-0x2218]; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp737_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00b8) + c = cp737_page00[wc - 0x00a0]; + else if (wc == 0x00f7) + c = 0xf6; + else if (wc >= 0x0380 && wc < 0x03d0) + c = cp737_page03[wc - 0x0380]; + else if (wc == 0x207f) + c = 0xfc; + else if (wc >= 0x2218 && wc < 0x2268) + c = cp737_page22[wc - 0x2218]; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp737_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP737_H_ */ diff --git a/lib/cp775.h b/lib/converters/cp775.h similarity index 83% rename from lib/cp775.h rename to lib/converters/cp775.h index db6aa949..c1285c77 100644 --- a/lib/cp775.h +++ b/lib/converters/cp775.h @@ -1,5 +1,10 @@ +/** + * @file cp775.h + * @brief CP775 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP775 - */ +#ifndef _CP775_H_ +#define _CP775_H_ + +#include "reiconv_defines.h" static const unsigned short cp775_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short cp775_2uni[128] = { 0x00b0, 0x2219, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x25a0, 0x00a0, }; -static int -cp775_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp775_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp775_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp775_2uni[c - 0x80]; + return 1; } static const unsigned char cp775_page00[224] = { @@ -117,25 +122,28 @@ static const unsigned char cp775_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp775_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp775_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0180) - c = cp775_page00[wc-0x00a0]; - else if (wc >= 0x2018 && wc < 0x2020) - c = cp775_page20[wc-0x2018]; - else if (wc == 0x2219) - c = 0xf9; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp775_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0180) + c = cp775_page00[wc - 0x00a0]; + else if (wc >= 0x2018 && wc < 0x2020) + c = cp775_page20[wc - 0x2018]; + else if (wc == 0x2219) + c = 0xf9; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp775_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP775_H_ */ diff --git a/lib/cp850.h b/lib/converters/cp850.h similarity index 79% rename from lib/cp850.h rename to lib/converters/cp850.h index 508d5e3e..26594318 100644 --- a/lib/cp850.h +++ b/lib/converters/cp850.h @@ -1,5 +1,10 @@ +/** + * @file cp850.h + * @brief CP850 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP850 - */ +#ifndef _CP850_H_ +#define _CP850_H_ + +#include "reiconv_defines.h" static const unsigned short cp850_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short cp850_2uni[128] = { 0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x25a0, 0x00a0, }; -static int -cp850_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp850_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp850_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp850_2uni[c - 0x80]; + return 1; } static const unsigned char cp850_page00[96] = { @@ -97,27 +102,30 @@ static const unsigned char cp850_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp850_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp850_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = cp850_page00[wc-0x00a0]; - else if (wc == 0x0131) - c = 0xd5; - else if (wc == 0x0192) - c = 0x9f; - else if (wc == 0x2017) - c = 0xf2; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp850_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = cp850_page00[wc - 0x00a0]; + else if (wc == 0x0131) + c = 0xd5; + else if (wc == 0x0192) + c = 0x9f; + else if (wc == 0x2017) + c = 0xf2; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp850_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP850_H_ */ diff --git a/lib/cp852.h b/lib/converters/cp852.h similarity index 84% rename from lib/cp852.h rename to lib/converters/cp852.h index af41d758..c80c0f51 100644 --- a/lib/cp852.h +++ b/lib/converters/cp852.h @@ -1,5 +1,10 @@ +/** + * @file cp852.h + * @brief CP852 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP852 - */ +#ifndef _CP852_H_ +#define _CP852_H_ + +#include "reiconv_defines.h" static const unsigned short cp852_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short cp852_2uni[128] = { 0x00b0, 0x00a8, 0x02d9, 0x0171, 0x0158, 0x0159, 0x25a0, 0x00a0, }; -static int -cp852_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp852_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp852_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp852_2uni[c - 0x80]; + return 1; } static const unsigned char cp852_page00[224] = { @@ -120,23 +125,26 @@ static const unsigned char cp852_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp852_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp852_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0180) - c = cp852_page00[wc-0x00a0]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = cp852_page02[wc-0x02c0]; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp852_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0180) + c = cp852_page00[wc - 0x00a0]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = cp852_page02[wc - 0x02c0]; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp852_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP852_H_ */ diff --git a/lib/cp853.h b/lib/converters/cp853.h similarity index 80% rename from lib/cp853.h rename to lib/converters/cp853.h index 1fbc31d2..334e3c1f 100644 --- a/lib/cp853.h +++ b/lib/converters/cp853.h @@ -1,5 +1,10 @@ +/** + * @file cp853.h + * @brief CP853 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP853 - */ +#ifndef _CP853_H_ +#define _CP853_H_ + +#include "reiconv_defines.h" static const unsigned short cp853_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short cp853_2uni[128] = { 0x00b0, 0x00a8, 0x02d9, 0xfffd, 0x00b3, 0x00b2, 0x25a0, 0x00a0, }; -static int -cp853_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp853_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = cp853_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = cp853_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char cp853_page00[96] = { @@ -124,27 +132,30 @@ static const unsigned char cp853_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp853_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp853_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = cp853_page00[wc-0x00a0]; - else if (wc >= 0x0108 && wc < 0x0180) - c = cp853_page01[wc-0x0108]; - else if (wc >= 0x02d8 && wc < 0x02e0) - c = cp853_page02[wc-0x02d8]; - else if (wc == 0x2113) - c = 0xf2; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp853_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = cp853_page00[wc - 0x00a0]; + else if (wc >= 0x0108 && wc < 0x0180) + c = cp853_page01[wc - 0x0108]; + else if (wc >= 0x02d8 && wc < 0x02e0) + c = cp853_page02[wc - 0x02d8]; + else if (wc == 0x2113) + c = 0xf2; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp853_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP853_H_ */ diff --git a/lib/cp855.h b/lib/converters/cp855.h similarity index 80% rename from lib/cp855.h rename to lib/converters/cp855.h index bc7b0e87..31fe9e6c 100644 --- a/lib/cp855.h +++ b/lib/converters/cp855.h @@ -1,5 +1,10 @@ +/** + * @file cp855.h + * @brief CP855 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP855 - */ +#ifndef _CP855_H_ +#define _CP855_H_ + +#include "reiconv_defines.h" static const unsigned short cp855_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short cp855_2uni[128] = { 0x042d, 0x0449, 0x0429, 0x0447, 0x0427, 0x00a7, 0x25a0, 0x00a0, }; -static int -cp855_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp855_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp855_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp855_2uni[c - 0x80]; + return 1; } static const unsigned char cp855_page00[32] = { @@ -103,25 +108,28 @@ static const unsigned char cp855_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp855_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp855_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00c0) - c = cp855_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x0460) - c = cp855_page04[wc-0x0400]; - else if (wc == 0x2116) - c = 0xef; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp855_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00c0) + c = cp855_page00[wc - 0x00a0]; + else if (wc >= 0x0400 && wc < 0x0460) + c = cp855_page04[wc - 0x0400]; + else if (wc == 0x2116) + c = 0xef; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp855_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP855_H_ */ diff --git a/lib/cp856.h b/lib/converters/cp856.h similarity index 78% rename from lib/cp856.h rename to lib/converters/cp856.h index 3b1ffcaa..7b37d9a6 100644 --- a/lib/cp856.h +++ b/lib/converters/cp856.h @@ -1,5 +1,10 @@ +/** + * @file cp856.h + * @brief CP856 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP856 - */ +#ifndef _CP856_H_ +#define _CP856_H_ + +#include "reiconv_defines.h" static const unsigned short cp856_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short cp856_2uni[128] = { 0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x25a0, 0x00a0, }; -static int -cp856_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp856_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = cp856_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = cp856_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char cp856_page00[88] = { @@ -109,25 +117,28 @@ static const unsigned char cp856_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp856_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp856_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00f8) - c = cp856_page00[wc-0x00a0]; - else if (wc >= 0x05d0 && wc < 0x05f0) - c = cp856_page05[wc-0x05d0]; - else if (wc == 0x2017) - c = 0xf2; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp856_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00f8) + c = cp856_page00[wc - 0x00a0]; + else if (wc >= 0x05d0 && wc < 0x05f0) + c = cp856_page05[wc - 0x05d0]; + else if (wc == 0x2017) + c = 0xf2; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp856_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP856_H_ */ diff --git a/lib/cp857.h b/lib/converters/cp857.h similarity index 80% rename from lib/cp857.h rename to lib/converters/cp857.h index 26afee12..dd9b3007 100644 --- a/lib/cp857.h +++ b/lib/converters/cp857.h @@ -1,5 +1,10 @@ +/** + * @file cp857.h + * @brief CP857 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP857 - */ +#ifndef _CP857_H_ +#define _CP857_H_ + +#include "reiconv_defines.h" static const unsigned short cp857_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short cp857_2uni[128] = { 0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x25a0, 0x00a0, }; -static int -cp857_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp857_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = cp857_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = cp857_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char cp857_page00[96] = { @@ -115,23 +123,26 @@ static const unsigned char cp857_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp857_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp857_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = cp857_page00[wc-0x00a0]; - else if (wc >= 0x0118 && wc < 0x0160) - c = cp857_page01[wc-0x0118]; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp857_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = cp857_page00[wc - 0x00a0]; + else if (wc >= 0x0118 && wc < 0x0160) + c = cp857_page01[wc - 0x0118]; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp857_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP857_H_ */ diff --git a/lib/converters/cp858.h b/lib/converters/cp858.h new file mode 100644 index 00000000..c3699c51 --- /dev/null +++ b/lib/converters/cp858.h @@ -0,0 +1,69 @@ +/** + * @file cp858.h + * @brief CP858 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _CP858_H_ +#define _CP858_H_ + +#include "converters/cp850.h" +#include "reiconv_defines.h" + +static int cp858_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else if (c == 0xd5) + *pwc = 0x20ac; + else + *pwc = (ucs4_t)cp850_2uni[c - 0x80]; + return 1; +} + +static int cp858_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = cp850_page00[wc - 0x00a0]; + else if (wc == 0x0192) + c = 0x9f; + else if (wc == 0x2017) + c = 0xf2; + else if (wc == 0x20ac) + c = 0xd5; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp850_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; +} + +#endif /* _CP858_H_ */ diff --git a/lib/cp860.h b/lib/converters/cp860.h similarity index 81% rename from lib/cp860.h rename to lib/converters/cp860.h index d66de0e7..cf27c030 100644 --- a/lib/cp860.h +++ b/lib/converters/cp860.h @@ -1,5 +1,10 @@ +/** + * @file cp860.h + * @brief CP860 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP860 - */ +#ifndef _CP860_H_ +#define _CP860_H_ + +#include "reiconv_defines.h" static const unsigned short cp860_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short cp860_2uni[128] = { 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0, }; -static int -cp860_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp860_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp860_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp860_2uni[c - 0x80]; + return 1; } static const unsigned char cp860_page00[96] = { @@ -118,31 +123,34 @@ static const unsigned char cp860_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp860_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp860_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = cp860_page00[wc-0x00a0]; - else if (wc >= 0x0390 && wc < 0x03c8) - c = cp860_page03[wc-0x0390]; - else if (wc == 0x207f) - c = 0xfc; - else if (wc == 0x20a7) - c = 0x9e; - else if (wc >= 0x2218 && wc < 0x2268) - c = cp860_page22[wc-0x2218]; - else if (wc >= 0x2320 && wc < 0x2322) - c = wc-0x222c; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp860_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = cp860_page00[wc - 0x00a0]; + else if (wc >= 0x0390 && wc < 0x03c8) + c = cp860_page03[wc - 0x0390]; + else if (wc == 0x207f) + c = 0xfc; + else if (wc == 0x20a7) + c = 0x9e; + else if (wc >= 0x2218 && wc < 0x2268) + c = cp860_page22[wc - 0x2218]; + else if (wc >= 0x2320 && wc < 0x2322) + c = wc - 0x222c; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp860_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP860_H_ */ diff --git a/lib/cp861.h b/lib/converters/cp861.h similarity index 81% rename from lib/cp861.h rename to lib/converters/cp861.h index 3d5a0876..a6ac34c9 100644 --- a/lib/cp861.h +++ b/lib/converters/cp861.h @@ -1,5 +1,10 @@ +/** + * @file cp861.h + * @brief CP861 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP861 - */ +#ifndef _CP861_H_ +#define _CP861_H_ + +#include "reiconv_defines.h" static const unsigned short cp861_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short cp861_2uni[128] = { 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0, }; -static int -cp861_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp861_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp861_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp861_2uni[c - 0x80]; + return 1; } static const unsigned char cp861_page00[96] = { @@ -123,33 +128,36 @@ static const unsigned char cp861_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp861_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp861_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = cp861_page00[wc-0x00a0]; - else if (wc == 0x0192) - c = 0x9f; - else if (wc >= 0x0390 && wc < 0x03c8) - c = cp861_page03[wc-0x0390]; - else if (wc == 0x207f) - c = 0xfc; - else if (wc == 0x20a7) - c = 0x9e; - else if (wc >= 0x2218 && wc < 0x2268) - c = cp861_page22[wc-0x2218]; - else if (wc >= 0x2310 && wc < 0x2328) - c = cp861_page23[wc-0x2310]; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp861_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = cp861_page00[wc - 0x00a0]; + else if (wc == 0x0192) + c = 0x9f; + else if (wc >= 0x0390 && wc < 0x03c8) + c = cp861_page03[wc - 0x0390]; + else if (wc == 0x207f) + c = 0xfc; + else if (wc == 0x20a7) + c = 0x9e; + else if (wc >= 0x2218 && wc < 0x2268) + c = cp861_page22[wc - 0x2218]; + else if (wc >= 0x2310 && wc < 0x2328) + c = cp861_page23[wc - 0x2310]; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp861_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP861_H_ */ diff --git a/lib/cp862.h b/lib/converters/cp862.h similarity index 79% rename from lib/cp862.h rename to lib/converters/cp862.h index 913dad29..ef1e526e 100644 --- a/lib/cp862.h +++ b/lib/converters/cp862.h @@ -1,5 +1,10 @@ +/** + * @file cp862.h + * @brief CP862 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP862 - */ +#ifndef _CP862_H_ +#define _CP862_H_ + +#include "reiconv_defines.h" static const unsigned short cp862_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short cp862_2uni[128] = { 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0, }; -static int -cp862_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp862_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp862_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp862_2uni[c - 0x80]; + return 1; } static const unsigned char cp862_page00[96] = { @@ -118,37 +123,40 @@ static const unsigned char cp862_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp862_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp862_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = cp862_page00[wc-0x00a0]; - else if (wc == 0x0192) - c = 0x9f; - else if (wc >= 0x0390 && wc < 0x03c8) - c = cp862_page03[wc-0x0390]; - else if (wc >= 0x05d0 && wc < 0x05eb) - c = wc-0x0550; - else if (wc == 0x207f) - c = 0xfc; - else if (wc == 0x20a7) - c = 0x9e; - else if (wc >= 0x2218 && wc < 0x2268) - c = cp862_page22[wc-0x2218]; - else if (wc == 0x2310) - c = 0xa9; - else if (wc >= 0x2320 && wc < 0x2322) - c = wc-0x222c; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp862_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = cp862_page00[wc - 0x00a0]; + else if (wc == 0x0192) + c = 0x9f; + else if (wc >= 0x0390 && wc < 0x03c8) + c = cp862_page03[wc - 0x0390]; + else if (wc >= 0x05d0 && wc < 0x05eb) + c = wc - 0x0550; + else if (wc == 0x207f) + c = 0xfc; + else if (wc == 0x20a7) + c = 0x9e; + else if (wc >= 0x2218 && wc < 0x2268) + c = cp862_page22[wc - 0x2218]; + else if (wc == 0x2310) + c = 0xa9; + else if (wc >= 0x2320 && wc < 0x2322) + c = wc - 0x222c; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp862_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP862_H_ */ diff --git a/lib/cp863.h b/lib/converters/cp863.h similarity index 81% rename from lib/cp863.h rename to lib/converters/cp863.h index 1e9d9075..7ff751a8 100644 --- a/lib/cp863.h +++ b/lib/converters/cp863.h @@ -1,5 +1,10 @@ +/** + * @file cp863.h + * @brief CP863 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP863 - */ +#ifndef _CP863_H_ +#define _CP863_H_ + +#include "reiconv_defines.h" static const unsigned short cp863_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short cp863_2uni[128] = { 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0, }; -static int -cp863_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp863_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp863_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp863_2uni[c - 0x80]; + return 1; } static const unsigned char cp863_page00[96] = { @@ -123,33 +128,36 @@ static const unsigned char cp863_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp863_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp863_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = cp863_page00[wc-0x00a0]; - else if (wc == 0x0192) - c = 0x9f; - else if (wc >= 0x0390 && wc < 0x03c8) - c = cp863_page03[wc-0x0390]; - else if (wc == 0x2017) - c = 0x8d; - else if (wc == 0x207f) - c = 0xfc; - else if (wc >= 0x2218 && wc < 0x2268) - c = cp863_page22[wc-0x2218]; - else if (wc >= 0x2310 && wc < 0x2328) - c = cp863_page23[wc-0x2310]; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp863_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = cp863_page00[wc - 0x00a0]; + else if (wc == 0x0192) + c = 0x9f; + else if (wc >= 0x0390 && wc < 0x03c8) + c = cp863_page03[wc - 0x0390]; + else if (wc == 0x2017) + c = 0x8d; + else if (wc == 0x207f) + c = 0xfc; + else if (wc >= 0x2218 && wc < 0x2268) + c = cp863_page22[wc - 0x2218]; + else if (wc >= 0x2310 && wc < 0x2328) + c = cp863_page23[wc - 0x2310]; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp863_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP863_H_ */ diff --git a/lib/cp864.h b/lib/converters/cp864.h similarity index 77% rename from lib/cp864.h rename to lib/converters/cp864.h index 8c33630f..e56a89a1 100644 --- a/lib/cp864.h +++ b/lib/converters/cp864.h @@ -1,5 +1,10 @@ +/** + * @file cp864.h + * @brief CP864 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP864 - */ +#ifndef _CP864_H_ +#define _CP864_H_ + +#include "reiconv_defines.h" static const unsigned short cp864_2uni_1[16] = { /* 0x20 */ @@ -53,30 +59,34 @@ static const unsigned short cp864_2uni_2[128] = { 0xfed5, 0xfef5, 0xfef6, 0xfedd, 0xfed9, 0xfef1, 0x25a0, 0xfffd, }; -static int -cp864_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp864_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x20) { - *pwc = (ucs4_t) c; - return 1; - } - else if (c < 0x30) { - *pwc = (ucs4_t) cp864_2uni_1[c-0x20]; - return 1; - } - else if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = cp864_2uni_2[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x20) + { + *pwc = (ucs4_t)c; + return 1; + } + else if (c < 0x30) + { + *pwc = (ucs4_t)cp864_2uni_1[c - 0x20]; + return 1; } - } - return RET_ILSEQ; + else if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; + } + else + { + unsigned short wc = cp864_2uni_2[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char cp864_page00[8] = { @@ -149,39 +159,42 @@ static const unsigned char cp864_pagefe[136] = { 0x9a, 0x00, 0x00, 0x9d, 0x9e, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; -static int -cp864_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp864_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0020) { - *r = wc; - return 1; - } - else if (wc >= 0x0020 && wc < 0x0028) - c = cp864_page00[wc-0x0020]; - else if (wc >= 0x0028 && wc < 0x0080) - c = wc; - else if (wc >= 0x00a0 && wc < 0x00f8) - c = cp864_page00_1[wc-0x00a0]; - else if (wc == 0x03b2) - c = 0x90; - else if (wc == 0x03c6) - c = 0x92; - else if (wc >= 0x0608 && wc < 0x0670) - c = cp864_page06[wc-0x0608]; - else if (wc >= 0x2218 && wc < 0x2250) - c = cp864_page22[wc-0x2218]; - else if (wc >= 0x2500 && wc < 0x2540) - c = cp864_page25[wc-0x2500]; - else if (wc == 0x2592) - c = 0x84; - else if (wc == 0x25a0) - c = 0xfe; - else if (wc >= 0xfe78 && wc < 0xff00) - c = cp864_pagefe[wc-0xfe78]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0020) + { + *r = wc; + return 1; + } + else if (wc >= 0x0020 && wc < 0x0028) + c = cp864_page00[wc - 0x0020]; + else if (wc >= 0x0028 && wc < 0x0080) + c = wc; + else if (wc >= 0x00a0 && wc < 0x00f8) + c = cp864_page00_1[wc - 0x00a0]; + else if (wc == 0x03b2) + c = 0x90; + else if (wc == 0x03c6) + c = 0x92; + else if (wc >= 0x0608 && wc < 0x0670) + c = cp864_page06[wc - 0x0608]; + else if (wc >= 0x2218 && wc < 0x2250) + c = cp864_page22[wc - 0x2218]; + else if (wc >= 0x2500 && wc < 0x2540) + c = cp864_page25[wc - 0x2500]; + else if (wc == 0x2592) + c = 0x84; + else if (wc == 0x25a0) + c = 0xfe; + else if (wc >= 0xfe78 && wc < 0xff00) + c = cp864_pagefe[wc - 0xfe78]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP864_H_ */ diff --git a/lib/cp865.h b/lib/converters/cp865.h similarity index 81% rename from lib/cp865.h rename to lib/converters/cp865.h index 1f9e3427..7414f15f 100644 --- a/lib/cp865.h +++ b/lib/converters/cp865.h @@ -1,5 +1,10 @@ +/** + * @file cp865.h + * @brief CP865 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP865 - */ +#ifndef _CP865_H_ +#define _CP865_H_ + +#include "reiconv_defines.h" static const unsigned short cp865_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short cp865_2uni[128] = { 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0, }; -static int -cp865_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp865_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp865_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp865_2uni[c - 0x80]; + return 1; } static const unsigned char cp865_page00[96] = { @@ -123,33 +128,36 @@ static const unsigned char cp865_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp865_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp865_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = cp865_page00[wc-0x00a0]; - else if (wc == 0x0192) - c = 0x9f; - else if (wc >= 0x0390 && wc < 0x03c8) - c = cp865_page03[wc-0x0390]; - else if (wc == 0x207f) - c = 0xfc; - else if (wc == 0x20a7) - c = 0x9e; - else if (wc >= 0x2218 && wc < 0x2268) - c = cp865_page22[wc-0x2218]; - else if (wc >= 0x2310 && wc < 0x2328) - c = cp865_page23[wc-0x2310]; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp865_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = cp865_page00[wc - 0x00a0]; + else if (wc == 0x0192) + c = 0x9f; + else if (wc >= 0x0390 && wc < 0x03c8) + c = cp865_page03[wc - 0x0390]; + else if (wc == 0x207f) + c = 0xfc; + else if (wc == 0x20a7) + c = 0x9e; + else if (wc >= 0x2218 && wc < 0x2268) + c = cp865_page22[wc - 0x2218]; + else if (wc >= 0x2310 && wc < 0x2328) + c = cp865_page23[wc - 0x2310]; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp865_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP865_H_ */ diff --git a/lib/cp866.h b/lib/converters/cp866.h similarity index 77% rename from lib/cp866.h rename to lib/converters/cp866.h index e9ca424c..3c457ff5 100644 --- a/lib/cp866.h +++ b/lib/converters/cp866.h @@ -1,5 +1,10 @@ +/** + * @file cp866.h + * @brief CP866 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP866 - */ +#ifndef _CP866_H_ +#define _CP866_H_ + +#include "reiconv_defines.h" static const unsigned short cp866_2uni[80] = { /* 0xb0 */ @@ -39,17 +45,16 @@ static const unsigned short cp866_2uni[80] = { 0x00b0, 0x2219, 0x00b7, 0x221a, 0x2116, 0x00a4, 0x25a0, 0x00a0, }; -static int -cp866_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp866_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else if (c < 0xb0) - *pwc = (ucs4_t) c + 0x0390; - else - *pwc = (ucs4_t) cp866_2uni[c-0xb0]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else if (c < 0xb0) + *pwc = (ucs4_t)c + 0x0390; + else + *pwc = (ucs4_t)cp866_2uni[c - 0xb0]; + return 1; } static const unsigned char cp866_page00[24] = { @@ -98,27 +103,30 @@ static const unsigned char cp866_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp866_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp866_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00b8) - c = cp866_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x0460) - c = cp866_page04[wc-0x0400]; - else if (wc == 0x2116) - c = 0xfc; - else if (wc >= 0x2218 && wc < 0x2220) - c = cp866_page22[wc-0x2218]; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp866_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00b8) + c = cp866_page00[wc - 0x00a0]; + else if (wc >= 0x0400 && wc < 0x0460) + c = cp866_page04[wc - 0x0400]; + else if (wc == 0x2116) + c = 0xfc; + else if (wc >= 0x2218 && wc < 0x2220) + c = cp866_page22[wc - 0x2218]; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp866_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP866_H_ */ diff --git a/lib/cp869.h b/lib/converters/cp869.h similarity index 78% rename from lib/cp869.h rename to lib/converters/cp869.h index 3705e024..93d10ee9 100644 --- a/lib/cp869.h +++ b/lib/converters/cp869.h @@ -1,5 +1,10 @@ +/** + * @file cp869.h + * @brief CP869 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP869 - */ +#ifndef _CP869_H_ +#define _CP869_H_ + +#include "reiconv_defines.h" static const unsigned short cp869_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short cp869_2uni[128] = { 0x00b0, 0x00a8, 0x03c9, 0x03cb, 0x03b0, 0x03ce, 0x25a0, 0x00a0, }; -static int -cp869_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp869_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = cp869_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = cp869_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char cp869_page00[32] = { @@ -112,25 +120,28 @@ static const unsigned char cp869_page25[168] = { 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -cp869_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp869_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00c0) - c = cp869_page00[wc-0x00a0]; - else if (wc >= 0x0380 && wc < 0x03d0) - c = cp869_page03[wc-0x0380]; - else if (wc >= 0x2010 && wc < 0x2020) - c = cp869_page20[wc-0x2010]; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp869_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00c0) + c = cp869_page00[wc - 0x00a0]; + else if (wc >= 0x0380 && wc < 0x03d0) + c = cp869_page03[wc - 0x0380]; + else if (wc >= 0x2010 && wc < 0x2020) + c = cp869_page20[wc - 0x2010]; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp869_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP869_H_ */ diff --git a/lib/cp874.h b/lib/converters/cp874.h similarity index 71% rename from lib/cp874.h rename to lib/converters/cp874.h index 7e1bf6f1..a4f060f3 100644 --- a/lib/cp874.h +++ b/lib/converters/cp874.h @@ -1,5 +1,10 @@ +/** + * @file cp874.h + * @brief CP874 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP874 - */ +#ifndef _CP874_H_ +#define _CP874_H_ + +#include "reiconv_defines.h" static const unsigned short cp874_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short cp874_2uni[128] = { 0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0xfffd, 0xfffd, 0xfffd, 0xfffd, }; -static int -cp874_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp874_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = cp874_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = cp874_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char cp874_page0e[96] = { @@ -86,25 +94,28 @@ static const unsigned char cp874_page20[24] = { 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */ }; -static int -cp874_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp874_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc == 0x00a0) - c = 0xa0; - else if (wc >= 0x0e00 && wc < 0x0e60) - c = cp874_page0e[wc-0x0e00]; - else if (wc >= 0x2010 && wc < 0x2028) - c = cp874_page20[wc-0x2010]; - else if (wc == 0x20ac) - c = 0x80; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc == 0x00a0) + c = 0xa0; + else if (wc >= 0x0e00 && wc < 0x0e60) + c = cp874_page0e[wc - 0x0e00]; + else if (wc >= 0x2010 && wc < 0x2028) + c = cp874_page20[wc - 0x2010]; + else if (wc == 0x20ac) + c = 0x80; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP874_H_ */ diff --git a/lib/cp922.h b/lib/converters/cp922.h similarity index 66% rename from lib/cp922.h rename to lib/converters/cp922.h index b7f7720d..6d86317e 100644 --- a/lib/cp922.h +++ b/lib/converters/cp922.h @@ -1,5 +1,10 @@ +/** + * @file cp922.h + * @brief CP922 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP922 - */ +#ifndef _CP922_H_ +#define _CP922_H_ + +#include "reiconv_defines.h" static const unsigned short cp922_2uni_1[16] = { /* 0xa0 */ @@ -37,23 +43,22 @@ static const unsigned short cp922_2uni_3[16] = { 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x017e, 0x00ff, }; -static int -cp922_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp922_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) - *pwc = (ucs4_t) c; - else if (c < 0xb0) - *pwc = (ucs4_t) cp922_2uni_1[c-0xa0]; - else if (c < 0xd0) - *pwc = (ucs4_t) c; - else if (c < 0xe0) - *pwc = (ucs4_t) cp922_2uni_2[c-0xd0]; - else if (c < 0xf0) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) cp922_2uni_3[c-0xf0]; - return 1; + unsigned char c = *s; + if (c < 0xa0) + *pwc = (ucs4_t)c; + else if (c < 0xb0) + *pwc = (ucs4_t)cp922_2uni_1[c - 0xa0]; + else if (c < 0xd0) + *pwc = (ucs4_t)c; + else if (c < 0xe0) + *pwc = (ucs4_t)cp922_2uni_2[c - 0xd0]; + else if (c < 0xf0) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)cp922_2uni_3[c - 0xf0]; + return 1; } static const unsigned char cp922_page00[88] = { @@ -76,23 +81,26 @@ static const unsigned char cp922_page01[32] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xfe, 0x00, /* 0x78-0x7f */ }; -static int -cp922_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp922_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a8) { - *r = wc; - return 1; - } - else if (wc >= 0x00a8 && wc < 0x0100) - c = cp922_page00[wc-0x00a8]; - else if (wc >= 0x0160 && wc < 0x0180) - c = cp922_page01[wc-0x0160]; - else if (wc == 0x203e) - c = 0xaf; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a8) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a8 && wc < 0x0100) + c = cp922_page00[wc - 0x00a8]; + else if (wc >= 0x0160 && wc < 0x0180) + c = cp922_page01[wc - 0x0160]; + else if (wc == 0x203e) + c = 0xaf; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _CP922_H_ */ diff --git a/lib/converters/cp932.h b/lib/converters/cp932.h new file mode 100644 index 00000000..da8168ae --- /dev/null +++ b/lib/converters/cp932.h @@ -0,0 +1,274 @@ +/** + * @file cp932.h + * @brief CP932 + * @copyright Copyright (C) 1999-2002, 2005, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * Microsoft CP932 is a slightly extended version of SHIFT_JIS. + * The differences between the EASTASIA/JIS/SHIFTJIS.TXT and the + * VENDORS/MICSFT/WINDOWS/CP932.TXT tables found on ftp.unicode.org are + * as follows: + * + * 1. CP932 uses ASCII, not JISX0201 Roman. + * + * 2. Some characters in the JISX0208 range are defined differently: + * + * code SHIFTJIS.TXT CP932.TXT + * 0x815F 0x005C # REVERSE SOLIDUS 0xFF3C # FULLWIDTH REVERSE SOLIDUS + * 0x8160 0x301C # WAVE DASH 0xFF5E # FULLWIDTH TILDE + * 0x8161 0x2016 # DOUBLE VERTICAL LINE 0x2225 # PARALLEL TO + * 0x817C 0x2212 # MINUS SIGN 0xFF0D # FULLWIDTH HYPHEN-MINUS + * 0x8191 0x00A2 # CENT SIGN 0xFFE0 # FULLWIDTH CENT SIGN + * 0x8192 0x00A3 # POUND SIGN 0xFFE1 # FULLWIDTH POUND SIGN + * 0x81CA 0x00AC # NOT SIGN 0xFFE2 # FULLWIDTH NOT SIGN + * + * We don't implement the latter 6 of these changes, only the first one. + * SHIFTJIS.TXT makes more sense. However, as a compromise with user + * expectation, we implement the middle 5 of these changes in the + * Unicode to CP932 direction. We don't implement the last one at all, + * because it would collide with the mapping of 0xFA54. + * + * 3. A few new rows. See cp932ext.h. + * + * Many variants of CP932 (in GNU libc, JDK, OSF/1, Windows-2000, ICU) also + * add: + * + * 4. Private area mappings: + * + * code Unicode + * 0x{F0..F9}{40..7E,80..FC} U+E000..U+E757 + * + * We add them too because, although there are backward compatibility problems + * when a character from a private area is moved to an official Unicode code + * point, they are useful for some people in practice. + */ + +#ifndef _CP932_H_ +#define _CP932_H_ + +#include "converters/ascii.h" +#include "converters/jisx0201.h" +#include "converters/jisx0208.h" +#include "reiconv_defines.h" + +#include "cp932ext.h" +#include + +/* + Conversion between SJIS codes (s1,s2) and JISX0208 codes (c1,c2): + Example. (s1,s2) = 0x8140, (c1,c2) = 0x2121. + 0x81 <= s1 <= 0x9F || 0xE0 <= s1 <= 0xEA, + 0x40 <= s2 <= 0x7E || 0x80 <= s2 <= 0xFC, + 0x21 <= c1 <= 0x74, 0x21 <= c2 <= 0x7E. + Invariant: + 94*2*(s1 < 0xE0 ? s1-0x81 : s1-0xC1) + (s2 < 0x80 ? s2-0x40 : s2-0x41) + = 94*(c1-0x21)+(c2-0x21) + Conversion (s1,s2) -> (c1,c2): + t1 := (s1 < 0xE0 ? s1-0x81 : s1-0xC1) + t2 := (s2 < 0x80 ? s2-0x40 : s2-0x41) + c1 := 2*t1 + (t2 < 0x5E ? 0 : 1) + 0x21 + c2 := (t2 < 0x5E ? t2 : t2-0x5E) + 0x21 + Conversion (c1,c2) -> (s1,s2): + t1 := (c1 - 0x21) >> 1 + t2 := ((c1 - 0x21) & 1) * 0x5E + (c2 - 0x21) + s1 := (t1 < 0x1F ? t1+0x81 : t1+0xC1) + s2 := (t2 < 0x3F ? t2+0x40 : t2+0x41) + */ + +static int cp932_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + else if (c >= 0xa1 && c <= 0xdf) + return jisx0201_mbtowc(conv, pwc, s, n); + else + { + unsigned char s1, s2; + s1 = c; + if ((s1 >= 0x81 && s1 <= 0x9f && s1 != 0x87) || (s1 >= 0xe0 && s1 <= 0xea)) + { + if (n < 2) + return RET_TOOFEW(0); + s2 = s[1]; + if ((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0x80 && s2 <= 0xfc)) + { + unsigned char t1 = (s1 < 0xe0 ? s1 - 0x81 : s1 - 0xc1); + unsigned char t2 = (s2 < 0x80 ? s2 - 0x40 : s2 - 0x41); + unsigned char buf[2]; + buf[0] = 2 * t1 + (t2 < 0x5e ? 0 : 1) + 0x21; + buf[1] = (t2 < 0x5e ? t2 : t2 - 0x5e) + 0x21; + return jisx0208_mbtowc(conv, pwc, buf, 2); + } + } + else if ((s1 == 0x87) || (s1 >= 0xed && s1 <= 0xee) || (s1 >= 0xfa)) + { + if (n < 2) + return RET_TOOFEW(0); + return cp932ext_mbtowc(conv, pwc, s, 2); + } + else if (s1 >= 0xf0 && s1 <= 0xf9) + { + /* User-defined range. See + * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ + if (n < 2) + return RET_TOOFEW(0); + s2 = s[1]; + if ((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0x80 && s2 <= 0xfc)) + { + *pwc = 0xe000 + 188 * (s1 - 0xf0) + (s2 < 0x80 ? s2 - 0x40 : s2 - 0x41); + return 2; + } + } + return RET_ILSEQ; + } +} + +static int cp932_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[2]; + int ret; + + /* Try ASCII. */ + ret = ascii_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + unsigned char c; + if (ret != 1) + abort(); + c = buf[0]; + if (c < 0x80) + { + r[0] = c; + return 1; + } + } + + /* Try JIS X 0201-1976 Katakana. */ + ret = jisx0201_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + unsigned char c; + if (ret != 1) + abort(); + c = buf[0]; + if (c >= 0xa1 && c <= 0xdf) + { + r[0] = c; + return 1; + } + } + + /* Try JIS X 0208-1990. */ + ret = jisx0208_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + unsigned char c1, c2; + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + c1 = buf[0]; + c2 = buf[1]; + if ((c1 >= 0x21 && c1 <= 0x74) && (c2 >= 0x21 && c2 <= 0x7e)) + { + unsigned char t1 = (c1 - 0x21) >> 1; + unsigned char t2 = (((c1 - 0x21) & 1) ? 0x5e : 0) + (c2 - 0x21); + r[0] = (t1 < 0x1f ? t1 + 0x81 : t1 + 0xc1); + r[1] = (t2 < 0x3f ? t2 + 0x40 : t2 + 0x41); + return 2; + } + } + + /* Try CP932 extensions. */ + ret = cp932ext_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0]; + r[1] = buf[1]; + return 2; + } + + /* User-defined range. See + * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ + if (wc >= 0xe000 && wc < 0xe758) + { + unsigned char c1, c2; + if (n < 2) + return RET_TOOSMALL; + c1 = (unsigned int)(wc - 0xe000) / 188; + c2 = (unsigned int)(wc - 0xe000) % 188; + r[0] = c1 + 0xf0; + r[1] = (c2 < 0x3f ? c2 + 0x40 : c2 + 0x41); + return 2; + } + + /* Irreversible mappings. */ + if (wc == 0xff5e) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x81; + r[1] = 0x60; + return 2; + } + if (wc == 0x2225) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x81; + r[1] = 0x61; + return 2; + } + if (wc == 0xff0d) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x81; + r[1] = 0x7c; + return 2; + } + if (wc == 0xffe0) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x81; + r[1] = 0x91; + return 2; + } + if (wc == 0xffe1) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x81; + r[1] = 0x92; + return 2; + } + + return RET_ILUNI; +} + +#endif /* _CP932_H_ */ diff --git a/lib/cp932ext.h b/lib/converters/cp932ext.h similarity index 89% rename from lib/cp932ext.h rename to lib/converters/cp932ext.h index d06a1ca5..4b0cef34 100644 --- a/lib/cp932ext.h +++ b/lib/converters/cp932ext.h @@ -1,5 +1,10 @@ +/** + * @file cp932ext.h + * @brief CP932 extensions + * @copyright Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP932 extensions - */ +#ifndef _CP932EXT_H_ +#define _CP932EXT_H_ + +#include "reiconv_defines.h" static const unsigned short cp932ext_2uni_page87[92] = { /* 0x87 */ @@ -144,36 +150,44 @@ static const unsigned short cp932ext_2uni_pagefa[388] = { 0x9d6b, 0xfa2d, 0x9e19, 0x9ed1, }; -static int -cp932ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp932ext_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 == 0x87) || (c1 >= 0xed && c1 <= 0xee) || (c1 >= 0xfa && c1 <= 0xfc)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xfd)) { - unsigned int i = 188 * (c1 - (c1 >= 0xe0 ? 0xc1 : 0x81)) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); - unsigned short wc = 0xfffd; - if (i < 8272) { - if (i < 1220) - wc = cp932ext_2uni_page87[i-1128]; - } else if (i < 10716) { - if (i < 8648) - wc = cp932ext_2uni_pageed[i-8272]; - } else { - if (i < 11104) - wc = cp932ext_2uni_pagefa[i-10716]; + unsigned char c1 = s[0]; + if ((c1 == 0x87) || (c1 >= 0xed && c1 <= 0xee) || (c1 >= 0xfa && c1 <= 0xfc)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xfd)) + { + unsigned int i = 188 * (c1 - (c1 >= 0xe0 ? 0xc1 : 0x81)) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); + unsigned short wc = 0xfffd; + if (i < 8272) + { + if (i < 1220) + wc = cp932ext_2uni_page87[i - 1128]; + } + else if (i < 10716) + { + if (i < 8648) + wc = cp932ext_2uni_pageed[i - 8272]; + } + else + { + if (i < 11104) + wc = cp932ext_2uni_pagefa[i - 10716]; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; - } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned short cp932ext_2charset[457] = { @@ -652,57 +666,62 @@ static const Summary16 cp932ext_uni2indx_pageff[15] = { { 455, 0x0000 }, { 455, 0x0000 }, { 455, 0x0014 }, }; -static int -cp932ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp932ext_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc >= 0x2100 && wc < 0x22c0) - summary = &cp932ext_uni2indx_page21[(wc>>4)-0x210]; - else if (wc >= 0x2400 && wc < 0x2480) - summary = &cp932ext_uni2indx_page24[(wc>>4)-0x240]; - else if (wc >= 0x3000 && wc < 0x3020) - summary = &cp932ext_uni2indx_page30[(wc>>4)-0x300]; - else if (wc >= 0x3200 && wc < 0x33d0) - summary = &cp932ext_uni2indx_page32[(wc>>4)-0x320]; - else if (wc >= 0x4e00 && wc < 0x5590) - summary = &cp932ext_uni2indx_page4e[(wc>>4)-0x4e0]; - else if (wc >= 0x5700 && wc < 0x59c0) - summary = &cp932ext_uni2indx_page57[(wc>>4)-0x570]; - else if (wc >= 0x5b00 && wc < 0x5de0) - summary = &cp932ext_uni2indx_page5b[(wc>>4)-0x5b0]; - else if (wc >= 0x5f00 && wc < 0x7ba0) - summary = &cp932ext_uni2indx_page5f[(wc>>4)-0x5f0]; - else if (wc >= 0x7d00 && wc < 0x7fb0) - summary = &cp932ext_uni2indx_page7d[(wc>>4)-0x7d0]; - else if (wc >= 0x8300 && wc < 0x85c0) - summary = &cp932ext_uni2indx_page83[(wc>>4)-0x830]; - else if (wc >= 0x8800 && wc < 0x8ed0) - summary = &cp932ext_uni2indx_page88[(wc>>4)-0x880]; - else if (wc >= 0x9000 && wc < 0x9ee0) - summary = &cp932ext_uni2indx_page90[(wc>>4)-0x900]; - else if (wc >= 0xf900 && wc < 0xfa30) - summary = &cp932ext_uni2indx_pagef9[(wc>>4)-0xf90]; - else if (wc >= 0xff00 && wc < 0xfff0) - summary = &cp932ext_uni2indx_pageff[(wc>>4)-0xff0]; - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = cp932ext_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc >= 0x2100 && wc < 0x22c0) + summary = &cp932ext_uni2indx_page21[(wc >> 4) - 0x210]; + else if (wc >= 0x2400 && wc < 0x2480) + summary = &cp932ext_uni2indx_page24[(wc >> 4) - 0x240]; + else if (wc >= 0x3000 && wc < 0x3020) + summary = &cp932ext_uni2indx_page30[(wc >> 4) - 0x300]; + else if (wc >= 0x3200 && wc < 0x33d0) + summary = &cp932ext_uni2indx_page32[(wc >> 4) - 0x320]; + else if (wc >= 0x4e00 && wc < 0x5590) + summary = &cp932ext_uni2indx_page4e[(wc >> 4) - 0x4e0]; + else if (wc >= 0x5700 && wc < 0x59c0) + summary = &cp932ext_uni2indx_page57[(wc >> 4) - 0x570]; + else if (wc >= 0x5b00 && wc < 0x5de0) + summary = &cp932ext_uni2indx_page5b[(wc >> 4) - 0x5b0]; + else if (wc >= 0x5f00 && wc < 0x7ba0) + summary = &cp932ext_uni2indx_page5f[(wc >> 4) - 0x5f0]; + else if (wc >= 0x7d00 && wc < 0x7fb0) + summary = &cp932ext_uni2indx_page7d[(wc >> 4) - 0x7d0]; + else if (wc >= 0x8300 && wc < 0x85c0) + summary = &cp932ext_uni2indx_page83[(wc >> 4) - 0x830]; + else if (wc >= 0x8800 && wc < 0x8ed0) + summary = &cp932ext_uni2indx_page88[(wc >> 4) - 0x880]; + else if (wc >= 0x9000 && wc < 0x9ee0) + summary = &cp932ext_uni2indx_page90[(wc >> 4) - 0x900]; + else if (wc >= 0xf900 && wc < 0xfa30) + summary = &cp932ext_uni2indx_pagef9[(wc >> 4) - 0xf90]; + else if (wc >= 0xff00 && wc < 0xfff0) + summary = &cp932ext_uni2indx_pageff[(wc >> 4) - 0xff0]; + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = cp932ext_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _CP932EXT_H_ */ diff --git a/lib/converters/cp936.h b/lib/converters/cp936.h new file mode 100644 index 00000000..b7dc9fa8 --- /dev/null +++ b/lib/converters/cp936.h @@ -0,0 +1,144 @@ +/** + * @file cp936.h + * @brief CP936 + * @copyright Copyright (C) 2005, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * The IANA has CP936 as an alias of GBK. But GBK is an official Chinese + * specification, whereas CP936 is de-facto maintained by Microsoft. And, + * of course, Microsoft modified CP936 since 1999. + * + * The differences from GBK are: + * + * 1. A single character: + * + * code CP936.TXT + * 0x80 0x20AC # EURO SIGN + * + * Some variants of CP936 (in JDK, Windows-2000, ICU) also add: + * + * 2. Private area mappings: + * + * code Unicode + * 0x{A1..A2}{40..7E,80..A0} U+E4C6..U+E585 + * 0x{AA..AF,F8..FE}{A1..FE} U+E000..U+E4C5 + * + * We add them too because, although there are backward compatibility problems + * when a character from a private area is moved to an official Unicode code + * point, they are useful for some people in practice. + */ + +#ifndef _CP936_H_ +#define _CP936_H_ + +#include "converters/ces_gbk.h" +#include "reiconv_defines.h" + +static int cp936_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + /* Try GBK first. */ + { + int ret = ces_gbk_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + } + /* Then handle the additional mappings. */ + { + unsigned char c = *s; + if (c == 0x80) + { + *pwc = 0x20ac; + return 1; + } + /* User-defined characters */ + if (c >= 0xa1 && c <= 0xa2) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xa1)) + { + *pwc = 0xe4c6 + 96 * (c - 0xa1) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); + return 2; + } + } + } + else if ((c >= 0xaa && c < 0xb0) || (c >= 0xf8 && c < 0xff)) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 < 0xff) + { + *pwc = 0xe000 + 94 * (c - (c >= 0xf8 ? 0xf2 : 0xaa)) + (c2 - 0xa1); + return 2; + } + } + } + } + return RET_ILSEQ; +} + +static int cp936_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + /* Try GBK first. */ + { + int ret = ces_gbk_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + } + /* Then handle the additional mappings. */ + if (wc >= 0xe000 && wc < 0xe586) + { + /* User-defined characters */ + if (n < 2) + return RET_TOOFEW(0); + if (wc < 0xe4c6) + { + unsigned int i = wc - 0xe000; + unsigned int c1 = i / 94; + unsigned int c2 = i % 94; + r[0] = c1 + (c1 < 6 ? 0xaa : 0xf2); + r[1] = c2 + 0xa1; + return 2; + } + else + { + unsigned int i = wc - 0xe4c6; + unsigned int c1 = i / 96; + unsigned int c2 = i % 96; + r[0] = c1 + 0xa1; + r[1] = c2 + (c2 < 0x3f ? 0x40 : 0x41); + return 2; + } + } + else if (wc == 0x20ac) + { + r[0] = 0x80; + return 1; + } + return RET_ILUNI; +} + +#endif /* _CP936_H_ */ diff --git a/lib/cp936ext.h b/lib/converters/cp936ext.h similarity index 51% rename from lib/cp936ext.h rename to lib/converters/cp936ext.h index 7837c80f..629240f3 100644 --- a/lib/cp936ext.h +++ b/lib/converters/cp936ext.h @@ -1,5 +1,10 @@ +/** + * @file cp936ext.h + * @brief CP936 extensions + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP936 extensions - */ +#ifndef _CP936EXT_H_ +#define _CP936EXT_H_ + +#include "reiconv_defines.h" static const unsigned short cp936ext_2uni_pagea6[181-159] = { /* 0xa6 */ @@ -33,33 +39,39 @@ static const unsigned short cp936ext_2uni_pagea8[128-122] = { 0x0251, 0xfffd, 0x0144, 0x0148, 0xfffd, 0x0261, }; -static int -cp936ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp936ext_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 == 0xa6) || (c1 == 0xa8)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xff)) { - unsigned int i = 190 * (c1 - 0x81) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); - unsigned short wc = 0xfffd; - if (i < 7410) { - if (i >= 7189 && i < 7211) - wc = cp936ext_2uni_pagea6[i-7189]; - } else { - if (i >= 7532 && i < 7538) - wc = cp936ext_2uni_pagea8[i-7532]; + unsigned char c1 = s[0]; + if ((c1 == 0xa6) || (c1 == 0xa8)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xff)) + { + unsigned int i = 190 * (c1 - 0x81) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); + unsigned short wc = 0xfffd; + if (i < 7410) + { + if (i >= 7189 && i < 7211) + wc = cp936ext_2uni_pagea6[i - 7189]; + } + else + { + if (i >= 7532 && i < 7538) + wc = cp936ext_2uni_pagea8[i - 7532]; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; - } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned short cp936ext_page01[16] = { @@ -77,22 +89,26 @@ static const unsigned short cp936ext_pagefe[24] = { 0xa6e5, 0xa6e8, 0xa6e9, 0xa6ea, 0xa6eb, 0x0000, 0x0000, 0x0000, /*0x40-0x47*/ }; -static int -cp936ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp936ext_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - unsigned short c = 0; - if (wc >= 0x0140 && wc < 0x0150) - c = cp936ext_page01[wc-0x0140]; - else if (wc >= 0x0250 && wc < 0x0268) - c = cp936ext_page02[wc-0x0250]; - else if (wc >= 0xfe30 && wc < 0xfe48) - c = cp936ext_pagefe[wc-0xfe30]; - if (c != 0) { - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; + if (n >= 2) + { + unsigned short c = 0; + if (wc >= 0x0140 && wc < 0x0150) + c = cp936ext_page01[wc - 0x0140]; + else if (wc >= 0x0250 && wc < 0x0268) + c = cp936ext_page02[wc - 0x0250]; + else if (wc >= 0xfe30 && wc < 0xfe48) + c = cp936ext_pagefe[wc - 0xfe30]; + if (c != 0) + { + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _CP936EXT_H_ */ diff --git a/lib/cp943.h b/lib/converters/cp943.h similarity index 72% rename from lib/cp943.h rename to lib/converters/cp943.h index f9e33018..55fc6d84 100644 --- a/lib/cp943.h +++ b/lib/converters/cp943.h @@ -1,5 +1,10 @@ +/** + * @file cp943.h + * @brief IBM CP943 + * @copyright Copyright (C) 1999-2001 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,16 +18,19 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM CP943 - */ +#ifndef _CP943_H_ +#define _CP943_H_ + +#include "reiconv_defines.h" // IWYU pragma: keep /* This is essentially CP932, with many mappings missing in the AIX conversion table. We just pretend it were the same as CP932. */ #define cp943_mbtowc cp932_mbtowc #define cp943_wctomb cp932_wctomb + +#endif /* _CP943_H_ */ diff --git a/lib/converters/cp949.h b/lib/converters/cp949.h new file mode 100644 index 00000000..9eec2f7c --- /dev/null +++ b/lib/converters/cp949.h @@ -0,0 +1,152 @@ +/** + * @file cp949.h + * @brief CP949 is EUC-KR, extended with UHC (Unified Hangul Code). + * @copyright Copyright (C) 1999-2001, 2005, 2007, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * + * Some variants of CP949 (in JDK, Windows-2000, ICU) also add: + * + * 2. Private area mappings: + * + * code Unicode + * 0xC9{A1..FE} U+E000..U+E05D + * 0xFE{A1..FE} U+E05E..U+E0BB + * + * We add them too because, although there are backward compatibility problems + * when a character from a private area is moved to an official Unicode code + * point, they are useful for some people in practice. + */ + +#ifndef _CP949_H_ +#define _CP949_H_ + +#include "converters/ascii.h" +#include "converters/ksc5601.h" +#include "converters/uhc_1.h" +#include "converters/uhc_2.h" +#include "reiconv_defines.h" + +#include + +static int cp949_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + /* Code set 0 (ASCII) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* UHC part 1 */ + if (c >= 0x81 && c <= 0xa0) + return uhc_1_mbtowc(conv, pwc, s, n); + if (c >= 0xa1 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c2 < 0xa1) + /* UHC part 2 */ + return uhc_2_mbtowc(conv, pwc, s, n); + else if (c2 < 0xff && !(c == 0xa2 && c2 == 0xe8)) + { + /* Code set 1 (KS C 5601-1992, now KS X 1001:1998) */ + unsigned char buf[2]; + int ret; + buf[0] = c - 0x80; + buf[1] = c2 - 0x80; + ret = ksc5601_mbtowc(conv, pwc, buf, 2); + if (ret != RET_ILSEQ) + return ret; + /* User-defined characters */ + if (c == 0xc9) + { + *pwc = 0xe000 + (c2 - 0xa1); + return 2; + } + if (c == 0xfe) + { + *pwc = 0xe05e + (c2 - 0xa1); + return 2; + } + } + } + } + return RET_ILSEQ; +} + +static int cp949_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[2]; + int ret; + + /* Code set 0 (ASCII) */ + ret = ascii_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + /* Code set 1 (KS C 5601-1992, now KS X 1001:1998) */ + if (wc != 0x327e) + { + ret = ksc5601_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0] + 0x80; + r[1] = buf[1] + 0x80; + return 2; + } + } + + /* UHC */ + if (wc >= 0xac00 && wc < 0xd7a4) + { + if (wc < 0xc8a5) + return uhc_1_wctomb(conv, r, wc, n); + else + return uhc_2_wctomb(conv, r, wc, n); + } + + /* User-defined characters */ + if (wc >= 0xe000 && wc < 0xe0bc) + { + if (n < 2) + return RET_TOOSMALL; + if (wc < 0xe05e) + { + r[0] = 0xc9; + r[1] = wc - 0xe000 + 0xa1; + } + else + { + r[0] = 0xfe; + r[1] = wc - 0xe05e + 0xa1; + } + return 2; + } + + return RET_ILUNI; +} + +#endif /* _CP949_H_ */ diff --git a/lib/converters/cp950.h b/lib/converters/cp950.h new file mode 100644 index 00000000..06eac404 --- /dev/null +++ b/lib/converters/cp950.h @@ -0,0 +1,428 @@ +/** + * @file cp950.h + * @brief CP950 + * @copyright Copyright (C) 1999-2001, 2005, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * Microsoft CP950 is a slightly extended and slightly modified version of + * BIG5. The differences between the EASTASIA/OTHER/BIG5.TXT and + * VENDORS/MICSFT/WINDOWS/CP950.TXT tables found on ftp.unicode.org are + * as follows: + * + * 1. Some characters in the BIG5 range are defined differently: + * + * code BIG5.TXT CP950.TXT + * 0xA145 0x2022 # BULLET 0x2027 # HYPHENATION POINT + * 0xA14E 0xFF64 # HALFWIDTH IDEOGRAPHIC COMMA + * 0xFE51 # SMALL IDEOGRAPHIC COMMA + * 0xA15A --- 0x2574 # BOX DRAWINGS LIGHT LEFT + * 0xA1C2 0x203E # OVERLINE 0x00AF # MACRON + * 0xA1C3 --- 0xFFE3 # FULLWIDTH MACRON + * 0xA1C5 --- 0x02CD # MODIFIER LETTER LOW MACRON + * 0xA1E3 0x223C # TILDE OPERATOR 0xFF5E # FULLWIDTH TILDE + * 0xA1F2 0x2641 # EARTH 0x2295 # CIRCLED PLUS + * 0xA1F3 0x2609 # SUN 0x2299 # CIRCLED DOT OPERATOR + * 0xA1FE --- 0xFF0F # FULLWIDTH SOLIDUS + * 0xA240 --- 0xFF3C # FULLWIDTH REVERSE SOLIDUS + * 0xA241 0xFF0F # FULLWIDTH SOLIDUS 0x2215 # DIVISION SLASH + * 0xA242 0xFF3C # FULLWIDTH REVERSE SOLIDUS + * 0xFE68 # SMALL REVERSE SOLIDUS + * 0xA244 0x00A5 # YEN SIGN 0xFFE5 # FULLWIDTH YEN SIGN + * 0xA246 0x00A2 # CENT SIGN 0xFFE0 # FULLWIDTH CENT SIGN + * 0xA247 0x00A3 # POUND SIGN 0xFFE1 # FULLWIDTH POUND SIGN + * 0xA2CC --- 0x5341 + * 0xA2CE --- 0x5345 + * + * 2. A small new row. See cp950ext.h. + * + * 3. CP950.TXT is lacking the range 0xC6A1..0xC7FC (Hiragana, Katakana, + * Cyrillic, circled digits, parenthesized digits). + * + * We implement this omission, because said range is marked "uncertain" + * in the unicode.org BIG5 table. + * + * The table found on Microsoft's website furthermore adds: + * + * 4. A single character: + * + * code CP950.TXT + * 0xA3E1 0x20AC # EURO SIGN + * + * Many variants of BIG5 or CP950 (in JDK, Solaris, OSF/1, Windows-2000, ICU, + * as well as our BIG5-2003 converter) also add: + * + * 5. Private area mappings: + * + * code Unicode + * 0x{81..8D}{40..7E,A1..FE} U+EEB8..U+F6B0 + * 0x{8E..A0}{40..7E,A1..FE} U+E311..U+EEB7 + * 0x{FA..FE}{40..7E,A1..FE} U+E000..U+E310 + * + * We add them too because, although there are backward compatibility problems + * when a character from a private area is moved to an official Unicode code + * point, they are useful for some people in practice. + */ + +#ifndef _CP950_H_ +#define _CP950_H_ + +#include "converters/ascii.h" +#include "converters/big5.h" +#include "converters/cp950ext.h" +#include "reiconv_defines.h" +#include + +static const unsigned short cp950_2uni_pagea1[314] = { + /* 0xa1 */ + 0x3000, 0xff0c, 0x3001, 0x3002, 0xff0e, 0x2027, 0xff1b, 0xff1a, + 0xff1f, 0xff01, 0xfe30, 0x2026, 0x2025, 0xfe50, 0xfe51, 0xfe52, + 0x00b7, 0xfe54, 0xfe55, 0xfe56, 0xfe57, 0xff5c, 0x2013, 0xfe31, + 0x2014, 0xfe33, 0x2574, 0xfe34, 0xfe4f, 0xff08, 0xff09, 0xfe35, + 0xfe36, 0xff5b, 0xff5d, 0xfe37, 0xfe38, 0x3014, 0x3015, 0xfe39, + 0xfe3a, 0x3010, 0x3011, 0xfe3b, 0xfe3c, 0x300a, 0x300b, 0xfe3d, + 0xfe3e, 0x3008, 0x3009, 0xfe3f, 0xfe40, 0x300c, 0x300d, 0xfe41, + 0xfe42, 0x300e, 0x300f, 0xfe43, 0xfe44, 0xfe59, 0xfe5a, 0xfe5b, + 0xfe5c, 0xfe5d, 0xfe5e, 0x2018, 0x2019, 0x201c, 0x201d, 0x301d, + 0x301e, 0x2035, 0x2032, 0xff03, 0xff06, 0xff0a, 0x203b, 0x00a7, + 0x3003, 0x25cb, 0x25cf, 0x25b3, 0x25b2, 0x25ce, 0x2606, 0x2605, + 0x25c7, 0x25c6, 0x25a1, 0x25a0, 0x25bd, 0x25bc, 0x32a3, 0x2105, + 0x00af, 0xffe3, 0xff3f, 0x02cd, 0xfe49, 0xfe4a, 0xfe4d, 0xfe4e, + 0xfe4b, 0xfe4c, 0xfe5f, 0xfe60, 0xfe61, 0xff0b, 0xff0d, 0x00d7, + 0x00f7, 0x00b1, 0x221a, 0xff1c, 0xff1e, 0xff1d, 0x2266, 0x2267, + 0x2260, 0x221e, 0x2252, 0x2261, 0xfe62, 0xfe63, 0xfe64, 0xfe65, + 0xfe66, 0xff5e, 0x2229, 0x222a, 0x22a5, 0x2220, 0x221f, 0x22bf, + 0x33d2, 0x33d1, 0x222b, 0x222e, 0x2235, 0x2234, 0x2640, 0x2642, + 0x2295, 0x2299, 0x2191, 0x2193, 0x2190, 0x2192, 0x2196, 0x2197, + 0x2199, 0x2198, 0x2225, 0x2223, 0xff0f, + /* 0xa2 */ + 0xff3c, 0x2215, 0xfe68, 0xff04, 0xffe5, 0x3012, 0xffe0, 0xffe1, + 0xff05, 0xff20, 0x2103, 0x2109, 0xfe69, 0xfe6a, 0xfe6b, 0x33d5, + 0x339c, 0x339d, 0x339e, 0x33ce, 0x33a1, 0x338e, 0x338f, 0x33c4, + 0x00b0, 0x5159, 0x515b, 0x515e, 0x515d, 0x5161, 0x5163, 0x55e7, + 0x74e9, 0x7cce, 0x2581, 0x2582, 0x2583, 0x2584, 0x2585, 0x2586, + 0x2587, 0x2588, 0x258f, 0x258e, 0x258d, 0x258c, 0x258b, 0x258a, + 0x2589, 0x253c, 0x2534, 0x252c, 0x2524, 0x251c, 0x2594, 0x2500, + 0x2502, 0x2595, 0x250c, 0x2510, 0x2514, 0x2518, 0x256d, 0x256e, + 0x2570, 0x256f, 0x2550, 0x255e, 0x256a, 0x2561, 0x25e2, 0x25e3, + 0x25e5, 0x25e4, 0x2571, 0x2572, 0x2573, 0xff10, 0xff11, 0xff12, + 0xff13, 0xff14, 0xff15, 0xff16, 0xff17, 0xff18, 0xff19, 0x2160, + 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, + 0x2169, 0x3021, 0x3022, 0x3023, 0x3024, 0x3025, 0x3026, 0x3027, + 0x3028, 0x3029, 0x5341, 0x5344, 0x5345, 0xff21, 0xff22, 0xff23, + 0xff24, 0xff25, 0xff26, 0xff27, 0xff28, 0xff29, 0xff2a, 0xff2b, + 0xff2c, 0xff2d, 0xff2e, 0xff2f, 0xff30, 0xff31, 0xff32, 0xff33, + 0xff34, 0xff35, 0xff36, 0xff37, 0xff38, 0xff39, 0xff3a, 0xff41, + 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48, 0xff49, + 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50, 0xff51, + 0xff52, 0xff53, 0xff54, 0xff55, 0xff56, +}; + +static int cp950_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + /* Code set 0 (ASCII) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (BIG5 extended) */ + if (c >= 0x81 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) + { + if (c >= 0xa1) + { + if (c < 0xa3) + { + unsigned int i = 157 * (c - 0xa1) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); + unsigned short wc = cp950_2uni_pagea1[i]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + if (!((c == 0xc6 && c2 >= 0xa1) || c == 0xc7)) + { + int ret = big5_mbtowc(conv, pwc, s, 2); + if (ret != RET_ILSEQ) + return ret; + } + if (c == 0xa3 && c2 == 0xe1) + { + *pwc = 0x20ac; + return 2; + } + if (c >= 0xfa) + { + /* User-defined characters */ + *pwc = 0xe000 + 157 * (c - 0xfa) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); + return 2; + } + } + else + { + /* 0x81 <= c < 0xa1. */ + /* User-defined characters */ + *pwc = (c >= 0x8e ? 0xdb18 : 0xeeb8) + 157 * (c - 0x81) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); + return 2; + } + } + } + if (c == 0xf9) + { + int ret = cp950ext_mbtowc(conv, pwc, s, 2); + if (ret != RET_ILSEQ) + return ret; + } + } + return RET_ILSEQ; +} + +static int cp950_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[2]; + int ret; + + /* Code set 0 (ASCII) */ + ret = ascii_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + /* Code set 1 (BIG5 extended) */ + switch (wc >> 8) + { + case 0x00: + if (wc == 0x00af) + { + buf[0] = 0xa1; + buf[1] = 0xc2; + ret = 2; + break; + } + if (wc == 0x00a2 || wc == 0x00a3 || wc == 0x00a4) + return RET_ILUNI; + break; + case 0x02: + if (wc == 0x02cd) + { + buf[0] = 0xa1; + buf[1] = 0xc5; + ret = 2; + break; + } + break; + case 0x20: + if (wc == 0x2027) + { + buf[0] = 0xa1; + buf[1] = 0x45; + ret = 2; + break; + } + if (wc == 0x20ac) + { + buf[0] = 0xa3; + buf[1] = 0xe1; + ret = 2; + break; + } + if (wc == 0x2022 || wc == 0x203e) + return RET_ILUNI; + break; + case 0x22: + if (wc == 0x2215) + { + buf[0] = 0xa2; + buf[1] = 0x41; + ret = 2; + break; + } + if (wc == 0x2295) + { + buf[0] = 0xa1; + buf[1] = 0xf2; + ret = 2; + break; + } + if (wc == 0x2299) + { + buf[0] = 0xa1; + buf[1] = 0xf3; + ret = 2; + break; + } + if (wc == 0x223c) + return RET_ILUNI; + break; + case 0x25: + if (wc == 0x2574) + { + buf[0] = 0xa1; + buf[1] = 0x5a; + ret = 2; + break; + } + break; + case 0x26: + if (wc == 0x2609 || wc == 0x2641) + return RET_ILUNI; + break; + case 0xe0: + case 0xe1: + case 0xe2: + case 0xe3: + case 0xe4: + case 0xe5: + case 0xe6: + case 0xe7: + case 0xe8: + case 0xe9: + case 0xea: + case 0xeb: + case 0xec: + case 0xed: + case 0xee: + case 0xef: + case 0xf0: + case 0xf1: + case 0xf2: + case 0xf3: + case 0xf4: + case 0xf5: + case 0xf6: { + /* User-defined characters */ + unsigned int i = wc - 0xe000; + if (i < 5809) + { + unsigned int c1 = i / 157; + unsigned int c2 = i % 157; + buf[0] = c1 + (c1 < 5 ? 0xfa : c1 < 24 ? 0x89 : 0x69); + buf[1] = c2 + (c2 < 0x3f ? 0x40 : 0x62); + ret = 2; + break; + } + } + break; + case 0xfe: + if (wc == 0xfe51) + { + buf[0] = 0xa1; + buf[1] = 0x4e; + ret = 2; + break; + } + if (wc == 0xfe68) + { + buf[0] = 0xa2; + buf[1] = 0x42; + ret = 2; + break; + } + break; + case 0xff: + if (wc == 0xff0f) + { + buf[0] = 0xa1; + buf[1] = 0xfe; + ret = 2; + break; + } + if (wc == 0xff3c) + { + buf[0] = 0xa2; + buf[1] = 0x40; + ret = 2; + break; + } + if (wc == 0xff5e) + { + buf[0] = 0xa1; + buf[1] = 0xe3; + ret = 2; + break; + } + if (wc == 0xffe0) + { + buf[0] = 0xa2; + buf[1] = 0x46; + ret = 2; + break; + } + if (wc == 0xffe1) + { + buf[0] = 0xa2; + buf[1] = 0x47; + ret = 2; + break; + } + if (wc == 0xffe3) + { + buf[0] = 0xa1; + buf[1] = 0xc3; + ret = 2; + break; + } + if (wc == 0xffe5) + { + buf[0] = 0xa2; + buf[1] = 0x44; + ret = 2; + break; + } + if (wc == 0xff64) + return RET_ILUNI; + break; + } + if (ret == RET_ILUNI) + ret = big5_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (!((buf[0] == 0xc6 && buf[1] >= 0xa1) || buf[0] == 0xc7)) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0]; + r[1] = buf[1]; + return 2; + } + } + ret = cp950ext_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0]; + r[1] = buf[1]; + return 2; + } + + return RET_ILUNI; +} + +#endif /* _CP950_H_ */ diff --git a/lib/cp950ext.h b/lib/converters/cp950ext.h similarity index 55% rename from lib/cp950ext.h rename to lib/converters/cp950ext.h index 944b2f95..bf1e508b 100644 --- a/lib/cp950ext.h +++ b/lib/converters/cp950ext.h @@ -1,5 +1,10 @@ +/** + * @file cp950ext.h + * @brief CP950 extensions + * @copyright Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * CP950 extensions - */ +#ifndef _CP950EXT_H_ +#define _CP950EXT_H_ + +#include "reiconv_defines.h" static const unsigned short cp950ext_2uni_pagef9[157-116] = { /* 0xf9 */ @@ -31,30 +37,33 @@ static const unsigned short cp950ext_2uni_pagef9[157-116] = { 0x256d, 0x256e, 0x2570, 0x256f, 0x2593, }; -static int -cp950ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int cp950ext_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 == (unsigned char)0xf9)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) { - unsigned int i = 157 * (c1 - 0xa1) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); - unsigned short wc = 0xfffd; + unsigned char c1 = s[0]; + if (c1 == (unsigned char)0xf9) + { + if (n >= 2) { - if (i >= 13932 && i < 13973) - wc = cp950ext_2uni_pagef9[i-13932]; + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) + { + unsigned int i = 157 * (c1 - 0xa1) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); + unsigned short wc = 0xfffd; + { + if (i >= 13932 && i < 13973) + wc = cp950ext_2uni_pagef9[i - 13932]; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; - } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned short cp950ext_2charset[41] = { @@ -116,45 +125,50 @@ static const Summary16 cp950ext_uni2indx_page92[12] = { { 40, 0x0000 }, { 40, 0x0000 }, { 40, 0x0000 }, { 40, 0x0200 }, }; -static int -cp950ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int cp950ext_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc >= 0x2500 && wc < 0x25a0) - summary = &cp950ext_uni2indx_page25[(wc>>4)-0x250]; - else if (wc >= 0x5800 && wc < 0x58c0) - summary = &cp950ext_uni2indx_page58[(wc>>4)-0x580]; - else if (wc >= 0x5a00 && wc < 0x5b00) - summary = &cp950ext_uni2indx_page5a[(wc>>4)-0x5a0]; - else if (wc >= 0x6000 && wc < 0x6060) - summary = &cp950ext_uni2indx_page60[(wc>>4)-0x600]; - else if (wc >= 0x7800 && wc < 0x7890) - summary = &cp950ext_uni2indx_page78[(wc>>4)-0x780]; - else if (wc >= 0x7c00 && wc < 0x7cb0) - summary = &cp950ext_uni2indx_page7c[(wc>>4)-0x7c0]; - else if (wc >= 0x8800 && wc < 0x88d0) - summary = &cp950ext_uni2indx_page88[(wc>>4)-0x880]; - else if (wc >= 0x9200 && wc < 0x92c0) - summary = &cp950ext_uni2indx_page92[(wc>>4)-0x920]; - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = cp950ext_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc >= 0x2500 && wc < 0x25a0) + summary = &cp950ext_uni2indx_page25[(wc >> 4) - 0x250]; + else if (wc >= 0x5800 && wc < 0x58c0) + summary = &cp950ext_uni2indx_page58[(wc >> 4) - 0x580]; + else if (wc >= 0x5a00 && wc < 0x5b00) + summary = &cp950ext_uni2indx_page5a[(wc >> 4) - 0x5a0]; + else if (wc >= 0x6000 && wc < 0x6060) + summary = &cp950ext_uni2indx_page60[(wc >> 4) - 0x600]; + else if (wc >= 0x7800 && wc < 0x7890) + summary = &cp950ext_uni2indx_page78[(wc >> 4) - 0x780]; + else if (wc >= 0x7c00 && wc < 0x7cb0) + summary = &cp950ext_uni2indx_page7c[(wc >> 4) - 0x7c0]; + else if (wc >= 0x8800 && wc < 0x88d0) + summary = &cp950ext_uni2indx_page88[(wc >> 4) - 0x880]; + else if (wc >= 0x9200 && wc < 0x92c0) + summary = &cp950ext_uni2indx_page92[(wc >> 4) - 0x920]; + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = cp950ext_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _CP950EXT_H_ */ diff --git a/lib/converters/dec_hanyu.h b/lib/converters/dec_hanyu.h new file mode 100644 index 00000000..de8c5c80 --- /dev/null +++ b/lib/converters/dec_hanyu.h @@ -0,0 +1,144 @@ +/** + * @file dec_hanyu.h + * @brief DEC-HANYU + * @copyright Copyright (C) 2001, 2005, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _DEC_HANYU_H_ +#define _DEC_HANYU_H_ + +#include "converters/ascii.h" +#include "converters/cns11643.h" +#include "converters/cns11643_1.h" +#include "converters/cns11643_2.h" +#include "converters/cns11643_3.h" +#include "reiconv_defines.h" +#include + +static int dec_hanyu_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + /* Code set 0 (ASCII) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (CNS 11643-1992 Plane 1), + Code set 2 (CNS 11643-1992 Plane 2), + Code set 3 (CNS 11643-1992 Plane 3) */ + if (c >= 0xa1 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c == 0xc2 && c2 == 0xcb) + { + if (n < 4) + return RET_TOOFEW(0); + if (s[2] >= 0xa1 && s[2] < 0xff && s[3] >= 0xa1 && s[3] < 0xff) + { + unsigned char buf[2]; + int ret; + buf[0] = s[2] - 0x80; + buf[1] = s[3] - 0x80; + ret = cns11643_3_mbtowc(conv, pwc, buf, 2); + if (ret != RET_ILSEQ) + { + if (ret != 2) + abort(); + return 4; + } + } + } + else if (c2 >= 0xa1 && c2 < 0xff) + { + if (c != 0xc2 || c2 < 0xc2) + { + unsigned char buf[2]; + buf[0] = c - 0x80; + buf[1] = c2 - 0x80; + return cns11643_1_mbtowc(conv, pwc, buf, 2); + } + } + else if (c2 >= 0x21 && c2 < 0x7f) + { + unsigned char buf[2]; + buf[0] = c - 0x80; + buf[1] = c2; + return cns11643_2_mbtowc(conv, pwc, buf, 2); + } + } + } + return RET_ILSEQ; +} + +static int dec_hanyu_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[3]; + int ret; + + /* Code set 0 (ASCII) */ + ret = ascii_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + ret = cns11643_wctomb(conv, buf, wc, 3); + if (ret != RET_ILUNI) + { + if (ret != 3) + abort(); + + /* Code set 1 (CNS 11643-1992 Plane 1) */ + if (buf[0] == 1 && (buf[1] != 0x42 || buf[2] < 0x42)) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[1] + 0x80; + r[1] = buf[2] + 0x80; + return 2; + } + + /* Code set 2 (CNS 11643-1992 Plane 2) */ + if (buf[0] == 2) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[1] + 0x80; + r[1] = buf[2]; + return 2; + } + + /* Code set 3 (CNS 11643-1992 Plane 3) */ + if (buf[0] == 3) + { + if (n < 4) + return RET_TOOSMALL; + r[0] = 0xc2; + r[1] = 0xcb; + r[2] = buf[1] + 0x80; + r[3] = buf[2] + 0x80; + return 4; + } + } + + return RET_ILUNI; +} + +#endif /* _DEC_HANYU_H_ */ diff --git a/lib/converters/dec_kanji.h b/lib/converters/dec_kanji.h new file mode 100644 index 00000000..0462a382 --- /dev/null +++ b/lib/converters/dec_kanji.h @@ -0,0 +1,85 @@ +/** + * @file dec_kanji.h + * @brief DEC-KANJI + * @copyright Copyright (C) 2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _DEC_KANJI_H_ +#define _DEC_KANJI_H_ + +#include "converters/ascii.h" +#include "converters/jisx0208.h" +#include "reiconv_defines.h" + +#include + +static int dec_kanji_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + /* Code set 0 (ASCII or JIS X 0201-1976 Roman) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (JIS X 0208) */ + if (c >= 0xa1 && c < 0xf5) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 < 0xff) + { + unsigned char buf[2]; + buf[0] = c - 0x80; + buf[1] = c2 - 0x80; + return jisx0208_mbtowc(conv, pwc, buf, 2); + } + } + } + return RET_ILSEQ; +} + +static int dec_kanji_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[2]; + int ret; + + /* Code set 0 (ASCII or JIS X 0201-1976 Roman) */ + ret = ascii_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + /* Code set 1 (JIS X 0208) */ + ret = jisx0208_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0] + 0x80; + r[1] = buf[1] + 0x80; + return 2; + } + + return RET_ILUNI; +} + +#endif /* _DEC_KANJI_H_ */ diff --git a/lib/ebcdic037.h b/lib/converters/ebcdic037.h similarity index 87% rename from lib/ebcdic037.h rename to lib/converters/ebcdic037.h index 8826ab3d..db81d6ad 100644 --- a/lib/ebcdic037.h +++ b/lib/converters/ebcdic037.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic037.h + * @brief IBM-037 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-037 - */ +#ifndef _EBCDIC037_H_ +#define _EBCDIC037_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic037_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic037_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic037_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic037_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic037_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic037_2uni[c]; + return 1; } static const unsigned char ebcdic037_page00[256] = { @@ -117,17 +120,17 @@ static const unsigned char ebcdic037_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic037_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic037_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic037_page00[wc]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic037_page00[wc]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC037_H_ */ diff --git a/lib/ebcdic1025.h b/lib/converters/ebcdic1025.h similarity index 86% rename from lib/ebcdic1025.h rename to lib/converters/ebcdic1025.h index e3d5df33..be4fef70 100644 --- a/lib/ebcdic1025.h +++ b/lib/converters/ebcdic1025.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1025.h + * @brief IBM-1025 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1025 - */ +#ifndef _EBCDIC1025_H_ +#define _EBCDIC1025_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1025_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1025_2uni[256] = { 0x0038, 0x0039, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x009f, }; -static int -ebcdic1025_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1025_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1025_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1025_2uni[c]; + return 1; } static const unsigned char ebcdic1025_page00[176] = { @@ -125,21 +128,21 @@ static const unsigned char ebcdic1025_page04[96] = { }; #endif -static int -ebcdic1025_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1025_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00b0) - c = ebcdic1025_page00[wc]; - else if (wc >= 0x0400 && wc < 0x0460) - c = ebcdic1025_page04[wc-0x0400]; - else if (wc == 0x2116) - c = 0x58; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00b0) + c = ebcdic1025_page00[wc]; + else if (wc >= 0x0400 && wc < 0x0460) + c = ebcdic1025_page04[wc - 0x0400]; + else if (wc == 0x2116) + c = 0x58; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1025_H_ */ diff --git a/lib/ebcdic1026.h b/lib/converters/ebcdic1026.h similarity index 87% rename from lib/ebcdic1026.h rename to lib/converters/ebcdic1026.h index 568a8a74..e1bcb7ed 100644 --- a/lib/ebcdic1026.h +++ b/lib/converters/ebcdic1026.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1026.h + * @brief IBM-1026 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1026 - */ +#ifndef _EBCDIC1026_H_ +#define _EBCDIC1026_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1026_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1026_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x0022, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1026_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1026_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1026_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1026_2uni[c]; + return 1; } static const unsigned char ebcdic1026_page00[256] = { @@ -128,19 +131,19 @@ static const unsigned char ebcdic1026_page01[72] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x6a, /* 0x58-0x5f */ }; -static int -ebcdic1026_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1026_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1026_page00[wc]; - else if (wc >= 0x0118 && wc < 0x0160) - c = ebcdic1026_page01[wc-0x0118]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1026_page00[wc]; + else if (wc >= 0x0118 && wc < 0x0160) + c = ebcdic1026_page01[wc - 0x0118]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1026_H_ */ diff --git a/lib/ebcdic1047.h b/lib/converters/ebcdic1047.h similarity index 87% rename from lib/ebcdic1047.h rename to lib/converters/ebcdic1047.h index 46dfacbd..70b3b86f 100644 --- a/lib/ebcdic1047.h +++ b/lib/converters/ebcdic1047.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1047.h + * @brief IBM-1047 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1047 - */ +#ifndef _EBCDIC1047_H_ +#define _EBCDIC1047_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1047_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1047_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1047_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1047_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1047_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1047_2uni[c]; + return 1; } static const unsigned char ebcdic1047_page00[256] = { @@ -117,17 +120,17 @@ static const unsigned char ebcdic1047_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic1047_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1047_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1047_page00[wc]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1047_page00[wc]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1047_H_ */ diff --git a/lib/ebcdic1097.h b/lib/converters/ebcdic1097.h similarity index 85% rename from lib/ebcdic1097.h rename to lib/converters/ebcdic1097.h index 17929a2a..e5e0abd6 100644 --- a/lib/ebcdic1097.h +++ b/lib/converters/ebcdic1097.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1097.h + * @brief IBM-1097 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1097 - */ +#ifndef _EBCDIC1097_H_ +#define _EBCDIC1097_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1097_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1097_2uni[256] = { 0x0038, 0x0039, 0x06f5, 0x06f6, 0x06f7, 0x06f8, 0x06f9, 0x009f, }; -static int -ebcdic1097_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1097_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1097_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1097_2uni[c]; + return 1; } static const unsigned char ebcdic1097_page00[216] = { @@ -162,29 +165,29 @@ static const unsigned char ebcdic1097_pagefe[112] = { 0x00, 0xcf, 0x00, 0xda, 0xdb, 0xce, 0x00, 0x00, /* 0xe8-0xef */ }; -static int -ebcdic1097_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1097_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00d8) - c = ebcdic1097_page00[wc]; - else if (wc >= 0x0608 && wc < 0x0650) - c = ebcdic1097_page06[wc-0x0608]; - else if (wc >= 0x06f0 && wc < 0x0700) - c = ebcdic1097_page06_1[wc-0x06f0]; - else if (wc >= 0xf8f8 && wc < 0xf900) - c = ebcdic1097_pagef8[wc-0xf8f8]; - else if (wc >= 0xfb50 && wc < 0xfba8) - c = ebcdic1097_pagefb[wc-0xfb50]; - else if (wc >= 0xfbf8 && wc < 0xfc00) - c = ebcdic1097_pagefb_2[wc-0xfbf8]; - else if (wc >= 0xfe80 && wc < 0xfef0) - c = ebcdic1097_pagefe[wc-0xfe80]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00d8) + c = ebcdic1097_page00[wc]; + else if (wc >= 0x0608 && wc < 0x0650) + c = ebcdic1097_page06[wc - 0x0608]; + else if (wc >= 0x06f0 && wc < 0x0700) + c = ebcdic1097_page06_1[wc - 0x06f0]; + else if (wc >= 0xf8f8 && wc < 0xf900) + c = ebcdic1097_pagef8[wc - 0xf8f8]; + else if (wc >= 0xfb50 && wc < 0xfba8) + c = ebcdic1097_pagefb[wc - 0xfb50]; + else if (wc >= 0xfbf8 && wc < 0xfc00) + c = ebcdic1097_pagefb_2[wc - 0xfbf8]; + else if (wc >= 0xfe80 && wc < 0xfef0) + c = ebcdic1097_pagefe[wc - 0xfe80]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1097_H_ */ diff --git a/lib/ebcdic1112.h b/lib/converters/ebcdic1112.h similarity index 88% rename from lib/ebcdic1112.h rename to lib/converters/ebcdic1112.h index 23e1bf56..c9913c5e 100644 --- a/lib/ebcdic1112.h +++ b/lib/converters/ebcdic1112.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1112.h + * @brief IBM-1112 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1112 - */ +#ifndef _EBCDIC1112_H_ +#define _EBCDIC1112_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1112_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1112_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x0106, 0x00dc, 0x0141, 0x015a, 0x009f, }; -static int -ebcdic1112_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1112_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1112_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1112_2uni[c]; + return 1; } static const unsigned char ebcdic1112_page00[384] = { @@ -137,19 +140,19 @@ static const unsigned char ebcdic1112_page20[8] = { 0x00, 0xdf, 0x00, 0x00, 0x57, 0xaa, 0x56, 0x00, /* 0x18-0x1f */ }; -static int -ebcdic1112_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1112_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0180) - c = ebcdic1112_page00[wc]; - else if (wc >= 0x2018 && wc < 0x2020) - c = ebcdic1112_page20[wc-0x2018]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0180) + c = ebcdic1112_page00[wc]; + else if (wc >= 0x2018 && wc < 0x2020) + c = ebcdic1112_page20[wc - 0x2018]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1112_H_ */ diff --git a/lib/ebcdic1122.h b/lib/converters/ebcdic1122.h similarity index 86% rename from lib/ebcdic1122.h rename to lib/converters/ebcdic1122.h index 803abb8b..fd3375c2 100644 --- a/lib/ebcdic1122.h +++ b/lib/converters/ebcdic1122.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1122.h + * @brief IBM-1122 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1122 - */ +#ifndef _EBCDIC1122_H_ +#define _EBCDIC1122_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1122_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1122_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1122_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1122_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1122_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1122_2uni[c]; + return 1; } static const unsigned char ebcdic1122_page00[256] = { @@ -123,19 +126,19 @@ static const unsigned char ebcdic1122_page01[32] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0xae, 0x8e, 0x00, /* 0x78-0x7f */ }; -static int -ebcdic1122_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1122_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1122_page00[wc]; - else if (wc >= 0x0160 && wc < 0x0180) - c = ebcdic1122_page01[wc-0x0160]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1122_page00[wc]; + else if (wc >= 0x0160 && wc < 0x0180) + c = ebcdic1122_page01[wc - 0x0160]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1122_H_ */ diff --git a/lib/ebcdic1123.h b/lib/converters/ebcdic1123.h similarity index 87% rename from lib/ebcdic1123.h rename to lib/converters/ebcdic1123.h index ffc55bb5..f0d56187 100644 --- a/lib/ebcdic1123.h +++ b/lib/converters/ebcdic1123.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1123.h + * @brief IBM-1123 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1123 - */ +#ifndef _EBCDIC1123_H_ +#define _EBCDIC1123_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1123_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1123_2uni[256] = { 0x0038, 0x0039, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x009f, }; -static int -ebcdic1123_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1123_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1123_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1123_2uni[c]; + return 1; } #if DEDUPLICATE_TABLES @@ -132,21 +135,21 @@ static const unsigned char ebcdic1123_page04[152] = { 0x62, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ }; -static int -ebcdic1123_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1123_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00b0) - c = ebcdic1123_page00[wc]; - else if (wc >= 0x0400 && wc < 0x0498) - c = ebcdic1123_page04[wc-0x0400]; - else if (wc == 0x2116) - c = 0x58; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00b0) + c = ebcdic1123_page00[wc]; + else if (wc >= 0x0400 && wc < 0x0498) + c = ebcdic1123_page04[wc - 0x0400]; + else if (wc == 0x2116) + c = 0x58; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1123_H_ */ diff --git a/lib/ebcdic1130.h b/lib/converters/ebcdic1130.h similarity index 89% rename from lib/ebcdic1130.h rename to lib/converters/ebcdic1130.h index 5844d471..52f2d95c 100644 --- a/lib/ebcdic1130.h +++ b/lib/converters/ebcdic1130.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1130.h + * @brief IBM-1130 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1130 - */ +#ifndef _EBCDIC1130_H_ +#define _EBCDIC1130_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1130_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1130_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1130_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1130_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1130_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1130_2uni[c]; + return 1; } static const unsigned char ebcdic1130_page00[440] = { @@ -148,21 +151,21 @@ static const unsigned char ebcdic1130_page03[40] = { 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ }; -static int -ebcdic1130_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1130_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x01b8) - c = ebcdic1130_page00[wc]; - else if (wc >= 0x0300 && wc < 0x0328) - c = ebcdic1130_page03[wc-0x0300]; - else if (wc == 0x20ab) - c = 0x78; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x01b8) + c = ebcdic1130_page00[wc]; + else if (wc >= 0x0300 && wc < 0x0328) + c = ebcdic1130_page03[wc - 0x0300]; + else if (wc == 0x20ab) + c = 0x78; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1130_H_ */ diff --git a/lib/ebcdic1132.h b/lib/converters/ebcdic1132.h similarity index 84% rename from lib/ebcdic1132.h rename to lib/converters/ebcdic1132.h index e68988c2..1b3bf3d2 100644 --- a/lib/ebcdic1132.h +++ b/lib/converters/ebcdic1132.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1132.h + * @brief IBM-1132 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1132 - */ +#ifndef _EBCDIC1132_H_ +#define _EBCDIC1132_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1132_2uni[256] = { /* 0x00 */ @@ -72,18 +78,16 @@ static const unsigned short ebcdic1132_2uni[256] = { 0x0038, 0x0039, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x009f, }; -static int -ebcdic1132_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1132_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - unsigned short wc = ebcdic1132_2uni[c]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; - } - return RET_ILSEQ; + unsigned char c = *s; + unsigned short wc = ebcdic1132_2uni[c]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + return RET_ILSEQ; } #if DEDUPLICATE_TABLES @@ -129,21 +133,21 @@ static const unsigned char ebcdic1132_page0e[96] = { 0xb8, 0xb9, 0x00, 0x00, 0xdd, 0xde, 0x00, 0x00, /* 0xd8-0xdf */ }; -static int -ebcdic1132_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1132_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00b0) - c = ebcdic1132_page00[wc]; - else if (wc >= 0x0e80 && wc < 0x0ee0) - c = ebcdic1132_page0e[wc-0x0e80]; - else if (wc == 0x20ad) - c = 0x70; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00b0) + c = ebcdic1132_page00[wc]; + else if (wc >= 0x0e80 && wc < 0x0ee0) + c = ebcdic1132_page0e[wc - 0x0e80]; + else if (wc == 0x20ad) + c = 0x70; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1132_H_ */ diff --git a/lib/ebcdic1137.h b/lib/converters/ebcdic1137.h similarity index 84% rename from lib/ebcdic1137.h rename to lib/converters/ebcdic1137.h index 54daabb8..576d4d31 100644 --- a/lib/ebcdic1137.h +++ b/lib/converters/ebcdic1137.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1137.h + * @brief IBM-1137 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1137 - */ +#ifndef _EBCDIC1137_H_ +#define _EBCDIC1137_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1137_2uni[256] = { /* 0x00 */ @@ -72,18 +78,16 @@ static const unsigned short ebcdic1137_2uni[256] = { 0x0038, 0x0039, 0x096c, 0x096d, 0x096e, 0x096f, 0x0970, 0x009f, }; -static int -ebcdic1137_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1137_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - unsigned short wc = ebcdic1137_2uni[c]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; - } - return RET_ILSEQ; + unsigned char c = *s; + unsigned short wc = ebcdic1137_2uni[c]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + return RET_ILSEQ; } static const unsigned char ebcdic1137_page00[168] = { @@ -130,21 +134,21 @@ static const unsigned char ebcdic1137_page20[8] = { 0x00, 0x00, 0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, /* 0x08-0x0f */ }; -static int -ebcdic1137_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1137_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a8) - c = ebcdic1137_page00[wc]; - else if (wc >= 0x0900 && wc < 0x0978) - c = ebcdic1137_page09[wc-0x0900]; - else if (wc >= 0x2008 && wc < 0x2010) - c = ebcdic1137_page20[wc-0x2008]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a8) + c = ebcdic1137_page00[wc]; + else if (wc >= 0x0900 && wc < 0x0978) + c = ebcdic1137_page09[wc - 0x0900]; + else if (wc >= 0x2008 && wc < 0x2010) + c = ebcdic1137_page20[wc - 0x2008]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1137_H_ */ diff --git a/lib/ebcdic1140.h b/lib/converters/ebcdic1140.h similarity index 86% rename from lib/ebcdic1140.h rename to lib/converters/ebcdic1140.h index 135652eb..95d29ed1 100644 --- a/lib/ebcdic1140.h +++ b/lib/converters/ebcdic1140.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1140.h + * @brief IBM-1140 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1140 - */ +#ifndef _EBCDIC1140_H_ +#define _EBCDIC1140_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1140_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1140_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1140_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1140_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1140_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1140_2uni[c]; + return 1; } static const unsigned char ebcdic1140_page00[256] = { @@ -117,19 +120,19 @@ static const unsigned char ebcdic1140_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic1140_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1140_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1140_page00[wc]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1140_page00[wc]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1140_H_ */ diff --git a/lib/ebcdic1141.h b/lib/converters/ebcdic1141.h similarity index 86% rename from lib/ebcdic1141.h rename to lib/converters/ebcdic1141.h index 6048d038..d197c6e0 100644 --- a/lib/ebcdic1141.h +++ b/lib/converters/ebcdic1141.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1141.h + * @brief IBM-1141 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1141 - */ +#ifndef _EBCDIC1141_H_ +#define _EBCDIC1141_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1141_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1141_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x005d, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1141_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1141_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1141_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1141_2uni[c]; + return 1; } static const unsigned char ebcdic1141_page00[256] = { @@ -117,19 +120,19 @@ static const unsigned char ebcdic1141_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xd0, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic1141_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1141_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1141_page00[wc]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1141_page00[wc]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1141_H_ */ diff --git a/lib/ebcdic1142.h b/lib/converters/ebcdic1142.h similarity index 86% rename from lib/ebcdic1142.h rename to lib/converters/ebcdic1142.h index 02865b0e..17ee8506 100644 --- a/lib/ebcdic1142.h +++ b/lib/converters/ebcdic1142.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1142.h + * @brief IBM-1142 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1142 - */ +#ifndef _EBCDIC1142_H_ +#define _EBCDIC1142_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1142_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1142_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1142_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1142_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1142_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1142_2uni[c]; + return 1; } static const unsigned char ebcdic1142_page00[256] = { @@ -117,19 +120,19 @@ static const unsigned char ebcdic1142_page00[256] = { 0x6a, 0xdd, 0xde, 0xdb, 0xa1, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic1142_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1142_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1142_page00[wc]; - else if (wc == 0x20ac) - c = 0x5a; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1142_page00[wc]; + else if (wc == 0x20ac) + c = 0x5a; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1142_H_ */ diff --git a/lib/ebcdic1143.h b/lib/converters/ebcdic1143.h similarity index 86% rename from lib/ebcdic1143.h rename to lib/converters/ebcdic1143.h index 718407aa..f2807b9f 100644 --- a/lib/ebcdic1143.h +++ b/lib/converters/ebcdic1143.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1143.h + * @brief IBM-1143 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1143 - */ +#ifndef _EBCDIC1143_H_ +#define _EBCDIC1143_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1143_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1143_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1143_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1143_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1143_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1143_2uni[c]; + return 1; } static const unsigned char ebcdic1143_page00[256] = { @@ -117,19 +120,19 @@ static const unsigned char ebcdic1143_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xa1, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic1143_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1143_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1143_page00[wc]; - else if (wc == 0x20ac) - c = 0x5a; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1143_page00[wc]; + else if (wc == 0x20ac) + c = 0x5a; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1143_H_ */ diff --git a/lib/ebcdic1144.h b/lib/converters/ebcdic1144.h similarity index 86% rename from lib/ebcdic1144.h rename to lib/converters/ebcdic1144.h index da4e1616..13ecbd73 100644 --- a/lib/ebcdic1144.h +++ b/lib/converters/ebcdic1144.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1144.h + * @brief IBM-1144 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1144 - */ +#ifndef _EBCDIC1144_H_ +#define _EBCDIC1144_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1144_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1144_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1144_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1144_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1144_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1144_2uni[c]; + return 1; } static const unsigned char ebcdic1144_page00[256] = { @@ -117,19 +120,19 @@ static const unsigned char ebcdic1144_page00[256] = { 0x70, 0x79, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic1144_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1144_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1144_page00[wc]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1144_page00[wc]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1144_H_ */ diff --git a/lib/ebcdic1145.h b/lib/converters/ebcdic1145.h similarity index 86% rename from lib/ebcdic1145.h rename to lib/converters/ebcdic1145.h index 7304da12..d3ed1d93 100644 --- a/lib/ebcdic1145.h +++ b/lib/converters/ebcdic1145.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1145.h + * @brief IBM-1145 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1145 - */ +#ifndef _EBCDIC1145_H_ +#define _EBCDIC1145_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1145_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1145_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1145_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1145_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1145_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1145_2uni[c]; + return 1; } static const unsigned char ebcdic1145_page00[256] = { @@ -117,19 +120,19 @@ static const unsigned char ebcdic1145_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic1145_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1145_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1145_page00[wc]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1145_page00[wc]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1145_H_ */ diff --git a/lib/ebcdic1146.h b/lib/converters/ebcdic1146.h similarity index 86% rename from lib/ebcdic1146.h rename to lib/converters/ebcdic1146.h index 1f9f006f..88530af7 100644 --- a/lib/ebcdic1146.h +++ b/lib/converters/ebcdic1146.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1146.h + * @brief IBM-1146 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1146 - */ +#ifndef _EBCDIC1146_H_ +#define _EBCDIC1146_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1146_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1146_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1146_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1146_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1146_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1146_2uni[c]; + return 1; } static const unsigned char ebcdic1146_page00[256] = { @@ -117,19 +120,19 @@ static const unsigned char ebcdic1146_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic1146_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1146_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1146_page00[wc]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1146_page00[wc]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1146_H_ */ diff --git a/lib/ebcdic1147.h b/lib/converters/ebcdic1147.h similarity index 86% rename from lib/ebcdic1147.h rename to lib/converters/ebcdic1147.h index 158cd4ad..bbfc0afa 100644 --- a/lib/ebcdic1147.h +++ b/lib/converters/ebcdic1147.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1147.h + * @brief IBM-1147 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1147 - */ +#ifndef _EBCDIC1147_H_ +#define _EBCDIC1147_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1147_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1147_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1147_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1147_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1147_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1147_2uni[c]; + return 1; } static const unsigned char ebcdic1147_page00[256] = { @@ -117,19 +120,19 @@ static const unsigned char ebcdic1147_page00[256] = { 0x70, 0x6a, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic1147_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1147_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1147_page00[wc]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1147_page00[wc]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1147_H_ */ diff --git a/lib/ebcdic1148.h b/lib/converters/ebcdic1148.h similarity index 86% rename from lib/ebcdic1148.h rename to lib/converters/ebcdic1148.h index 6a65db3d..99d3ef86 100644 --- a/lib/ebcdic1148.h +++ b/lib/converters/ebcdic1148.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1148.h + * @brief IBM-1148 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1148 - */ +#ifndef _EBCDIC1148_H_ +#define _EBCDIC1148_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1148_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1148_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1148_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1148_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1148_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1148_2uni[c]; + return 1; } static const unsigned char ebcdic1148_page00[256] = { @@ -117,19 +120,19 @@ static const unsigned char ebcdic1148_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic1148_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1148_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1148_page00[wc]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1148_page00[wc]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1148_H_ */ diff --git a/lib/ebcdic1149.h b/lib/converters/ebcdic1149.h similarity index 86% rename from lib/ebcdic1149.h rename to lib/converters/ebcdic1149.h index edd588ba..f294a840 100644 --- a/lib/ebcdic1149.h +++ b/lib/converters/ebcdic1149.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1149.h + * @brief IBM-1149 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1149 - */ +#ifndef _EBCDIC1149_H_ +#define _EBCDIC1149_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1149_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1149_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1149_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1149_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1149_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1149_2uni[c]; + return 1; } static const unsigned char ebcdic1149_page00[256] = { @@ -117,19 +120,19 @@ static const unsigned char ebcdic1149_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0xc0, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic1149_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1149_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1149_page00[wc]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1149_page00[wc]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1149_H_ */ diff --git a/lib/ebcdic1153.h b/lib/converters/ebcdic1153.h similarity index 88% rename from lib/ebcdic1153.h rename to lib/converters/ebcdic1153.h index 818e4918..b186c2b3 100644 --- a/lib/ebcdic1153.h +++ b/lib/converters/ebcdic1153.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1153.h + * @brief IBM-1153 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1153 - */ +#ifndef _EBCDIC1153_H_ +#define _EBCDIC1153_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1153_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1153_2uni[256] = { 0x0038, 0x0039, 0x010e, 0x0170, 0x00dc, 0x0164, 0x00da, 0x009f, }; -static int -ebcdic1153_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1153_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1153_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1153_2uni[c]; + return 1; } static const unsigned char ebcdic1153_page00[384] = { @@ -144,21 +147,21 @@ static const unsigned char ebcdic1153_page02[32] = { }; #endif -static int -ebcdic1153_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1153_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0180) - c = ebcdic1153_page00[wc]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = ebcdic1153_page02[wc-0x02c0]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0180) + c = ebcdic1153_page00[wc]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = ebcdic1153_page02[wc - 0x02c0]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1153_H_ */ diff --git a/lib/ebcdic1154.h b/lib/converters/ebcdic1154.h similarity index 85% rename from lib/ebcdic1154.h rename to lib/converters/ebcdic1154.h index 70a1d844..ab2d9450 100644 --- a/lib/ebcdic1154.h +++ b/lib/converters/ebcdic1154.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1154.h + * @brief IBM-1154 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1154 - */ +#ifndef _EBCDIC1154_H_ +#define _EBCDIC1154_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1154_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1154_2uni[256] = { 0x0038, 0x0039, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x009f, }; -static int -ebcdic1154_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1154_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1154_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1154_2uni[c]; + return 1; } static const unsigned char ebcdic1154_page00[176] = { @@ -125,23 +128,23 @@ static const unsigned char ebcdic1154_page04[96] = { }; #endif -static int -ebcdic1154_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1154_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00b0) - c = ebcdic1154_page00[wc]; - else if (wc >= 0x0400 && wc < 0x0460) - c = ebcdic1154_page04[wc-0x0400]; - else if (wc == 0x20ac) - c = 0xe1; - else if (wc == 0x2116) - c = 0x58; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00b0) + c = ebcdic1154_page00[wc]; + else if (wc >= 0x0400 && wc < 0x0460) + c = ebcdic1154_page04[wc - 0x0400]; + else if (wc == 0x20ac) + c = 0xe1; + else if (wc == 0x2116) + c = 0x58; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1154_H_ */ diff --git a/lib/ebcdic1155.h b/lib/converters/ebcdic1155.h similarity index 87% rename from lib/ebcdic1155.h rename to lib/converters/ebcdic1155.h index 272f8fb2..396fff50 100644 --- a/lib/ebcdic1155.h +++ b/lib/converters/ebcdic1155.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1155.h + * @brief IBM-1155 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1155 - */ +#ifndef _EBCDIC1155_H_ +#define _EBCDIC1155_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1155_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1155_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x0022, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1155_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1155_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1155_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1155_2uni[c]; + return 1; } static const unsigned char ebcdic1155_page00[256] = { @@ -132,21 +135,21 @@ static const unsigned char ebcdic1155_page01[72] = { }; #endif -static int -ebcdic1155_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1155_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1155_page00[wc]; - else if (wc >= 0x0118 && wc < 0x0160) - c = ebcdic1155_page01[wc-0x0118]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1155_page00[wc]; + else if (wc >= 0x0118 && wc < 0x0160) + c = ebcdic1155_page01[wc - 0x0118]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1155_H_ */ diff --git a/lib/ebcdic1156.h b/lib/converters/ebcdic1156.h similarity index 88% rename from lib/ebcdic1156.h rename to lib/converters/ebcdic1156.h index f628683a..ad804c13 100644 --- a/lib/ebcdic1156.h +++ b/lib/converters/ebcdic1156.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1156.h + * @brief IBM-1156 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1156 - */ +#ifndef _EBCDIC1156_H_ +#define _EBCDIC1156_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1156_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1156_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x0106, 0x00dc, 0x0141, 0x015a, 0x009f, }; -static int -ebcdic1156_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1156_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1156_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1156_2uni[c]; + return 1; } static const unsigned char ebcdic1156_page00[384] = { @@ -141,21 +144,21 @@ static const unsigned char ebcdic1156_page20[8] = { }; #endif -static int -ebcdic1156_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1156_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0180) - c = ebcdic1156_page00[wc]; - else if (wc >= 0x2018 && wc < 0x2020) - c = ebcdic1156_page20[wc-0x2018]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0180) + c = ebcdic1156_page00[wc]; + else if (wc >= 0x2018 && wc < 0x2020) + c = ebcdic1156_page20[wc - 0x2018]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1156_H_ */ diff --git a/lib/ebcdic1157.h b/lib/converters/ebcdic1157.h similarity index 86% rename from lib/ebcdic1157.h rename to lib/converters/ebcdic1157.h index 67858d34..3efb930c 100644 --- a/lib/ebcdic1157.h +++ b/lib/converters/ebcdic1157.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1157.h + * @brief IBM-1157 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1157 - */ +#ifndef _EBCDIC1157_H_ +#define _EBCDIC1157_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1157_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1157_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1157_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1157_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1157_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1157_2uni[c]; + return 1; } static const unsigned char ebcdic1157_page00[256] = { @@ -127,21 +130,21 @@ static const unsigned char ebcdic1157_page01[32] = { }; #endif -static int -ebcdic1157_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1157_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic1157_page00[wc]; - else if (wc >= 0x0160 && wc < 0x0180) - c = ebcdic1157_page01[wc-0x0160]; - else if (wc == 0x20ac) - c = 0x5a; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic1157_page00[wc]; + else if (wc >= 0x0160 && wc < 0x0180) + c = ebcdic1157_page01[wc - 0x0160]; + else if (wc == 0x20ac) + c = 0x5a; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1157_H_ */ diff --git a/lib/ebcdic1158.h b/lib/converters/ebcdic1158.h similarity index 86% rename from lib/ebcdic1158.h rename to lib/converters/ebcdic1158.h index a6364e0f..d58d3899 100644 --- a/lib/ebcdic1158.h +++ b/lib/converters/ebcdic1158.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1158.h + * @brief IBM-1158 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1158 - */ +#ifndef _EBCDIC1158_H_ +#define _EBCDIC1158_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1158_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1158_2uni[256] = { 0x0038, 0x0039, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x009f, }; -static int -ebcdic1158_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1158_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1158_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1158_2uni[c]; + return 1; } #if DEDUPLICATE_TABLES @@ -136,23 +139,23 @@ static const unsigned char ebcdic1158_page04[152] = { }; #endif -static int -ebcdic1158_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1158_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00b0) - c = ebcdic1158_page00[wc]; - else if (wc >= 0x0400 && wc < 0x0498) - c = ebcdic1158_page04[wc-0x0400]; - else if (wc == 0x20ac) - c = 0xe1; - else if (wc == 0x2116) - c = 0x58; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00b0) + c = ebcdic1158_page00[wc]; + else if (wc >= 0x0400 && wc < 0x0498) + c = ebcdic1158_page04[wc - 0x0400]; + else if (wc == 0x20ac) + c = 0xe1; + else if (wc == 0x2116) + c = 0x58; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1158_H_ */ diff --git a/lib/ebcdic1160.h b/lib/converters/ebcdic1160.h similarity index 86% rename from lib/ebcdic1160.h rename to lib/converters/ebcdic1160.h index 2245d0c1..b98b24cb 100644 --- a/lib/ebcdic1160.h +++ b/lib/converters/ebcdic1160.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1160.h + * @brief IBM-1160 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1160 - */ +#ifndef _EBCDIC1160_H_ +#define _EBCDIC1160_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1160_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1160_2uni[256] = { 0x0038, 0x0039, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4b, 0x20ac, 0x009f, }; -static int -ebcdic1160_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1160_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1160_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1160_2uni[c]; + return 1; } #if DEDUPLICATE_TABLES @@ -129,21 +132,21 @@ static const unsigned char ebcdic1160_page0e[96] = { }; #endif -static int -ebcdic1160_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1160_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00b0) - c = ebcdic1160_page00[wc]; - else if (wc >= 0x0e00 && wc < 0x0e60) - c = ebcdic1160_page0e[wc-0x0e00]; - else if (wc == 0x20ac) - c = 0xfe; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00b0) + c = ebcdic1160_page00[wc]; + else if (wc >= 0x0e00 && wc < 0x0e60) + c = ebcdic1160_page0e[wc - 0x0e00]; + else if (wc == 0x20ac) + c = 0xfe; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1160_H_ */ diff --git a/lib/ebcdic1164.h b/lib/converters/ebcdic1164.h similarity index 88% rename from lib/ebcdic1164.h rename to lib/converters/ebcdic1164.h index 8ee2bb12..a143cf51 100644 --- a/lib/ebcdic1164.h +++ b/lib/converters/ebcdic1164.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1164.h + * @brief IBM-1164 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1164 - */ +#ifndef _EBCDIC1164_H_ +#define _EBCDIC1164_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1164_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1164_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic1164_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1164_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1164_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1164_2uni[c]; + return 1; } static const unsigned char ebcdic1164_page00[440] = { @@ -155,21 +158,21 @@ static const unsigned char ebcdic1164_page20[8] = { 0x00, 0x00, 0x00, 0x78, 0x9f, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ }; -static int -ebcdic1164_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1164_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x01b8) - c = ebcdic1164_page00[wc]; - else if (wc >= 0x0300 && wc < 0x0328) - c = ebcdic1164_page03[wc-0x0300]; - else if (wc >= 0x20a8 && wc < 0x20b0) - c = ebcdic1164_page20[wc-0x20a8]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x01b8) + c = ebcdic1164_page00[wc]; + else if (wc >= 0x0300 && wc < 0x0328) + c = ebcdic1164_page03[wc - 0x0300]; + else if (wc >= 0x20a8 && wc < 0x20b0) + c = ebcdic1164_page20[wc - 0x20a8]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1164_H_ */ diff --git a/lib/ebcdic1165.h b/lib/converters/ebcdic1165.h similarity index 88% rename from lib/ebcdic1165.h rename to lib/converters/ebcdic1165.h index a7307c89..b7534ad3 100644 --- a/lib/ebcdic1165.h +++ b/lib/converters/ebcdic1165.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1165.h + * @brief IBM-1165 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1165 - */ +#ifndef _EBCDIC1165_H_ +#define _EBCDIC1165_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1165_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1165_2uni[256] = { 0x0038, 0x0039, 0x010e, 0x0170, 0x00dc, 0x0164, 0x00da, 0x009f, }; -static int -ebcdic1165_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1165_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1165_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1165_2uni[c]; + return 1; } static const unsigned char ebcdic1165_page00[384] = { @@ -144,21 +147,21 @@ static const unsigned char ebcdic1165_page02[32] = { }; #endif -static int -ebcdic1165_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1165_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0180) - c = ebcdic1165_page00[wc]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = ebcdic1165_page02[wc-0x02c0]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0180) + c = ebcdic1165_page00[wc]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = ebcdic1165_page02[wc - 0x02c0]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1165_H_ */ diff --git a/lib/ebcdic1166.h b/lib/converters/ebcdic1166.h similarity index 87% rename from lib/ebcdic1166.h rename to lib/converters/ebcdic1166.h index f1a02703..314b84c0 100644 --- a/lib/ebcdic1166.h +++ b/lib/converters/ebcdic1166.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic1166.h + * @brief IBM-1166 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-1166 - */ +#ifndef _EBCDIC1166_H_ +#define _EBCDIC1166_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic1166_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic1166_2uni[256] = { 0x0038, 0x0039, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x009f, }; -static int -ebcdic1166_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic1166_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic1166_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic1166_2uni[c]; + return 1; } #if DEDUPLICATE_TABLES @@ -143,23 +146,23 @@ static const unsigned char ebcdic1166_page04[240] = { 0x70, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ }; -static int -ebcdic1166_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic1166_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00b0) - c = ebcdic1166_page00[wc]; - else if (wc >= 0x0400 && wc < 0x04f0) - c = ebcdic1166_page04[wc-0x0400]; - else if (wc == 0x20ac) - c = 0xe1; - else if (wc == 0x2116) - c = 0x58; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00b0) + c = ebcdic1166_page00[wc]; + else if (wc >= 0x0400 && wc < 0x04f0) + c = ebcdic1166_page04[wc - 0x0400]; + else if (wc == 0x20ac) + c = 0xe1; + else if (wc == 0x2116) + c = 0x58; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC1166_H_ */ diff --git a/lib/ebcdic12712.h b/lib/converters/ebcdic12712.h similarity index 84% rename from lib/ebcdic12712.h rename to lib/converters/ebcdic12712.h index 9e3a4821..c2e78c86 100644 --- a/lib/ebcdic12712.h +++ b/lib/converters/ebcdic12712.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic12712.h + * @brief IBM-12712 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-12712 - */ +#ifndef _EBCDIC12712_H_ +#define _EBCDIC12712_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic12712_2uni[256] = { /* 0x00 */ @@ -72,18 +78,16 @@ static const unsigned short ebcdic12712_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x202a, 0x202b, 0x200e, 0x200f, 0x009f, }; -static int -ebcdic12712_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic12712_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - unsigned short wc = ebcdic12712_2uni[c]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; - } - return RET_ILSEQ; + unsigned char c = *s; + unsigned short wc = ebcdic12712_2uni[c]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + return RET_ILSEQ; } #if DEDUPLICATE_TABLES @@ -146,23 +150,23 @@ static const unsigned char ebcdic12712_page20_1[8] = { 0x00, 0x00, 0x9e, 0x00, 0x9c, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ }; -static int -ebcdic12712_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic12712_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00f8) - c = ebcdic12712_page00[wc]; - else if (wc >= 0x05d0 && wc < 0x05f0) - c = ebcdic12712_page05[wc-0x05d0]; - else if (wc >= 0x2008 && wc < 0x2040) - c = ebcdic12712_page20[wc-0x2008]; - else if (wc >= 0x20a8 && wc < 0x20b0) - c = ebcdic12712_page20_1[wc-0x20a8]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00f8) + c = ebcdic12712_page00[wc]; + else if (wc >= 0x05d0 && wc < 0x05f0) + c = ebcdic12712_page05[wc - 0x05d0]; + else if (wc >= 0x2008 && wc < 0x2040) + c = ebcdic12712_page20[wc - 0x2008]; + else if (wc >= 0x20a8 && wc < 0x20b0) + c = ebcdic12712_page20_1[wc - 0x20a8]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC12712_H_ */ diff --git a/lib/ebcdic16804.h b/lib/converters/ebcdic16804.h similarity index 86% rename from lib/ebcdic16804.h rename to lib/converters/ebcdic16804.h index 2ace6edb..0dcf9b73 100644 --- a/lib/ebcdic16804.h +++ b/lib/converters/ebcdic16804.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic16804.h + * @brief IBM-16804 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-16804 - */ +#ifndef _EBCDIC16804_H_ +#define _EBCDIC16804_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic16804_2uni[256] = { /* 0x00 */ @@ -72,18 +78,16 @@ static const unsigned short ebcdic16804_2uni[256] = { 0x0038, 0x0039, 0x20ac, 0x0666, 0x0667, 0x0668, 0x0669, 0x009f, }; -static int -ebcdic16804_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic16804_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - unsigned short wc = ebcdic16804_2uni[c]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; - } - return RET_ILSEQ; + unsigned char c = *s; + unsigned short wc = ebcdic16804_2uni[c]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + return RET_ILSEQ; } static const unsigned char ebcdic16804_page00[248] = { @@ -158,25 +162,25 @@ static const unsigned char ebcdic16804_pagefe[136] = { 0xb5, 0x00, 0x00, 0xb8, 0xb9, 0x00, 0x00, 0x00, /* 0xf8-0xff */ }; -static int -ebcdic16804_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic16804_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00f8) - c = ebcdic16804_page00[wc]; - else if (wc >= 0x0608 && wc < 0x0670) - c = ebcdic16804_page06[wc-0x0608]; - else if (wc >= 0x2000 && wc < 0x2010) - c = ebcdic16804_page20[wc-0x2000]; - else if (wc == 0x20ac) - c = 0xfa; - else if (wc >= 0xfe78 && wc < 0xff00) - c = ebcdic16804_pagefe[wc-0xfe78]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00f8) + c = ebcdic16804_page00[wc]; + else if (wc >= 0x0608 && wc < 0x0670) + c = ebcdic16804_page06[wc - 0x0608]; + else if (wc >= 0x2000 && wc < 0x2010) + c = ebcdic16804_page20[wc - 0x2000]; + else if (wc == 0x20ac) + c = 0xfa; + else if (wc >= 0xfe78 && wc < 0xff00) + c = ebcdic16804_pagefe[wc - 0xfe78]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC16804_H_ */ diff --git a/lib/ebcdic273.h b/lib/converters/ebcdic273.h similarity index 87% rename from lib/ebcdic273.h rename to lib/converters/ebcdic273.h index 7c372bde..43430ee6 100644 --- a/lib/ebcdic273.h +++ b/lib/converters/ebcdic273.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic273.h + * @brief IBM-273 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-273 - */ +#ifndef _EBCDIC273_H_ +#define _EBCDIC273_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic273_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic273_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x005d, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic273_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic273_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic273_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic273_2uni[c]; + return 1; } static const unsigned char ebcdic273_page00[256] = { @@ -117,17 +120,17 @@ static const unsigned char ebcdic273_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xd0, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic273_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic273_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic273_page00[wc]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic273_page00[wc]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC273_H_ */ diff --git a/lib/ebcdic277.h b/lib/converters/ebcdic277.h similarity index 87% rename from lib/ebcdic277.h rename to lib/converters/ebcdic277.h index efca03aa..a20e99e7 100644 --- a/lib/ebcdic277.h +++ b/lib/converters/ebcdic277.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic277.h + * @brief IBM-277 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-277 - */ +#ifndef _EBCDIC277_H_ +#define _EBCDIC277_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic277_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic277_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic277_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic277_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic277_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic277_2uni[c]; + return 1; } static const unsigned char ebcdic277_page00[256] = { @@ -117,17 +120,17 @@ static const unsigned char ebcdic277_page00[256] = { 0x6a, 0xdd, 0xde, 0xdb, 0xa1, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic277_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic277_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic277_page00[wc]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic277_page00[wc]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC277_H_ */ diff --git a/lib/ebcdic278.h b/lib/converters/ebcdic278.h similarity index 87% rename from lib/ebcdic278.h rename to lib/converters/ebcdic278.h index 608b3d84..7dcd9920 100644 --- a/lib/ebcdic278.h +++ b/lib/converters/ebcdic278.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic278.h + * @brief IBM-278 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-278 - */ +#ifndef _EBCDIC278_H_ +#define _EBCDIC278_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic278_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic278_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic278_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic278_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic278_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic278_2uni[c]; + return 1; } static const unsigned char ebcdic278_page00[256] = { @@ -117,17 +120,17 @@ static const unsigned char ebcdic278_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xa1, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic278_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic278_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic278_page00[wc]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic278_page00[wc]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC278_H_ */ diff --git a/lib/ebcdic280.h b/lib/converters/ebcdic280.h similarity index 87% rename from lib/ebcdic280.h rename to lib/converters/ebcdic280.h index 9e24ce8d..261e863d 100644 --- a/lib/ebcdic280.h +++ b/lib/converters/ebcdic280.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic280.h + * @brief IBM-280 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-280 - */ +#ifndef _EBCDIC280_H_ +#define _EBCDIC280_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic280_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic280_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic280_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic280_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic280_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic280_2uni[c]; + return 1; } static const unsigned char ebcdic280_page00[256] = { @@ -117,17 +120,17 @@ static const unsigned char ebcdic280_page00[256] = { 0x70, 0x79, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic280_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic280_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic280_page00[wc]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic280_page00[wc]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC280_H_ */ diff --git a/lib/ebcdic282.h b/lib/converters/ebcdic282.h similarity index 87% rename from lib/ebcdic282.h rename to lib/converters/ebcdic282.h index bb50eb2a..8746007e 100644 --- a/lib/ebcdic282.h +++ b/lib/converters/ebcdic282.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic282.h + * @brief IBM-282 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-282 - */ +#ifndef _EBCDIC282_H_ +#define _EBCDIC282_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic282_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic282_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic282_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic282_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic282_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic282_2uni[c]; + return 1; } static const unsigned char ebcdic282_page00[256] = { @@ -117,17 +120,17 @@ static const unsigned char ebcdic282_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic282_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic282_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic282_page00[wc]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic282_page00[wc]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC282_H_ */ diff --git a/lib/ebcdic284.h b/lib/converters/ebcdic284.h similarity index 87% rename from lib/ebcdic284.h rename to lib/converters/ebcdic284.h index e730fff4..d78c0530 100644 --- a/lib/ebcdic284.h +++ b/lib/converters/ebcdic284.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic284.h + * @brief IBM-284 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-284 - */ +#ifndef _EBCDIC284_H_ +#define _EBCDIC284_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic284_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic284_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic284_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic284_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic284_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic284_2uni[c]; + return 1; } static const unsigned char ebcdic284_page00[256] = { @@ -117,17 +120,17 @@ static const unsigned char ebcdic284_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic284_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic284_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic284_page00[wc]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic284_page00[wc]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC284_H_ */ diff --git a/lib/ebcdic285.h b/lib/converters/ebcdic285.h similarity index 87% rename from lib/ebcdic285.h rename to lib/converters/ebcdic285.h index 01ecef62..bd188660 100644 --- a/lib/ebcdic285.h +++ b/lib/converters/ebcdic285.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic285.h + * @brief IBM-285 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-285 - */ +#ifndef _EBCDIC285_H_ +#define _EBCDIC285_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic285_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic285_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic285_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic285_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic285_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic285_2uni[c]; + return 1; } static const unsigned char ebcdic285_page00[256] = { @@ -117,17 +120,17 @@ static const unsigned char ebcdic285_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic285_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic285_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic285_page00[wc]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic285_page00[wc]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC285_H_ */ diff --git a/lib/ebcdic297.h b/lib/converters/ebcdic297.h similarity index 87% rename from lib/ebcdic297.h rename to lib/converters/ebcdic297.h index 34789e5a..d0b4cdfc 100644 --- a/lib/ebcdic297.h +++ b/lib/converters/ebcdic297.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic297.h + * @brief IBM-297 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-297 - */ +#ifndef _EBCDIC297_H_ +#define _EBCDIC297_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic297_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic297_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic297_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic297_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic297_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic297_2uni[c]; + return 1; } static const unsigned char ebcdic297_page00[256] = { @@ -117,17 +120,17 @@ static const unsigned char ebcdic297_page00[256] = { 0x70, 0x6a, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic297_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic297_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic297_page00[wc]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic297_page00[wc]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC297_H_ */ diff --git a/lib/ebcdic423.h b/lib/converters/ebcdic423.h similarity index 86% rename from lib/ebcdic423.h rename to lib/converters/ebcdic423.h index 514a418c..06bc6802 100644 --- a/lib/ebcdic423.h +++ b/lib/converters/ebcdic423.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic423.h + * @brief IBM-423 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-423 - */ +#ifndef _EBCDIC423_H_ +#define _EBCDIC423_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic423_2uni[256] = { /* 0x00 */ @@ -72,18 +78,16 @@ static const unsigned short ebcdic423_2uni[256] = { 0x0038, 0x0039, 0x00ff, 0x00e7, 0x00c7, 0xfffd, 0xfffd, 0x009f, }; -static int -ebcdic423_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic423_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - unsigned short wc = ebcdic423_2uni[c]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; - } - return RET_ILSEQ; + unsigned char c = *s; + unsigned short wc = ebcdic423_2uni[c]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + return RET_ILSEQ; } static const unsigned char ebcdic423_page00[256] = { @@ -133,19 +137,19 @@ static const unsigned char ebcdic423_page03[80] = { 0xbf, 0xcb, 0xb4, 0xb8, 0xb6, 0xb7, 0xb9, 0x00, /* 0xc8-0xcf */ }; -static int -ebcdic423_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic423_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic423_page00[wc]; - else if (wc >= 0x0380 && wc < 0x03d0) - c = ebcdic423_page03[wc-0x0380]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic423_page00[wc]; + else if (wc >= 0x0380 && wc < 0x03d0) + c = ebcdic423_page03[wc - 0x0380]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC423_H_ */ diff --git a/lib/ebcdic424.h b/lib/converters/ebcdic424.h similarity index 85% rename from lib/ebcdic424.h rename to lib/converters/ebcdic424.h index 2c3d366c..61db7e2b 100644 --- a/lib/ebcdic424.h +++ b/lib/converters/ebcdic424.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic424.h + * @brief IBM-424 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-424 - */ +#ifndef _EBCDIC424_H_ +#define _EBCDIC424_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic424_2uni[256] = { /* 0x00 */ @@ -72,18 +78,16 @@ static const unsigned short ebcdic424_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x009f, }; -static int -ebcdic424_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic424_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - unsigned short wc = ebcdic424_2uni[c]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; - } - return RET_ILSEQ; + unsigned char c = *s; + unsigned short wc = ebcdic424_2uni[c]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + return RET_ILSEQ; } static const unsigned char ebcdic424_page00[248] = { @@ -134,21 +138,21 @@ static const unsigned char ebcdic424_page20[48] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbc, 0x00, /* 0x38-0x3f */ }; -static int -ebcdic424_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic424_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00f8) - c = ebcdic424_page00[wc]; - else if (wc >= 0x05d0 && wc < 0x05f0) - c = ebcdic424_page05[wc-0x05d0]; - else if (wc >= 0x2010 && wc < 0x2040) - c = ebcdic424_page20[wc-0x2010]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00f8) + c = ebcdic424_page00[wc]; + else if (wc >= 0x05d0 && wc < 0x05f0) + c = ebcdic424_page05[wc - 0x05d0]; + else if (wc >= 0x2010 && wc < 0x2040) + c = ebcdic424_page20[wc - 0x2010]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC424_H_ */ diff --git a/lib/ebcdic425.h b/lib/converters/ebcdic425.h similarity index 85% rename from lib/ebcdic425.h rename to lib/converters/ebcdic425.h index 675c571a..46e7d6d8 100644 --- a/lib/ebcdic425.h +++ b/lib/converters/ebcdic425.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic425.h + * @brief IBM-425 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-425 - */ +#ifndef _EBCDIC425_H_ +#define _EBCDIC425_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic425_2uni[256] = { /* 0x00 */ @@ -72,18 +78,16 @@ static const unsigned short ebcdic425_2uni[256] = { 0x0038, 0x0039, 0xfffd, 0x00db, 0x00dc, 0x00d9, 0x00a4, 0x009f, }; -static int -ebcdic425_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic425_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - unsigned short wc = ebcdic425_2uni[c]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; - } - return RET_ILSEQ; + unsigned char c = *s; + unsigned short wc = ebcdic425_2uni[c]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + return RET_ILSEQ; } static const unsigned char ebcdic425_page00[256] = { @@ -144,25 +148,25 @@ static const unsigned char ebcdic425_page20[8] = { 0x00, 0x00, 0x00, 0x00, 0xec, 0xed, 0xee, 0xef, /* 0x08-0x0f */ }; -static int -ebcdic425_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic425_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic425_page00[wc]; - else if (wc >= 0x0150 && wc < 0x0180) - c = ebcdic425_page01[wc-0x0150]; - else if (wc >= 0x0608 && wc < 0x0658) - c = ebcdic425_page06[wc-0x0608]; - else if (wc >= 0x2008 && wc < 0x2010) - c = ebcdic425_page20[wc-0x2008]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic425_page00[wc]; + else if (wc >= 0x0150 && wc < 0x0180) + c = ebcdic425_page01[wc - 0x0150]; + else if (wc >= 0x0608 && wc < 0x0658) + c = ebcdic425_page06[wc - 0x0608]; + else if (wc >= 0x2008 && wc < 0x2010) + c = ebcdic425_page20[wc - 0x2008]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC425_H_ */ diff --git a/lib/ebcdic4971.h b/lib/converters/ebcdic4971.h similarity index 84% rename from lib/ebcdic4971.h rename to lib/converters/ebcdic4971.h index c396ca29..80159d83 100644 --- a/lib/ebcdic4971.h +++ b/lib/converters/ebcdic4971.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic4971.h + * @brief IBM-4971 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-4971 - */ +#ifndef _EBCDIC4971_H_ +#define _EBCDIC4971_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic4971_2uni[256] = { /* 0x00 */ @@ -72,18 +78,16 @@ static const unsigned short ebcdic4971_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00a9, 0x20ac, 0xfffd, 0x00bb, 0x009f, }; -static int -ebcdic4971_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic4971_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - unsigned short wc = ebcdic4971_2uni[c]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; - } - return RET_ILSEQ; + unsigned char c = *s; + unsigned short wc = ebcdic4971_2uni[c]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + return RET_ILSEQ; } #if DEDUPLICATE_TABLES @@ -141,23 +145,23 @@ static const unsigned char ebcdic4971_page20[16] = { }; #endif -static int -ebcdic4971_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic4971_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00c0) - c = ebcdic4971_page00[wc]; - else if (wc >= 0x0380 && wc < 0x03d0) - c = ebcdic4971_page03[wc-0x0380]; - else if (wc >= 0x2010 && wc < 0x2020) - c = ebcdic4971_page20[wc-0x2010]; - else if (wc == 0x20ac) - c = 0xfc; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00c0) + c = ebcdic4971_page00[wc]; + else if (wc >= 0x0380 && wc < 0x03d0) + c = ebcdic4971_page03[wc - 0x0380]; + else if (wc >= 0x2010 && wc < 0x2020) + c = ebcdic4971_page20[wc - 0x2010]; + else if (wc == 0x20ac) + c = 0xfc; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC4971_H_ */ diff --git a/lib/ebcdic500.h b/lib/converters/ebcdic500.h similarity index 87% rename from lib/ebcdic500.h rename to lib/converters/ebcdic500.h index dd25158c..1b51dd96 100644 --- a/lib/ebcdic500.h +++ b/lib/converters/ebcdic500.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic500.h + * @brief IBM-500 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-500 - */ +#ifndef _EBCDIC500_H_ +#define _EBCDIC500_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic500_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic500_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic500_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic500_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic500_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic500_2uni[c]; + return 1; } static const unsigned char ebcdic500_page00[256] = { @@ -117,17 +120,17 @@ static const unsigned char ebcdic500_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic500_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic500_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic500_page00[wc]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic500_page00[wc]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC500_H_ */ diff --git a/lib/ebcdic838.h b/lib/converters/ebcdic838.h similarity index 86% rename from lib/ebcdic838.h rename to lib/converters/ebcdic838.h index c74ac5aa..02841513 100644 --- a/lib/ebcdic838.h +++ b/lib/converters/ebcdic838.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic838.h + * @brief IBM-838 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-838 - */ +#ifndef _EBCDIC838_H_ +#define _EBCDIC838_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic838_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic838_2uni[256] = { 0x0038, 0x0039, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4b, 0x0e4c, 0x009f, }; -static int -ebcdic838_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic838_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic838_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic838_2uni[c]; + return 1; } static const unsigned char ebcdic838_page00[176] = { @@ -121,19 +124,19 @@ static const unsigned char ebcdic838_page0e[96] = { 0xb8, 0xb9, 0x90, 0xa0, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ }; -static int -ebcdic838_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic838_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00b0) - c = ebcdic838_page00[wc]; - else if (wc >= 0x0e00 && wc < 0x0e60) - c = ebcdic838_page0e[wc-0x0e00]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00b0) + c = ebcdic838_page00[wc]; + else if (wc >= 0x0e00 && wc < 0x0e60) + c = ebcdic838_page0e[wc - 0x0e00]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC838_H_ */ diff --git a/lib/ebcdic870.h b/lib/converters/ebcdic870.h similarity index 88% rename from lib/ebcdic870.h rename to lib/converters/ebcdic870.h index eaae81cc..bec18a3f 100644 --- a/lib/ebcdic870.h +++ b/lib/converters/ebcdic870.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic870.h + * @brief IBM-870 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-870 - */ +#ifndef _EBCDIC870_H_ +#define _EBCDIC870_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic870_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic870_2uni[256] = { 0x0038, 0x0039, 0x010e, 0x0170, 0x00dc, 0x0164, 0x00da, 0x009f, }; -static int -ebcdic870_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic870_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic870_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic870_2uni[c]; + return 1; } static const unsigned char ebcdic870_page00[384] = { @@ -140,19 +143,19 @@ static const unsigned char ebcdic870_page02[32] = { 0x80, 0xb0, 0x00, 0x9e, 0x00, 0x64, 0x00, 0x00, /* 0xd8-0xdf */ }; -static int -ebcdic870_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic870_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0180) - c = ebcdic870_page00[wc]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = ebcdic870_page02[wc-0x02c0]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0180) + c = ebcdic870_page00[wc]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = ebcdic870_page02[wc - 0x02c0]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC870_H_ */ diff --git a/lib/ebcdic871.h b/lib/converters/ebcdic871.h similarity index 87% rename from lib/ebcdic871.h rename to lib/converters/ebcdic871.h index 88b54a3c..585316f6 100644 --- a/lib/ebcdic871.h +++ b/lib/converters/ebcdic871.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic871.h + * @brief IBM-871 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-871 - */ +#ifndef _EBCDIC871_H_ +#define _EBCDIC871_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic871_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic871_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic871_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic871_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic871_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic871_2uni[c]; + return 1; } static const unsigned char ebcdic871_page00[256] = { @@ -117,17 +120,17 @@ static const unsigned char ebcdic871_page00[256] = { 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0xc0, 0xdf, /* 0xf8-0xff */ }; -static int -ebcdic871_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic871_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic871_page00[wc]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic871_page00[wc]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC871_H_ */ diff --git a/lib/ebcdic875.h b/lib/converters/ebcdic875.h similarity index 84% rename from lib/ebcdic875.h rename to lib/converters/ebcdic875.h index afb44ab0..8eb6da65 100644 --- a/lib/ebcdic875.h +++ b/lib/converters/ebcdic875.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic875.h + * @brief IBM-875 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-875 - */ +#ifndef _EBCDIC875_H_ +#define _EBCDIC875_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic875_2uni[256] = { /* 0x00 */ @@ -72,18 +78,16 @@ static const unsigned short ebcdic875_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00a9, 0xfffd, 0xfffd, 0x00bb, 0x009f, }; -static int -ebcdic875_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic875_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - unsigned short wc = ebcdic875_2uni[c]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; - } - return RET_ILSEQ; + unsigned char c = *s; + unsigned short wc = ebcdic875_2uni[c]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + return RET_ILSEQ; } static const unsigned char ebcdic875_page00[192] = { @@ -129,21 +133,21 @@ static const unsigned char ebcdic875_page20[16] = { 0xce, 0xde, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ }; -static int -ebcdic875_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic875_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00c0) - c = ebcdic875_page00[wc]; - else if (wc >= 0x0380 && wc < 0x03d0) - c = ebcdic875_page03[wc-0x0380]; - else if (wc >= 0x2010 && wc < 0x2020) - c = ebcdic875_page20[wc-0x2010]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00c0) + c = ebcdic875_page00[wc]; + else if (wc >= 0x0380 && wc < 0x03d0) + c = ebcdic875_page03[wc - 0x0380]; + else if (wc >= 0x2010 && wc < 0x2020) + c = ebcdic875_page20[wc - 0x2010]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC875_H_ */ diff --git a/lib/ebcdic880.h b/lib/converters/ebcdic880.h similarity index 86% rename from lib/ebcdic880.h rename to lib/converters/ebcdic880.h index f545a1ec..05be75bd 100644 --- a/lib/ebcdic880.h +++ b/lib/converters/ebcdic880.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic880.h + * @brief IBM-880 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-880 - */ +#ifndef _EBCDIC880_H_ +#define _EBCDIC880_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic880_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic880_2uni[256] = { 0x0038, 0x0039, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x009f, }; -static int -ebcdic880_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic880_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic880_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic880_2uni[c]; + return 1; } static const unsigned char ebcdic880_page00[176] = { @@ -121,21 +124,21 @@ static const unsigned char ebcdic880_page04[96] = { 0x49, 0x51, 0x52, 0x53, 0x54, 0x00, 0x55, 0x56, /* 0x58-0x5f */ }; -static int -ebcdic880_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic880_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00b0) - c = ebcdic880_page00[wc]; - else if (wc >= 0x0400 && wc < 0x0460) - c = ebcdic880_page04[wc-0x0400]; - else if (wc == 0x2116) - c = 0x58; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00b0) + c = ebcdic880_page00[wc]; + else if (wc >= 0x0400 && wc < 0x0460) + c = ebcdic880_page04[wc - 0x0400]; + else if (wc == 0x2116) + c = 0x58; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC880_H_ */ diff --git a/lib/ebcdic905.h b/lib/converters/ebcdic905.h similarity index 86% rename from lib/ebcdic905.h rename to lib/converters/ebcdic905.h index b133776c..2747cf75 100644 --- a/lib/ebcdic905.h +++ b/lib/converters/ebcdic905.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic905.h + * @brief IBM-905 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-905 - */ +#ifndef _EBCDIC905_H_ +#define _EBCDIC905_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic905_2uni[256] = { /* 0x00 */ @@ -72,18 +78,16 @@ static const unsigned short ebcdic905_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x0022, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic905_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic905_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - unsigned short wc = ebcdic905_2uni[c]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; - } - return RET_ILSEQ; + unsigned char c = *s; + unsigned short wc = ebcdic905_2uni[c]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + return RET_ILSEQ; } static const unsigned char ebcdic905_page00[256] = { @@ -141,21 +145,21 @@ static const unsigned char ebcdic905_page02[8] = { 0x80, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ }; -static int -ebcdic905_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic905_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic905_page00[wc]; - else if (wc >= 0x0108 && wc < 0x0180) - c = ebcdic905_page01[wc-0x0108]; - else if (wc >= 0x02d8 && wc < 0x02e0) - c = ebcdic905_page02[wc-0x02d8]; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic905_page00[wc]; + else if (wc >= 0x0108 && wc < 0x0180) + c = ebcdic905_page01[wc - 0x0108]; + else if (wc >= 0x02d8 && wc < 0x02e0) + c = ebcdic905_page02[wc - 0x02d8]; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC905_H_ */ diff --git a/lib/ebcdic924.h b/lib/converters/ebcdic924.h similarity index 86% rename from lib/ebcdic924.h rename to lib/converters/ebcdic924.h index 373d29e6..c2bc1494 100644 --- a/lib/ebcdic924.h +++ b/lib/converters/ebcdic924.h @@ -1,5 +1,10 @@ +/** + * @file ebcdic924.h + * @brief IBM-924 + * @copyright Copyright (C) 1999-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * IBM-924 - */ +#ifndef _EBCDIC924_H_ +#define _EBCDIC924_H_ + +#include "reiconv_defines.h" static const unsigned short ebcdic924_2uni[256] = { /* 0x00 */ @@ -72,14 +78,11 @@ static const unsigned short ebcdic924_2uni[256] = { 0x0038, 0x0039, 0x00b3, 0x00db, 0x00dc, 0x00d9, 0x00da, 0x009f, }; -static int -ebcdic924_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ebcdic924_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *pwc = (ucs4_t) ebcdic924_2uni[c]; - return 1; + unsigned char c = *s; + *pwc = (ucs4_t)ebcdic924_2uni[c]; + return 1; } static const unsigned char ebcdic924_page00[256] = { @@ -125,21 +128,21 @@ static const unsigned char ebcdic924_page01[48] = { 0xb9, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x9d, 0x00, /* 0x78-0x7f */ }; -static int -ebcdic924_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ebcdic924_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0100) - c = ebcdic924_page00[wc]; - else if (wc >= 0x0150 && wc < 0x0180) - c = ebcdic924_page01[wc-0x0150]; - else if (wc == 0x20ac) - c = 0x9f; - if (c != 0 || wc == 0) { - if (conv->osurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX) - c = swap_x15_x25 (c); - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0100) + c = ebcdic924_page00[wc]; + else if (wc >= 0x0150 && wc < 0x0180) + c = ebcdic924_page01[wc - 0x0150]; + else if (wc == 0x20ac) + c = 0x9f; + if (c != 0 || wc == 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _EBCDIC924_H_ */ diff --git a/lib/converters/euc_cn.h b/lib/converters/euc_cn.h new file mode 100644 index 00000000..74ef8778 --- /dev/null +++ b/lib/converters/euc_cn.h @@ -0,0 +1,87 @@ +/** + * @file euc_cn.h + * @brief EUC-CN + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _EUC_CN_H_ +#define _EUC_CN_H_ + +#include "converters/ascii.h" +#include "converters/gb2312.h" +#include "reiconv_defines.h" + +#include + +static int euc_cn_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + /* Code set 0 (ASCII or GB 1988-89) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (GB 2312-1980) */ + if (c >= 0xa1 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 < 0xff) + { + unsigned char buf[2]; + buf[0] = c - 0x80; + buf[1] = c2 - 0x80; + return gb2312_mbtowc(conv, pwc, buf, 2); + } + else + return RET_ILSEQ; + } + } + return RET_ILSEQ; +} + +static int euc_cn_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[2]; + int ret; + + /* Code set 0 (ASCII or GB 1988-89) */ + ret = ascii_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + /* Code set 1 (GB 2312-1980) */ + ret = gb2312_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0] + 0x80; + r[1] = buf[1] + 0x80; + return 2; + } + + return RET_ILUNI; +} + +#endif /* _EUC_CN_H_ */ diff --git a/lib/converters/euc_jisx0213.h b/lib/converters/euc_jisx0213.h new file mode 100644 index 00000000..9b07b403 --- /dev/null +++ b/lib/converters/euc_jisx0213.h @@ -0,0 +1,319 @@ +/** + * @file euc_jisx0213.h + * @brief EUC-JISX0213 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _EUC_JISX0213_H_ +#define _EUC_JISX0213_H_ + +#include "converters/flushwc.h" // IWYU pragma: keep +#include "converters/jisx0213.h" +#include "reiconv_defines.h" + +#include + +/* The structure of EUC-JISX0213 is as follows: + + 0x00..0x7F: ASCII + + 0x8E{A1..FE}: JISX0201 Katakana, with prefix 0x8E, offset by +0x80. + + 0x8F{A1..FE}{A1..FE}: JISX0213 plane 2, with prefix 0x8F, offset by +0x8080. + + 0x{A1..FE}{A1..FE}: JISX0213 plane 1, offset by +0x8080. + + Note that some JISX0213 characters are not contained in Unicode 3.2 + and are therefore best represented as sequences of Unicode characters. +*/ + +static int euc_jisx0213_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + ucs4_t last_wc = conv->istate; + if (last_wc) + { + /* Output the buffered character. */ + conv->istate = 0; + *pwc = last_wc; + return 0; /* Don't advance the input pointer. */ + } + else + { + unsigned char c = *s; + if (c < 0x80) + { + /* Plain ASCII character. */ + *pwc = (ucs4_t)c; + return 1; + } + else + { + if ((c >= 0xa1 && c <= 0xfe) || c == 0x8e || c == 0x8f) + { + /* Two or three byte character. */ + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 <= 0xfe) + { + if (c == 0x8e) + { + /* Half-width katakana. */ + if (c2 <= 0xdf) + { + *pwc = c2 + 0xfec0; + return 2; + } + } + else + { + ucs4_t wc; + if (c == 0x8f) + { + /* JISX 0213 plane 2. */ + if (n >= 3) + { + unsigned char c3 = s[2]; + wc = jisx0213_to_ucs4(0x200 - 0x80 + c2, c3 ^ 0x80); + } + else + return RET_TOOFEW(0); + } + else + { + /* JISX 0213 plane 1. */ + wc = jisx0213_to_ucs4(0x100 - 0x80 + c, c2 ^ 0x80); + } + if (wc) + { + if (wc < 0x80) + { + /* It's a combining character. */ + ucs4_t wc1 = jisx0213_to_ucs_combining[wc - 1][0]; + ucs4_t wc2 = jisx0213_to_ucs_combining[wc - 1][1]; + /* We cannot output two Unicode characters at once. So, + output the first character and buffer the second one. */ + *pwc = wc1; + conv->istate = wc2; + } + else + *pwc = wc; + return (c == 0x8f ? 3 : 2); + } + } + } + } + else + return RET_TOOFEW(0); + } + return RET_ILSEQ; + } + } +} + +#define euc_jisx0213_flushwc normal_flushwc + +/* Composition tables for each of the relevant combining characters. */ +static const struct +{ + unsigned short base; + unsigned short composed; +} euc_jisx0213_comp_table_data[] = { +#define euc_jisx0213_comp_table02e5_idx 0 +#define euc_jisx0213_comp_table02e5_len 1 + {0xabe4, 0xabe5}, /* 0x12B65 = 0x12B64 U+02E5 */ +#define euc_jisx0213_comp_table02e9_idx (euc_jisx0213_comp_table02e5_idx + euc_jisx0213_comp_table02e5_len) +#define euc_jisx0213_comp_table02e9_len 1 + {0xabe0, 0xabe6}, /* 0x12B66 = 0x12B60 U+02E9 */ +#define euc_jisx0213_comp_table0300_idx (euc_jisx0213_comp_table02e9_idx + euc_jisx0213_comp_table02e9_len) +#define euc_jisx0213_comp_table0300_len 5 + {0xa9dc, 0xabc4}, /* 0x12B44 = 0x1295C U+0300 */ + {0xabb8, 0xabc8}, /* 0x12B48 = 0x12B38 U+0300 */ + {0xabb7, 0xabca}, /* 0x12B4A = 0x12B37 U+0300 */ + {0xabb0, 0xabcc}, /* 0x12B4C = 0x12B30 U+0300 */ + {0xabc3, 0xabce}, /* 0x12B4E = 0x12B43 U+0300 */ +#define euc_jisx0213_comp_table0301_idx (euc_jisx0213_comp_table0300_idx + euc_jisx0213_comp_table0300_len) +#define euc_jisx0213_comp_table0301_len 4 + {0xabb8, 0xabc9}, /* 0x12B49 = 0x12B38 U+0301 */ + {0xabb7, 0xabcb}, /* 0x12B4B = 0x12B37 U+0301 */ + {0xabb0, 0xabcd}, /* 0x12B4D = 0x12B30 U+0301 */ + {0xabc3, 0xabcf}, /* 0x12B4F = 0x12B43 U+0301 */ +#define euc_jisx0213_comp_table309a_idx (euc_jisx0213_comp_table0301_idx + euc_jisx0213_comp_table0301_len) +#define euc_jisx0213_comp_table309a_len 14 + {0xa4ab, 0xa4f7}, /* 0x12477 = 0x1242B U+309A */ + {0xa4ad, 0xa4f8}, /* 0x12478 = 0x1242D U+309A */ + {0xa4af, 0xa4f9}, /* 0x12479 = 0x1242F U+309A */ + {0xa4b1, 0xa4fa}, /* 0x1247A = 0x12431 U+309A */ + {0xa4b3, 0xa4fb}, /* 0x1247B = 0x12433 U+309A */ + {0xa5ab, 0xa5f7}, /* 0x12577 = 0x1252B U+309A */ + {0xa5ad, 0xa5f8}, /* 0x12578 = 0x1252D U+309A */ + {0xa5af, 0xa5f9}, /* 0x12579 = 0x1252F U+309A */ + {0xa5b1, 0xa5fa}, /* 0x1257A = 0x12531 U+309A */ + {0xa5b3, 0xa5fb}, /* 0x1257B = 0x12533 U+309A */ + {0xa5bb, 0xa5fc}, /* 0x1257C = 0x1253B U+309A */ + {0xa5c4, 0xa5fd}, /* 0x1257D = 0x12544 U+309A */ + {0xa5c8, 0xa5fe}, /* 0x1257E = 0x12548 U+309A */ + {0xa6f5, 0xa6f8}, /* 0x12678 = 0x12675 U+309A */ +}; + +static int euc_jisx0213_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + int count = 0; + unsigned short lasttwo = conv->ostate; + + if (lasttwo) + { + /* Attempt to combine the last character with this one. */ + unsigned int idx; + unsigned int len; + + if (wc == 0x02e5) + idx = euc_jisx0213_comp_table02e5_idx, len = euc_jisx0213_comp_table02e5_len; + else if (wc == 0x02e9) + idx = euc_jisx0213_comp_table02e9_idx, len = euc_jisx0213_comp_table02e9_len; + else if (wc == 0x0300) + idx = euc_jisx0213_comp_table0300_idx, len = euc_jisx0213_comp_table0300_len; + else if (wc == 0x0301) + idx = euc_jisx0213_comp_table0301_idx, len = euc_jisx0213_comp_table0301_len; + else if (wc == 0x309a) + idx = euc_jisx0213_comp_table309a_idx, len = euc_jisx0213_comp_table309a_len; + else + goto not_combining; + + do + if (euc_jisx0213_comp_table_data[idx].base == lasttwo) + break; + while (++idx, --len > 0); + + if (len > 0) + { + /* Output the combined character. */ + if (n >= 2) + { + lasttwo = euc_jisx0213_comp_table_data[idx].composed; + r[0] = (lasttwo >> 8) & 0xff; + r[1] = lasttwo & 0xff; + conv->ostate = 0; + return 2; + } + else + return RET_TOOSMALL; + } + + not_combining: + /* Output the buffered character. */ + if (n < 2) + return RET_TOOSMALL; + r[0] = (lasttwo >> 8) & 0xff; + r[1] = lasttwo & 0xff; + r += 2; + count = 2; + } + + if (wc < 0x80) + { + /* Plain ASCII character. */ + if (n > count) + { + r[0] = (unsigned char)wc; + conv->ostate = 0; + return count + 1; + } + else + return RET_TOOSMALL; + } + else if (wc >= 0xff61 && wc <= 0xff9f) + { + /* Half-width katakana. */ + if (n >= count + 2) + { + r[0] = 0x8e; + r[1] = wc - 0xfec0; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + else + { + unsigned short jch = ucs4_to_jisx0213(wc); + if (jch != 0) + { + if (jch & 0x0080) + { + /* A possible match in comp_table_data. We have to buffer it. */ + /* We know it's a JISX 0213 plane 1 character. */ + if (jch & 0x8000) + abort(); + conv->ostate = jch | 0x8080; + return count + 0; + } + if (jch & 0x8000) + { + /* JISX 0213 plane 2. */ + if (n >= count + 3) + { + r[0] = 0x8f; + r[1] = (jch >> 8) | 0x80; + r[2] = (jch & 0xff) | 0x80; + conv->ostate = 0; + return count + 3; + } + else + return RET_TOOSMALL; + } + else + { + /* JISX 0213 plane 1. */ + if (n >= count + 2) + { + r[0] = (jch >> 8) | 0x80; + r[1] = (jch & 0xff) | 0x80; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + } + return RET_ILUNI; + } +} + +static int euc_jisx0213_reset(conv_t conv, unsigned char *r, size_t n) +{ + state_t lasttwo = conv->ostate; + + if (lasttwo) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = (lasttwo >> 8) & 0xff; + r[1] = lasttwo & 0xff; + /* conv->ostate = 0; will be done by the caller */ + return 2; + } + else + return 0; +} + +#endif /* _EUC_JISX0213_H_ */ diff --git a/lib/converters/euc_jp.h b/lib/converters/euc_jp.h new file mode 100644 index 00000000..f1a84a4c --- /dev/null +++ b/lib/converters/euc_jp.h @@ -0,0 +1,238 @@ +/** + * @file euc_jp.h + * @brief EUC-JP + * @copyright Copyright (C) 1999-2001, 2005, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _EUC_JP_H_ +#define _EUC_JP_H_ + +#include "converters/ascii.h" +#include "converters/jisx0201.h" +#include "converters/jisx0208.h" +#include "converters/jisx0212.h" +#include "reiconv_defines.h" +#include + +static int euc_jp_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + /* Code set 0 (ASCII or JIS X 0201-1976 Roman) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (JIS X 0208) */ + if (c >= 0xa1 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + if (c < 0xf5) + { + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 < 0xff) + { + unsigned char buf[2]; + buf[0] = c - 0x80; + buf[1] = c2 - 0x80; + return jisx0208_mbtowc(conv, pwc, buf, 2); + } + else + return RET_ILSEQ; + } + else + { + /* User-defined range. See + * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 < 0xff) + { + *pwc = 0xe000 + 94 * (c - 0xf5) + (c2 - 0xa1); + return 2; + } + else + return RET_ILSEQ; + } + } + /* Code set 2 (half-width katakana) */ + if (c == 0x8e) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 < 0xe0) + { + int ret = jisx0201_mbtowc(conv, pwc, s + 1, n - 1); + if (ret == RET_ILSEQ) + return RET_ILSEQ; + if (ret != 1) + abort(); + return 2; + } + else + return RET_ILSEQ; + } + } + /* Code set 3 (JIS X 0212-1990) */ + if (c == 0x8f) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 < 0xff) + { + if (n < 3) + return RET_TOOFEW(0); + if (c2 < 0xf5) + { + unsigned char c3 = s[2]; + if (c3 >= 0xa1 && c3 < 0xff) + { + unsigned char buf[2]; + int ret; + buf[0] = c2 - 0x80; + buf[1] = c3 - 0x80; + ret = jisx0212_mbtowc(conv, pwc, buf, 2); + if (ret == RET_ILSEQ) + return RET_ILSEQ; + if (ret != 2) + abort(); + return 3; + } + else + return RET_ILSEQ; + } + else + { + /* User-defined range. See + * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ + unsigned char c3 = s[2]; + if (c3 >= 0xa1 && c3 < 0xff) + { + *pwc = 0xe3ac + 94 * (c2 - 0xf5) + (c3 - 0xa1); + return 3; + } + else + return RET_ILSEQ; + } + } + else + return RET_ILSEQ; + } + } + return RET_ILSEQ; +} + +static int euc_jp_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[2]; + int ret; + + /* Code set 0 (ASCII or JIS X 0201-1976 Roman) */ + ret = ascii_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + /* Code set 1 (JIS X 0208) */ + ret = jisx0208_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0] + 0x80; + r[1] = buf[1] + 0x80; + return 2; + } + + /* Code set 2 (half-width katakana) */ + ret = jisx0201_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI && buf[0] >= 0x80) + { + if (ret != 1) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = 0x8e; + r[1] = buf[0]; + return 2; + } + + /* Code set 3 (JIS X 0212-1990) */ + ret = jisx0212_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 3) + return RET_TOOSMALL; + r[0] = 0x8f; + r[1] = buf[0] + 0x80; + r[2] = buf[1] + 0x80; + return 3; + } + + /* Extra compatibility with Shift_JIS. */ + if (wc == 0x00a5) + { + r[0] = 0x5c; + return 1; + } + if (wc == 0x203e) + { + r[0] = 0x7e; + return 1; + } + + /* User-defined range. See + * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ + if (wc >= 0xe000 && wc < 0xe758) + { + if (wc < 0xe3ac) + { + unsigned char c1, c2; + if (n < 2) + return RET_TOOSMALL; + c1 = (unsigned int)(wc - 0xe000) / 94; + c2 = (unsigned int)(wc - 0xe000) % 94; + r[0] = c1 + 0xf5; + r[1] = c2 + 0xa1; + return 2; + } + else + { + unsigned char c1, c2; + if (n < 3) + return RET_TOOSMALL; + c1 = (unsigned int)(wc - 0xe3ac) / 94; + c2 = (unsigned int)(wc - 0xe3ac) % 94; + r[0] = 0x8f; + r[1] = c1 + 0xf5; + r[2] = c2 + 0xa1; + return 3; + } + } + + return RET_ILUNI; +} + +#endif /* _EUC_JP_H_ */ diff --git a/lib/converters/euc_kr.h b/lib/converters/euc_kr.h new file mode 100644 index 00000000..b7330934 --- /dev/null +++ b/lib/converters/euc_kr.h @@ -0,0 +1,88 @@ +/** + * @file euc_kr.h + * @brief EUC-KR + * @copyright Copyright (C) 1999-2001, 2007, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _EUC_KR_H_ +#define _EUC_KR_H_ + +#include "converters/ascii.h" +#include "converters/ksc5601.h" +#include "reiconv_defines.h" +#include + +/* Specification: RFC 1557 */ + +static int euc_kr_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + /* Code set 0 (ASCII or KS C 5636-1993) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (KS C 5601-1992, now KS X 1001:2002) */ + if (c >= 0xa1 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 < 0xff) + { + unsigned char buf[2]; + buf[0] = c - 0x80; + buf[1] = c2 - 0x80; + return ksc5601_mbtowc(conv, pwc, buf, 2); + } + else + return RET_ILSEQ; + } + } + return RET_ILSEQ; +} + +static int euc_kr_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[2]; + int ret; + + /* Code set 0 (ASCII or KS C 5636-1993) */ + ret = ascii_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + /* Code set 1 (KS C 5601-1992, now KS X 1001:2002) */ + ret = ksc5601_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0] + 0x80; + r[1] = buf[1] + 0x80; + return 2; + } + + return RET_ILUNI; +} + +#endif /* _EUC_KR_H_ */ diff --git a/lib/converters/euc_tw.h b/lib/converters/euc_tw.h new file mode 100644 index 00000000..fe4db390 --- /dev/null +++ b/lib/converters/euc_tw.h @@ -0,0 +1,163 @@ +/** + * @file euc_tw.h + * @brief EUC-TW + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _EUC_TW_H_ +#define _EUC_TW_H_ + +#include "converters/ascii.h" +#include "converters/cns11643.h" +#include "converters/cns11643_1.h" +#include "converters/cns11643_15.h" +#include "converters/cns11643_2.h" +#include "converters/cns11643_3.h" +#include "converters/cns11643_4.h" +#include "converters/cns11643_5.h" +#include "converters/cns11643_6.h" +#include "converters/cns11643_7.h" +#include "reiconv_defines.h" + +#include + +static int euc_tw_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + /* Code set 0 (ASCII) */ + if (c < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + /* Code set 1 (CNS 11643-1992 Plane 1) */ + if (c >= 0xa1 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 < 0xff) + { + unsigned char buf[2]; + buf[0] = c - 0x80; + buf[1] = c2 - 0x80; + return cns11643_1_mbtowc(conv, pwc, buf, 2); + } + else + return RET_ILSEQ; + } + } + /* Code set 2 (CNS 11643-1992 Planes 1-16) */ + if (c == 0x8e) + { + if (n < 4) + return RET_TOOFEW(0); + { + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 <= 0xb0) + { + unsigned char c3 = s[2]; + unsigned char c4 = s[3]; + if (c3 >= 0xa1 && c3 < 0xff && c4 >= 0xa1 && c4 < 0xff) + { + unsigned char buf[2]; + int ret; + buf[0] = c3 - 0x80; + buf[1] = c4 - 0x80; + switch (c2 - 0xa0) + { + case 1: + ret = cns11643_1_mbtowc(conv, pwc, buf, 2); + break; + case 2: + ret = cns11643_2_mbtowc(conv, pwc, buf, 2); + break; + case 3: + ret = cns11643_3_mbtowc(conv, pwc, buf, 2); + break; + case 4: + ret = cns11643_4_mbtowc(conv, pwc, buf, 2); + break; + case 5: + ret = cns11643_5_mbtowc(conv, pwc, buf, 2); + break; + case 6: + ret = cns11643_6_mbtowc(conv, pwc, buf, 2); + break; + case 7: + ret = cns11643_7_mbtowc(conv, pwc, buf, 2); + break; + case 15: + ret = cns11643_15_mbtowc(conv, pwc, buf, 2); + break; + default: + return RET_ILSEQ; + } + if (ret == RET_ILSEQ) + return RET_ILSEQ; + if (ret != 2) + abort(); + return 4; + } + } + } + } + return RET_ILSEQ; +} + +static int euc_tw_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[3]; + int ret; + + /* Code set 0 (ASCII) */ + ret = ascii_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + ret = cns11643_wctomb(conv, buf, wc, 3); + if (ret != RET_ILUNI) + { + if (ret != 3) + abort(); + + /* Code set 1 (CNS 11643-1992 Plane 1) */ + if (buf[0] == 1) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[1] + 0x80; + r[1] = buf[2] + 0x80; + return 2; + } + + /* Code set 2 (CNS 11643-1992 Planes 1-16) */ + if (n < 4) + return RET_TOOSMALL; + r[0] = 0x8e; + r[1] = buf[0] + 0xa0; + r[2] = buf[1] + 0x80; + r[3] = buf[2] + 0x80; + return 4; + } + + return RET_ILUNI; +} + +#endif /* _EUC_TW_H_ */ diff --git a/lib/flushwc.h b/lib/converters/flushwc.h similarity index 73% rename from lib/flushwc.h rename to lib/converters/flushwc.h index d3439519..54876a0f 100644 --- a/lib/flushwc.h +++ b/lib/converters/flushwc.h @@ -1,5 +1,10 @@ +/** + * @file flushwc.h + * @brief tput the buffered character. + * @copyright Copyright (C) 2001 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 2001 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,12 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -#ifndef _FLUSHWC_H -#define _FLUSHWC_H +#ifndef _FLUSHWC_H_ +#define _FLUSHWC_H_ + +#include "reiconv_defines.h" static int normal_flushwc (conv_t conv, ucs4_t *pwc) @@ -33,4 +40,4 @@ normal_flushwc (conv_t conv, ucs4_t *pwc) return 0; } -#endif /* _FLUSHWC_H */ +#endif /* _FLUSHWC_H_ */ diff --git a/lib/converters/gb12345.h b/lib/converters/gb12345.h new file mode 100644 index 00000000..06a07ac4 --- /dev/null +++ b/lib/converters/gb12345.h @@ -0,0 +1,73 @@ +/** + * @file gb12345.h + * @brief GB/T 12345-1990 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * GB/T 12345-1990 is a traditional chinese counterpart of GB 2312-1986. + * According to the unicode.org tables: + * 2146 characters have been changed to their traditional counterpart, + * 103 characters have been added, no characters have been removed. + * Therefore we use an auxiliary table, which contains only the changes. + */ + +#ifndef _GB12345_H_ +#define _GB12345_H_ + +#include "converters/gb2312.h" +#include "reiconv_defines.h" + +#include "gb12345ext.h" + +static int gb12345_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + int ret; + + /* The gb12345ext table overrides some entries in the gb2312 table. */ + /* Try the GB12345 extensions -> Unicode table. */ + ret = gb12345ext_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + /* Try the GB2312 -> Unicode table. */ + ret = gb2312_mbtowc(conv, pwc, s, n); + return ret; +} + +static int gb12345_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + int ret; + + /* The gb12345ext table overrides some entries in the gb2312 table. */ + /* Try the Unicode -> GB12345 extensions table. */ + ret = gb12345ext_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + /* Try the Unicode -> GB2312 table, and check that the resulting GB2312 + byte sequence is not overridden by the GB12345 extensions table. */ + ret = gb2312_wctomb(conv, r, wc, n); + if (ret == 2 && gb12345ext_mbtowc(conv, &wc, r, 2) == 2) + return RET_ILUNI; + else + return ret; +} + +#endif /* _GB12345_H_ */ diff --git a/lib/gb12345ext.h b/lib/converters/gb12345ext.h similarity index 98% rename from lib/gb12345ext.h rename to lib/converters/gb12345ext.h index 16fc638a..7b536ecd 100644 --- a/lib/gb12345ext.h +++ b/lib/converters/gb12345ext.h @@ -1,5 +1,10 @@ +/** + * @file gb12345ext.h + * @brief GB/T 12345.1990-0 extensions + * @copyright Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * GB/T 12345.1990-0 extensions - */ +#ifndef _GB12345EXT_H_ +#define _GB12345EXT_H_ + +#include "reiconv_defines.h" static const unsigned short gb12345ext_2uni_page21[12] = { /* 0x21 */ @@ -1757,39 +1763,44 @@ static const Summary16 gb12345ext_uni2indx_pagefe[5] = { { 2247, 0x001f }, }; -static int -gb12345ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int gb12345ext_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc >= 0x0100 && wc < 0x0270) - summary = &gb12345ext_uni2indx_page01[(wc>>4)-0x010]; - else if (wc >= 0x1e00 && wc < 0x1e40) - summary = &gb12345ext_uni2indx_page1e[(wc>>4)-0x1e0]; - else if (wc >= 0x2200 && wc < 0x2230) - summary = &gb12345ext_uni2indx_page22[(wc>>4)-0x220]; - else if (wc >= 0x4e00 && wc < 0x9fa0) - summary = &gb12345ext_uni2indx_page4e[(wc>>4)-0x4e0]; - else if (wc >= 0xfe00 && wc < 0xfe50) - summary = &gb12345ext_uni2indx_pagefe[(wc>>4)-0xfe0]; - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = gb12345ext_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc >= 0x0100 && wc < 0x0270) + summary = &gb12345ext_uni2indx_page01[(wc >> 4) - 0x010]; + else if (wc >= 0x1e00 && wc < 0x1e40) + summary = &gb12345ext_uni2indx_page1e[(wc >> 4) - 0x1e0]; + else if (wc >= 0x2200 && wc < 0x2230) + summary = &gb12345ext_uni2indx_page22[(wc >> 4) - 0x220]; + else if (wc >= 0x4e00 && wc < 0x9fa0) + summary = &gb12345ext_uni2indx_page4e[(wc >> 4) - 0x4e0]; + else if (wc >= 0xfe00 && wc < 0xfe50) + summary = &gb12345ext_uni2indx_pagefe[(wc >> 4) - 0xfe0]; + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = gb12345ext_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _GB12345EXT_H_ */ diff --git a/lib/gb18030_2005.h b/lib/converters/gb18030_2005.h similarity index 60% rename from lib/gb18030_2005.h rename to lib/converters/gb18030_2005.h index 85233a3a..649b3ea1 100644 --- a/lib/gb18030_2005.h +++ b/lib/converters/gb18030_2005.h @@ -1,5 +1,10 @@ +/** + * @file gb18030_2005.h + * @brief GB18030:2005 + * @copyright Copyright (C) 1999-2001, 2005, 2012, 2016, 2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2005, 2012, 2016, 2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,18 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * GB18030:2005 - */ +#ifndef _GB18030_2005_H_ +#define _GB18030_2005_H_ + +#include "converters/ascii.h" +#include "converters/gb18030ext.h" +#include "converters/gb18030uni.h" +#include "converters/gbk.h" +#include "reiconv_defines.h" /* * GB18030, as specified in the GB18030 standard, is an extension of GBK. @@ -181,89 +191,103 @@ * */ -#include "gb18030ext.h" -#include "gb18030uni.h" - -static int -gb18030_2005_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int gb18030_2005_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - int ret; + int ret; - /* Code set 0 (ASCII) */ - if (*s < 0x80) - return ascii_mbtowc(conv,pwc,s,n); + /* Code set 0 (ASCII) */ + if (*s < 0x80) + return ascii_mbtowc(conv, pwc, s, n); - /* Code set 1 (GBK extended) */ - ret = gbk_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; + /* Code set 1 (GBK extended) */ + ret = gbk_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; - ret = gb18030_2005_ext_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; + ret = gb18030_2005_ext_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; - /* Code set 2 (remainder of Unicode U+0000..U+FFFF), including - User-defined characters, two-byte part of range U+E766..U+E864 */ - ret = gb18030_2005_uni_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - /* User-defined characters range U+E000..U+E765 */ - { - unsigned char c1 = s[0]; - if ((c1 >= 0xaa && c1 <= 0xaf) || (c1 >= 0xf8 && c1 <= 0xfe)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 <= 0xfe) { - *pwc = 0xe000 + 94 * (c1 >= 0xf8 ? c1 - 0xf2 : c1 - 0xaa) + (c2 - 0xa1); - return 2; + /* Code set 2 (remainder of Unicode U+0000..U+FFFF), including + User-defined characters, two-byte part of range U+E766..U+E864 */ + ret = gb18030_2005_uni_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + /* User-defined characters range U+E000..U+E765 */ + { + unsigned char c1 = s[0]; + if ((c1 >= 0xaa && c1 <= 0xaf) || (c1 >= 0xf8 && c1 <= 0xfe)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 <= 0xfe) + { + *pwc = 0xe000 + 94 * (c1 >= 0xf8 ? c1 - 0xf2 : c1 - 0xaa) + (c2 - 0xa1); + return 2; + } + } + else + return RET_TOOFEW(0); } - } else - return RET_TOOFEW(0); - } else if (c1 >= 0xa1 && c1 <= 0xa7) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x40 && c2 <= 0xa1 && c2 != 0x7f) { - *pwc = 0xe4c6 + 96 * (c1 - 0xa1) + c2 - (c2 >= 0x80 ? 0x41 : 0x40); - return 2; + else if (c1 >= 0xa1 && c1 <= 0xa7) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x40 && c2 <= 0xa1 && c2 != 0x7f) + { + *pwc = 0xe4c6 + 96 * (c1 - 0xa1) + c2 - (c2 >= 0x80 ? 0x41 : 0x40); + return 2; + } + } + else + return RET_TOOFEW(0); } - } else - return RET_TOOFEW(0); } - } - /* Code set 3 (Unicode U+10000..U+10FFFF) */ - { - unsigned char c1 = s[0]; - if (c1 >= 0x90 && c1 <= 0xe3) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x30 && c2 <= 0x39) { - if (n >= 3) { - unsigned char c3 = s[2]; - if (c3 >= 0x81 && c3 <= 0xfe) { - if (n >= 4) { - unsigned char c4 = s[3]; - if (c4 >= 0x30 && c4 <= 0x39) { - unsigned int i = (((c1 - 0x90) * 10 + (c2 - 0x30)) * 126 + (c3 - 0x81)) * 10 + (c4 - 0x30); - if (i >= 0 && i < 0x100000) { - *pwc = (ucs4_t) (0x10000 + i); - return 4; - } + /* Code set 3 (Unicode U+10000..U+10FFFF) */ + { + unsigned char c1 = s[0]; + if (c1 >= 0x90 && c1 <= 0xe3) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x30 && c2 <= 0x39) + { + if (n >= 3) + { + unsigned char c3 = s[2]; + if (c3 >= 0x81 && c3 <= 0xfe) + { + if (n >= 4) + { + unsigned char c4 = s[3]; + if (c4 >= 0x30 && c4 <= 0x39) + { + unsigned int i = + (((c1 - 0x90) * 10 + (c2 - 0x30)) * 126 + (c3 - 0x81)) * 10 + (c4 - 0x30); + if (i >= 0 && i < 0x100000) + { + *pwc = (ucs4_t)(0x10000 + i); + return 4; + } + } + return RET_ILSEQ; + } + return RET_TOOFEW(0); + } + return RET_ILSEQ; + } + return RET_TOOFEW(0); } return RET_ILSEQ; - } - return RET_TOOFEW(0); } - return RET_ILSEQ; - } - return RET_TOOFEW(0); + return RET_TOOFEW(0); } return RET_ILSEQ; - } - return RET_TOOFEW(0); } - return RET_ILSEQ; - } } static const struct { unsigned short uni[2]; unsigned int charset; } gb18030_2005_pua2charset[35] = { @@ -305,89 +329,111 @@ static const struct { unsigned short uni[2]; unsigned int charset; } gb18030_200 { { 0xe864, 0xe864 }, 0xfea0 }, }; -static int -gb18030_2005_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int gb18030_2005_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - int ret; + int ret; - /* Code set 0 (ASCII) */ - ret = ascii_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; + /* Code set 0 (ASCII) */ + ret = ascii_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; - /* Code set 1 (GBK extended) */ - ret = gbk_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; + /* Code set 1 (GBK extended) */ + ret = gbk_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; - ret = gb18030ext_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; + ret = gb18030ext_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; - /* Code set 2 (remainder of Unicode U+0000..U+FFFF) */ - if (wc >= 0xe000 && wc <= 0xe864) { - if (n >= 2) { - if (wc < 0xe766) { - /* User-defined characters range U+E000..U+E765 */ - if (wc < 0xe4c6) { - unsigned int i = wc - 0xe000; - r[1] = (i % 94) + 0xa1; i = i / 94; - r[0] = (i < 6 ? i + 0xaa : i + 0xf2); - return 2; - } else { - unsigned int i = wc - 0xe4c6; - r[0] = (i / 96) + 0xa1; i = i % 96; - r[1] = i + (i >= 0x3f ? 0x41 : 0x40); - return 2; - } - } else { - /* User-defined characters, two-byte part and 6 four-byte mappings in - range U+E766..U+E864 */ - unsigned int k1 = 0; - unsigned int k2 = 35; - /* Invariant: We know that if wc occurs in Unicode interval in - gb18030_2005_pua2charset, it does so at a k with k1 <= k < k2. */ - while (k1 < k2) { - unsigned int k = (k1 + k2) / 2; - if (wc < gb18030_2005_pua2charset[k].uni[0]) - k2 = k; - else if (wc > gb18030_2005_pua2charset[k].uni[1]) - k1 = k + 1; - else { - unsigned int c = - gb18030_2005_pua2charset[k].charset + (wc - gb18030_2005_pua2charset[k].uni[0]); - if (c < 0x10000) { - r[0] = (c >> 8); - r[1] = c & 0xff; - return 2; - } else { - r[0] = (c >> 24); - r[1] = (c >> 16) & 0xff; - r[2] = (c >> 8) & 0xff; - r[3] = c & 0xff; - return 4; + /* Code set 2 (remainder of Unicode U+0000..U+FFFF) */ + if (wc >= 0xe000 && wc <= 0xe864) + { + if (n >= 2) + { + if (wc < 0xe766) + { + /* User-defined characters range U+E000..U+E765 */ + if (wc < 0xe4c6) + { + unsigned int i = wc - 0xe000; + r[1] = (i % 94) + 0xa1; + i = i / 94; + r[0] = (i < 6 ? i + 0xaa : i + 0xf2); + return 2; + } + else + { + unsigned int i = wc - 0xe4c6; + r[0] = (i / 96) + 0xa1; + i = i % 96; + r[1] = i + (i >= 0x3f ? 0x41 : 0x40); + return 2; + } + } + else + { + /* User-defined characters, two-byte part and 6 four-byte mappings in + range U+E766..U+E864 */ + unsigned int k1 = 0; + unsigned int k2 = 35; + /* Invariant: We know that if wc occurs in Unicode interval in + gb18030_2005_pua2charset, it does so at a k with k1 <= k < k2. */ + while (k1 < k2) + { + unsigned int k = (k1 + k2) / 2; + if (wc < gb18030_2005_pua2charset[k].uni[0]) + k2 = k; + else if (wc > gb18030_2005_pua2charset[k].uni[1]) + k1 = k + 1; + else + { + unsigned int c = + gb18030_2005_pua2charset[k].charset + (wc - gb18030_2005_pua2charset[k].uni[0]); + if (c < 0x10000) + { + r[0] = (c >> 8); + r[1] = c & 0xff; + return 2; + } + else + { + r[0] = (c >> 24); + r[1] = (c >> 16) & 0xff; + r[2] = (c >> 8) & 0xff; + r[3] = c & 0xff; + return 4; + } + } + } } - } } - } - } else - return RET_TOOSMALL; - } - ret = gb18030_2005_uni_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; + else + return RET_TOOSMALL; + } + ret = gb18030_2005_uni_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; - /* Code set 3 (Unicode U+10000..U+10FFFF) */ - if (n >= 4) { - if (wc >= 0x10000 && wc < 0x110000) { - unsigned int i = wc - 0x10000; - r[3] = (i % 10) + 0x30; i = i / 10; - r[2] = (i % 126) + 0x81; i = i / 126; - r[1] = (i % 10) + 0x30; i = i / 10; - r[0] = i + 0x90; - return 4; + /* Code set 3 (Unicode U+10000..U+10FFFF) */ + if (n >= 4) + { + if (wc >= 0x10000 && wc < 0x110000) + { + unsigned int i = wc - 0x10000; + r[3] = (i % 10) + 0x30; + i = i / 10; + r[2] = (i % 126) + 0x81; + i = i / 126; + r[1] = (i % 10) + 0x30; + i = i / 10; + r[0] = i + 0x90; + return 4; + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _GB18030_2005_H_ */ diff --git a/lib/converters/gb18030_2022.h b/lib/converters/gb18030_2022.h new file mode 100644 index 00000000..6e321c27 --- /dev/null +++ b/lib/converters/gb18030_2022.h @@ -0,0 +1,261 @@ +/** + * @file gb18030_2022.h + * @brief GB18030:2022 + * @copyright Copyright (C) 1999-2001, 2005, 2012, 2016, 2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * GB18030, in the version from 2022, is like the version from 2005, + * except that a few mappings to the Unicode PUA have been replaced with + * mappings to assigned Unicode characters. + */ + +#ifndef _GB18030_2022_H_ +#define _GB18030_2022_H_ + +#include "converters/ascii.h" +#include "converters/gb18030ext.h" +#include "converters/gb18030uni.h" +#include "converters/gbk.h" +#include "reiconv_defines.h" + +static int gb18030_2022_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + int ret; + + /* Code set 0 (ASCII) */ + if (*s < 0x80) + return ascii_mbtowc(conv, pwc, s, n); + + /* Code set 1 (GBK extended) */ + ret = gbk_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + + ret = gb18030_2022_ext_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + + /* Code set 2 (remainder of Unicode U+0000..U+FFFF), including + User-defined characters, two-byte part of range U+E766..U+E864 */ + ret = gb18030_2022_uni_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + /* User-defined characters range U+E000..U+E765 */ + { + unsigned char c1 = s[0]; + if ((c1 >= 0xaa && c1 <= 0xaf) || (c1 >= 0xf8 && c1 <= 0xfe)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 <= 0xfe) + { + *pwc = 0xe000 + 94 * (c1 >= 0xf8 ? c1 - 0xf2 : c1 - 0xaa) + (c2 - 0xa1); + return 2; + } + } + else + return RET_TOOFEW(0); + } + else if (c1 >= 0xa1 && c1 <= 0xa7) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x40 && c2 <= 0xa1 && c2 != 0x7f) + { + *pwc = 0xe4c6 + 96 * (c1 - 0xa1) + c2 - (c2 >= 0x80 ? 0x41 : 0x40); + return 2; + } + } + else + return RET_TOOFEW(0); + } + } + + /* Code set 3 (Unicode U+10000..U+10FFFF) */ + { + unsigned char c1 = s[0]; + if (c1 >= 0x90 && c1 <= 0xe3) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x30 && c2 <= 0x39) + { + if (n >= 3) + { + unsigned char c3 = s[2]; + if (c3 >= 0x81 && c3 <= 0xfe) + { + if (n >= 4) + { + unsigned char c4 = s[3]; + if (c4 >= 0x30 && c4 <= 0x39) + { + unsigned int i = + (((c1 - 0x90) * 10 + (c2 - 0x30)) * 126 + (c3 - 0x81)) * 10 + (c4 - 0x30); + if (i >= 0 && i < 0x100000) + { + *pwc = (ucs4_t)(0x10000 + i); + return 4; + } + } + return RET_ILSEQ; + } + return RET_TOOFEW(0); + } + return RET_ILSEQ; + } + return RET_TOOFEW(0); + } + return RET_ILSEQ; + } + return RET_TOOFEW(0); + } + return RET_ILSEQ; + } +} + +static const unsigned short gb18030_2022_pua2charset[23*3] = { +/* Unicode range GB18030 range */ + 0xe766, 0xe76b, 0xa2ab, /*.. 0xa2b0, */ + 0xe76d, 0xe76d, 0xa2e4, + 0xe76e, 0xe76f, 0xa2ef, /*.. 0xa2f0, */ + 0xe770, 0xe771, 0xa2fd, /*.. 0xa2fe, */ + 0xe772, 0xe77c, 0xa4f4, /*.. 0xa4fe, */ + 0xe77d, 0xe784, 0xa5f7, /*.. 0xa5fe, */ + 0xe785, 0xe78c, 0xa6b9, /*.. 0xa6c0, */ + 0xe797, 0xe79f, 0xa6f6, /*.. 0xa6fe, */ + 0xe7a0, 0xe7ae, 0xa7c2, /*.. 0xa7d0, */ + 0xe7af, 0xe7bb, 0xa7f2, /*.. 0xa7fe, */ + 0xe7bc, 0xe7c6, 0xa896, /*.. 0xa8a0, */ + 0xe7c9, 0xe7cc, 0xa8c1, /*.. 0xa8c4, */ + 0xe7cd, 0xe7e1, 0xa8ea, /*.. 0xa8fe, */ + 0xe7e2, 0xe7e2, 0xa958, + 0xe7e3, 0xe7e3, 0xa95b, + 0xe7e4, 0xe7e6, 0xa95d, /*.. 0xa95f, */ + 0xe7f4, 0xe800, 0xa997, /*.. 0xa9a3, */ + 0xe801, 0xe80f, 0xa9f0, /*.. 0xa9fe, */ + 0xe810, 0xe814, 0xd7fa, /*.. 0xd7fe, */ + 0xe816, 0xe818, 0xfe51, /*.. 0xfe53, */ + 0xe831, 0xe831, 0xfe6c, + 0xe83b, 0xe83b, 0xfe76, + 0xe855, 0xe855, 0xfe91, +}; + +static int gb18030_2022_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + int ret; + + /* Code set 0 (ASCII) */ + ret = ascii_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + /* Code set 1 (GBK extended) */ + ret = gbk_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + ret = gb18030ext_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + /* Code set 2 (remainder of Unicode U+0000..U+FFFF) */ + if (wc >= 0xe000 && wc <= 0xe864) + { + if (n >= 2) + { + if (wc < 0xe766) + { + /* User-defined characters range U+E000..U+E765 */ + if (wc < 0xe4c6) + { + unsigned int i = wc - 0xe000; + r[1] = (i % 94) + 0xa1; + i = i / 94; + r[0] = (i < 6 ? i + 0xaa : i + 0xf2); + return 2; + } + else + { + unsigned int i = wc - 0xe4c6; + r[0] = (i / 96) + 0xa1; + i = i % 96; + r[1] = i + (i >= 0x3f ? 0x41 : 0x40); + return 2; + } + } + else + { + /* User-defined characters, two-byte part of range U+E766..U+E864 */ + unsigned int k1 = 0; + unsigned int k2 = 23; + /* Invariant: We know that if wc occurs in Unicode interval in + gb18030_2022_pua2charset, it does so at a k with k1 <= k < k2. */ + while (k1 < k2) + { + unsigned int k = (k1 + k2) / 2; + if (wc < gb18030_2022_pua2charset[k * 3 + 0]) + k2 = k; + else if (wc > gb18030_2022_pua2charset[k * 3 + 1]) + k1 = k + 1; + else + { + unsigned short c = + gb18030_2022_pua2charset[k * 3 + 2] + (wc - gb18030_2022_pua2charset[k * 3 + 0]); + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + } + } + else + return RET_TOOSMALL; + } + ret = gb18030_2022_uni_wctomb(conv, r, wc, n); + if (ret != RET_ILUNI) + return ret; + + /* Code set 3 (Unicode U+10000..U+10FFFF) */ + if (n >= 4) + { + if (wc >= 0x10000 && wc < 0x110000) + { + unsigned int i = wc - 0x10000; + r[3] = (i % 10) + 0x30; + i = i / 10; + r[2] = (i % 126) + 0x81; + i = i / 126; + r[1] = (i % 10) + 0x30; + i = i / 10; + r[0] = i + 0x90; + return 4; + } + return RET_ILUNI; + } + return RET_TOOSMALL; +} + +#endif /* _GB18030_2022_H_ */ diff --git a/lib/converters/gb18030ext.h b/lib/converters/gb18030ext.h new file mode 100644 index 00000000..0aa93e9a --- /dev/null +++ b/lib/converters/gb18030ext.h @@ -0,0 +1,449 @@ +/** + * @file gb18030ext.h + * @brief GB18030 two-byte extension + * @copyright Copyright (C) 1999-2001, 2005, 2011, 2016, 2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _GB18030EXT_H_ +#define _GB18030EXT_H_ + +#include "reiconv_defines.h" + +static const unsigned short gb18030ext_2uni_pagea9[13] = { + /* 0xa9 */ + 0x303e, 0x2ff0, 0x2ff1, 0x2ff2, 0x2ff3, 0x2ff4, 0x2ff5, 0x2ff6, + 0x2ff7, 0x2ff8, 0x2ff9, 0x2ffa, 0x2ffb, +}; +static const unsigned int gb18030_2005_ext_2uni_pagefe[96] = { + /* 0xfe */ + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0x2e81, 0x20087, 0x20089, 0x200cc, 0x2e84, 0x3473, 0x3447, 0x2e88, + 0x2e8b, 0x9fb4, 0x359e, 0x361a, 0x360e, 0x2e8c, 0x2e97, 0x396e, + 0x3918, 0x9fb5, 0x39cf, 0x39df, 0x3a73, 0x39d0, 0x9fb6, 0x9fb7, + 0x3b4e, 0x3c6e, 0x3ce0, 0x2ea7, 0x215d7, 0x9fb8, 0x2eaa, 0x4056, + 0x415f, 0x2eae, 0x4337, 0x2eb3, 0x2eb6, 0x2eb7, 0x2298f, 0x43b1, + 0x43ac, 0x2ebb, 0x43dd, 0x44d6, 0x4661, 0x464c, 0x9fb9, 0x4723, + 0x4729, 0x477c, 0x478d, 0x2eca, 0x4947, 0x497a, 0x497d, 0x4982, + 0x4983, 0x4985, 0x4986, 0x499f, 0x499b, 0x49b7, 0x49b6, 0x9fba, + 0x241fe, 0x4ca3, 0x4c9f, 0x4ca0, 0x4ca1, 0x4c77, 0x4ca2, 0x4d13, + 0x4d14, 0x4d15, 0x4d16, 0x4d17, 0x4d18, 0x4d19, 0x4dae, 0x9fbb, +}; + +static const unsigned short gb18030_2022_ext_2uni_pagefe[96] = { + /* 0xfe */ + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, + 0x2e81, 0xe816, 0xe817, 0xe818, 0x2e84, 0x3473, 0x3447, 0x2e88, + 0x2e8b, 0x9fb4, 0x359e, 0x361a, 0x360e, 0x2e8c, 0x2e97, 0x396e, + 0x3918, 0x9fb5, 0x39cf, 0x39df, 0x3a73, 0x39d0, 0x9fb6, 0x9fb7, + 0x3b4e, 0x3c6e, 0x3ce0, 0x2ea7, 0xe831, 0x9fb8, 0x2eaa, 0x4056, + 0x415f, 0x2eae, 0x4337, 0x2eb3, 0x2eb6, 0x2eb7, 0xe83b, 0x43b1, + 0x43ac, 0x2ebb, 0x43dd, 0x44d6, 0x4661, 0x464c, 0x9fb9, 0x4723, + 0x4729, 0x477c, 0x478d, 0x2eca, 0x4947, 0x497a, 0x497d, 0x4982, + 0x4983, 0x4985, 0x4986, 0x499f, 0x499b, 0x49b7, 0x49b6, 0x9fba, + 0xe855, 0x4ca3, 0x4c9f, 0x4ca0, 0x4ca1, 0x4c77, 0x4ca2, 0x4d13, + 0x4d14, 0x4d15, 0x4d16, 0x4d17, 0x4d18, 0x4d19, 0x4dae, 0x9fbb, +}; + +static int gb18030_2005_ext_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c1 = s[0]; + if ((c1 == 0xa2) || (c1 >= 0xa4 && c1 <= 0xa9) || (c1 == 0xd7) || (c1 == 0xfe)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xff)) + { + unsigned int i = 190 * (c1 - 0x81) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); + unsigned int wc = 0xfffd; + switch (c1) + { + case 0xa2: + if (i >= 6376 && i <= 6381) /* 0xA2AB..0xA2B0 */ + wc = 0xe766 + (i - 6376); + else if (i == 6432) /* 0xA2E3 */ + wc = 0x20ac; + else if (i == 6433) /* 0xA2E4 */ + wc = 0xe76d; + else if (i >= 6444 && i <= 6445) /* 0xA2EF..0xA2F0 */ + wc = 0xe76e + (i - 6444); + else if (i >= 6458 && i <= 6459) /* 0xA2FD..0xA2FE */ + wc = 0xe770 + (i - 6458); + break; + case 0xa4: + if (i >= 6829 && i <= 6839) /* 0xA4F4..0xA4FE */ + wc = 0xe772 + (i - 6829); + break; + case 0xa5: + if (i >= 7022 && i <= 7029) /* 0xA5F7..0xA5FE */ + wc = 0xe77d + (i - 7022); + break; + case 0xa6: + if (i >= 7150 && i <= 7157) /* 0xA6B9..0xA6C0 */ + wc = 0xe785 + (i - 7150); + else if (i >= 7183 && i <= 7184) /* 0xA6DA..0xA6DB */ + wc = 0xfe12 - (i - 7183); + else if (i >= 7182 && i <= 7190) /* 0xA6D9..0xA6DF */ + wc = 0xfe10 + (i - 7182); + else if (i >= 7201 && i <= 7202) /* 0xA6EC..0xA6ED */ + wc = 0xfe17 + (i - 7201); + else if (i == 7208) /* 0xA6F3 */ + wc = 0xfe19; + else if (i >= 7211 && i <= 7219) /* 0xA6F6..0xA6FE */ + wc = 0xe797 + (i - 7211); + break; + case 0xa7: + if (i >= 7349 && i <= 7363) /* 0xA7C2..0xA7D0 */ + wc = 0xe7a0 + (i - 7349); + else if (i >= 7397 && i <= 7409) /* 0xA7F2..0xA7FE */ + wc = 0xe7af + (i - 7397); + break; + case 0xa8: + if (i >= 7495 && i <= 7505) /* 0xA896..0xA8A0 */ + wc = 0xe7bc + (i - 7495); + else if (i == 7533) /* 0xA8BC */ + wc = 0x1e3f; + else if (i == 7536) /* 0xA8BF */ + wc = 0x01f9; + else if (i >= 7538 && i <= 7541) /* 0xA8C1..0xA8C4 */ + wc = 0xe7c9 + (i - 7538); + else if (i >= 7579 && i <= 7599) /* 0xA8EA..0xA8FE */ + wc = 0xe7cd + (i - 7579); + break; + case 0xa9: + if (i == 7624) /* 0xA958 */ + wc = 0xe7e2; + else if (i == 7627) /* 0xA95B */ + wc = 0xe7e3; + else if (i >= 7629 && i <= 7631) /* 0xA95D..0xA95F */ + wc = 0xe7e4 + (i - 7629); + else if (i >= 7672 && i < 7685) /* 0xA989..0xA995 */ + wc = gb18030ext_2uni_pagea9[i - 7672]; + else if (i >= 7686 && i <= 7698) /* 0xA997..0xA9A3 */ + wc = 0xe7f4 + (i - 7686); + else if (i >= 7775 && i <= 7789) /* 0xA9F0..0xA9FE */ + wc = 0xe801 + (i - 7775); + break; + case 0xd7: + if (i >= 16525 && i <= 16529) /* 0xD7FA..0xD7FE */ + wc = 0xe810 + (i - 16525); + break; + case 0xfe: + if (i < 23846) + wc = gb18030_2005_ext_2uni_pagefe[i - 23750]; + break; + default: + break; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; + } + return RET_TOOFEW(0); + } + return RET_ILSEQ; +} + +static int gb18030_2022_ext_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c1 = s[0]; + if ((c1 == 0xa2) || (c1 >= 0xa4 && c1 <= 0xa9) || (c1 == 0xd7) || (c1 == 0xfe)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xff)) + { + unsigned int i = 190 * (c1 - 0x81) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); + unsigned int wc = 0xfffd; + switch (c1) + { + case 0xa2: + if (i >= 6376 && i <= 6381) /* 0xA2AB..0xA2B0 */ + wc = 0xe766 + (i - 6376); + else if (i == 6432) /* 0xA2E3 */ + wc = 0x20ac; + else if (i == 6433) /* 0xA2E4 */ + wc = 0xe76d; + else if (i >= 6444 && i <= 6445) /* 0xA2EF..0xA2F0 */ + wc = 0xe76e + (i - 6444); + else if (i >= 6458 && i <= 6459) /* 0xA2FD..0xA2FE */ + wc = 0xe770 + (i - 6458); + break; + case 0xa4: + if (i >= 6829 && i <= 6839) /* 0xA4F4..0xA4FE */ + wc = 0xe772 + (i - 6829); + break; + case 0xa5: + if (i >= 7022 && i <= 7029) /* 0xA5F7..0xA5FE */ + wc = 0xe77d + (i - 7022); + break; + case 0xa6: + if (i >= 7150 && i <= 7157) /* 0xA6B9..0xA6C0 */ + wc = 0xe785 + (i - 7150); + else if (i >= 7183 && i <= 7184) /* 0xA6DA..0xA6DB */ + wc = 0xfe12 - (i - 7183); + else if (i >= 7182 && i <= 7190) /* 0xA6D9..0xA6DF */ + wc = 0xfe10 + (i - 7182); + else if (i >= 7201 && i <= 7202) /* 0xA6EC..0xA6ED */ + wc = 0xfe17 + (i - 7201); + else if (i == 7208) /* 0xA6F3 */ + wc = 0xfe19; + else if (i >= 7211 && i <= 7219) /* 0xA6F6..0xA6FE */ + wc = 0xe797 + (i - 7211); + break; + case 0xa7: + if (i >= 7349 && i <= 7363) /* 0xA7C2..0xA7D0 */ + wc = 0xe7a0 + (i - 7349); + else if (i >= 7397 && i <= 7409) /* 0xA7F2..0xA7FE */ + wc = 0xe7af + (i - 7397); + break; + case 0xa8: + if (i >= 7495 && i <= 7505) /* 0xA896..0xA8A0 */ + wc = 0xe7bc + (i - 7495); + else if (i == 7533) /* 0xA8BC */ + wc = 0x1e3f; + else if (i == 7536) /* 0xA8BF */ + wc = 0x01f9; + else if (i >= 7538 && i <= 7541) /* 0xA8C1..0xA8C4 */ + wc = 0xe7c9 + (i - 7538); + else if (i >= 7579 && i <= 7599) /* 0xA8EA..0xA8FE */ + wc = 0xe7cd + (i - 7579); + break; + case 0xa9: + if (i == 7624) /* 0xA958 */ + wc = 0xe7e2; + else if (i == 7627) /* 0xA95B */ + wc = 0xe7e3; + else if (i >= 7629 && i <= 7631) /* 0xA95D..0xA95F */ + wc = 0xe7e4 + (i - 7629); + else if (i >= 7672 && i < 7685) /* 0xA989..0xA995 */ + wc = gb18030ext_2uni_pagea9[i - 7672]; + else if (i >= 7686 && i <= 7698) /* 0xA997..0xA9A3 */ + wc = 0xe7f4 + (i - 7686); + else if (i >= 7775 && i <= 7789) /* 0xA9F0..0xA9FE */ + wc = 0xe801 + (i - 7775); + break; + case 0xd7: + if (i >= 16525 && i <= 16529) /* 0xD7FA..0xD7FE */ + wc = 0xe810 + (i - 16525); + break; + case 0xfe: + if (i < 23846) + wc = gb18030_2022_ext_2uni_pagefe[i - 23750]; + break; + default: + break; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; + } + return RET_TOOFEW(0); + } + return RET_ILSEQ; +} + +static const unsigned short gb18030ext_page2e[80] = { + 0x0000, 0xfe50, 0x0000, 0x0000, 0xfe54, 0x0000, 0x0000, 0x0000, /*0x80-0x87*/ + 0xfe57, 0x0000, 0x0000, 0xfe58, 0xfe5d, 0x0000, 0x0000, 0x0000, /*0x88-0x8f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe5e, /*0x90-0x97*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x98-0x9f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe6b, /*0xa0-0xa7*/ + 0x0000, 0x0000, 0xfe6e, 0x0000, 0x0000, 0x0000, 0xfe71, 0x0000, /*0xa8-0xaf*/ + 0x0000, 0x0000, 0x0000, 0xfe73, 0x0000, 0x0000, 0xfe74, 0xfe75, /*0xb0-0xb7*/ + 0x0000, 0x0000, 0x0000, 0xfe79, 0x0000, 0x0000, 0x0000, 0x0000, /*0xb8-0xbf*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xc0-0xc7*/ + 0x0000, 0x0000, 0xfe84, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xc8-0xcf*/ +}; +static const unsigned short gb18030ext_page2f[16] = { + 0xa98a, 0xa98b, 0xa98c, 0xa98d, 0xa98e, 0xa98f, 0xa990, 0xa991, /*0xf0-0xf7*/ + 0xa992, 0xa993, 0xa994, 0xa995, 0x0000, 0x0000, 0x0000, 0x0000, /*0xf8-0xff*/ +}; +static const unsigned short gb18030ext_page34[56] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe56, /*0x40-0x47*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x48-0x4f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x50-0x57*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x58-0x5f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x60-0x67*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x68-0x6f*/ + 0x0000, 0x0000, 0x0000, 0xfe55, 0x0000, 0x0000, 0x0000, 0x0000, /*0x70-0x77*/ +}; +static const unsigned short gb18030ext_page36[24] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe5c, 0x0000, /*0x08-0x0f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x10-0x17*/ + 0x0000, 0x0000, 0xfe5b, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x18-0x1f*/ +}; +static const unsigned short gb18030ext_page39[24] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe62, /*0xc8-0xcf*/ + 0xfe65, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xd0-0xd7*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe63, /*0xd8-0xdf*/ +}; +static const unsigned short gb18030ext_page43[56] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0xfe78, 0x0000, 0x0000, 0x0000, /*0xa8-0xaf*/ + 0x0000, 0xfe77, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xb0-0xb7*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xb8-0xbf*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xc0-0xc7*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xc8-0xcf*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xd0-0xd7*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe7a, 0x0000, 0x0000, /*0xd8-0xdf*/ +}; +static const unsigned short gb18030ext_page46[32] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0xfe7d, 0x0000, 0x0000, 0x0000, /*0x48-0x4f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x50-0x57*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x58-0x5f*/ + 0x0000, 0xfe7c, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x60-0x67*/ +}; +static const unsigned short gb18030ext_page47_1[16] = { + 0x0000, 0x0000, 0x0000, 0xfe80, 0x0000, 0x0000, 0x0000, 0x0000, /*0x20-0x27*/ + 0x0000, 0xfe81, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x28-0x2f*/ +}; +static const unsigned short gb18030ext_page47_2[24] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0xfe82, 0x0000, 0x0000, 0x0000, /*0x78-0x7f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x80-0x87*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe83, 0x0000, 0x0000, /*0x88-0x8f*/ +}; +static const unsigned short gb18030ext_page49[120] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe85, /*0x40-0x47*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x48-0x4f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x50-0x57*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x58-0x5f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x60-0x67*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x68-0x6f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x70-0x77*/ + 0x0000, 0x0000, 0xfe86, 0x0000, 0x0000, 0xfe87, 0x0000, 0x0000, /*0x78-0x7f*/ + 0x0000, 0x0000, 0xfe88, 0xfe89, 0x0000, 0xfe8a, 0xfe8b, 0x0000, /*0x80-0x87*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x88-0x8f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x90-0x97*/ + 0x0000, 0x0000, 0x0000, 0xfe8d, 0x0000, 0x0000, 0x0000, 0xfe8c, /*0x98-0x9f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xa0-0xa7*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xa8-0xaf*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe8f, 0xfe8e, /*0xb0-0xb7*/ +}; +static const unsigned short gb18030ext_page4c[56] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe96, /*0x70-0x77*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x78-0x7f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x80-0x87*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x88-0x8f*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x90-0x97*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe93, /*0x98-0x9f*/ + 0xfe94, 0xfe95, 0xfe97, 0xfe92, 0x0000, 0x0000, 0x0000, 0x0000, /*0xa0-0xa7*/ +}; +static const unsigned short gb18030ext_page4d[16] = { + 0x0000, 0x0000, 0x0000, 0xfe98, 0xfe99, 0xfe9a, 0xfe9b, 0xfe9c, /*0x10-0x17*/ + 0xfe9d, 0xfe9e, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x18-0x1f*/ +}; +static const unsigned short gb18030ext_page9f[16] = { + 0x0000, 0x0000, 0x0000, 0x0000, 0xfe59, 0xfe61, 0xfe66, 0xfe67, /*0xb0-0xb7*/ + 0xfe6d, 0xfe7e, 0xfe90, 0xfea0, 0x0000, 0x0000, 0x0000, 0x0000, /*0xb8-0xbf*/ +}; +static const unsigned short gb18030ext_pagefe[16] = { + 0xa6d9, 0xa6db, 0xa6da, 0xa6dc, 0xa6dd, 0xa6de, 0xa6df, 0xa6ec, /*0x10-0x17*/ + 0xa6ed, 0xa6f3, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x18-0x1f*/ +}; + +static int gb18030ext_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (n >= 2) + { + unsigned short c = 0; + if (wc == 0x01f9) + c = 0xa8bf; + else if (wc == 0x1e3f) + c = 0xa8bc; + else if (wc == 0x20ac) + c = 0xa2e3; + else if (wc >= 0x2e80 && wc < 0x2ed0) + c = gb18030ext_page2e[wc - 0x2e80]; + else if (wc >= 0x2ff0 && wc < 0x3000) + c = gb18030ext_page2f[wc - 0x2ff0]; + else if (wc == 0x303e) + c = 0xa989; + else if (wc >= 0x3440 && wc < 0x3478) + c = gb18030ext_page34[wc - 0x3440]; + else if (wc == 0x359e) + c = 0xfe5a; + else if (wc >= 0x3608 && wc < 0x3620) + c = gb18030ext_page36[wc - 0x3608]; + else if (wc == 0x3918) + c = 0xfe60; + else if (wc == 0x396e) + c = 0xfe5f; + else if (wc >= 0x39c8 && wc < 0x39e0) + c = gb18030ext_page39[wc - 0x39c8]; + else if (wc == 0x3a73) + c = 0xfe64; + else if (wc == 0x3b4e) + c = 0xfe68; + else if (wc == 0x3c6e) + c = 0xfe69; + else if (wc == 0x3ce0) + c = 0xfe6a; + else if (wc == 0x4056) + c = 0xfe6f; + else if (wc == 0x415f) + c = 0xfe70; + else if (wc == 0x4337) + c = 0xfe72; + else if (wc >= 0x43a8 && wc < 0x43e0) + c = gb18030ext_page43[wc - 0x43a8]; + else if (wc == 0x44d6) + c = 0xfe7b; + else if (wc >= 0x4648 && wc < 0x4668) + c = gb18030ext_page46[wc - 0x4648]; + else if (wc >= 0x4720 && wc < 0x4730) + c = gb18030ext_page47_1[wc - 0x4720]; + else if (wc >= 0x4778 && wc < 0x4790) + c = gb18030ext_page47_2[wc - 0x4778]; + else if (wc >= 0x4940 && wc < 0x49b8) + c = gb18030ext_page49[wc - 0x4940]; + else if (wc >= 0x4c70 && wc < 0x4ca8) + c = gb18030ext_page4c[wc - 0x4c70]; + else if (wc >= 0x4d10 && wc < 0x4d20) + c = gb18030ext_page4d[wc - 0x4d10]; + else if (wc == 0x4dae) + c = 0xfe9f; + else if (wc >= 0x9fb4 && wc < 0x9fbc) + c = gb18030ext_page9f[wc - 0x9fb0]; + else if (wc >= 0xfe10 && wc < 0xfe1a) + c = gb18030ext_pagefe[wc - 0xfe10]; + if (c != 0) + { + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + return RET_ILUNI; + } + return RET_TOOSMALL; +} + +#endif /* _GB18030EXT_H_ */ diff --git a/lib/gb18030uni.h b/lib/converters/gb18030uni.h similarity index 54% rename from lib/gb18030uni.h rename to lib/converters/gb18030uni.h index 5a880700..517364c6 100644 --- a/lib/gb18030uni.h +++ b/lib/converters/gb18030uni.h @@ -1,5 +1,10 @@ +/** + * @file gb18030uni.h + * @brief GB18030 four-byte extension + * @copyright Copyright (C) 1999-2001, 2005, 2012, 2016, 2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2005, 2012, 2016, 2023 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * GB18030 four-byte extension - */ +#ifndef _GB18030UNI_H_ +#define _GB18030UNI_H_ + +#include "reiconv_defines.h" static const unsigned short gb18030uni_charset2uni_ranges[412] = { 0x0000, 0x0023, 0x0024, 0x0025, 0x0026, 0x002c, 0x002d, 0x0031, @@ -174,114 +180,142 @@ static const unsigned short gb18030_2022_charset2uni_pua2[10] = { 0xe78d, 0xe78f, 0xe78e, 0xe790, 0xe791, 0xe792, 0xe793, 0xe794, 0xe795, 0xe796 }; -static int -gb18030_2005_uni_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int gb18030_2005_uni_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if (c1 >= 0x81 && c1 <= 0x84) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x30 && c2 <= 0x39) { - if (n >= 3) { - unsigned char c3 = s[2]; - if (c3 >= 0x81 && c3 <= 0xfe) { - if (n >= 4) { - unsigned char c4 = s[3]; - if (c4 >= 0x30 && c4 <= 0x39) { - unsigned int i = (((c1 - 0x81) * 10 + (c2 - 0x30)) * 126 + (c3 - 0x81)) * 10 + (c4 - 0x30); - if (i >= 0 && i <= 39419) { - if (i == 7457) { - *pwc = 0xe7c7; - } else { - unsigned int k1 = 0; - unsigned int k2 = 205; - while (k1 < k2) { - unsigned int k = (k1 + k2) / 2; - if (i <= gb18030uni_charset2uni_ranges[2*k+1]) - k2 = k; - else if (i >= gb18030uni_charset2uni_ranges[2*k+2]) - k1 = k + 1; - else - return RET_ILSEQ; - } + unsigned char c1 = s[0]; + if (c1 >= 0x81 && c1 <= 0x84) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x30 && c2 <= 0x39) + { + if (n >= 3) + { + unsigned char c3 = s[2]; + if (c3 >= 0x81 && c3 <= 0xfe) { - unsigned int diff = gb18030uni_ranges[k1]; - *pwc = (ucs4_t) (i + diff); + if (n >= 4) + { + unsigned char c4 = s[3]; + if (c4 >= 0x30 && c4 <= 0x39) + { + unsigned int i = + (((c1 - 0x81) * 10 + (c2 - 0x30)) * 126 + (c3 - 0x81)) * 10 + (c4 - 0x30); + if (i >= 0 && i <= 39419) + { + if (i == 7457) + { + *pwc = 0xe7c7; + } + else + { + unsigned int k1 = 0; + unsigned int k2 = 205; + while (k1 < k2) + { + unsigned int k = (k1 + k2) / 2; + if (i <= gb18030uni_charset2uni_ranges[2 * k + 1]) + k2 = k; + else if (i >= gb18030uni_charset2uni_ranges[2 * k + 2]) + k1 = k + 1; + else + return RET_ILSEQ; + } + { + unsigned int diff = gb18030uni_ranges[k1]; + *pwc = (ucs4_t)(i + diff); + } + } + return 4; + } + } + return RET_ILSEQ; + } + return RET_TOOFEW(0); } - } - return 4; + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } return RET_TOOFEW(0); - } - return RET_ILSEQ; } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } -static int -gb18030_2022_uni_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int gb18030_2022_uni_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if (c1 >= 0x81 && c1 <= 0x84) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x30 && c2 <= 0x39) { - if (n >= 3) { - unsigned char c3 = s[2]; - if (c3 >= 0x81 && c3 <= 0xfe) { - if (n >= 4) { - unsigned char c4 = s[3]; - if (c4 >= 0x30 && c4 <= 0x39) { - unsigned int i = (((c1 - 0x81) * 10 + (c2 - 0x30)) * 126 + (c3 - 0x81)) * 10 + (c4 - 0x30); - if (i >= 0 && i <= 39419) { - if (i == 7457) { - *pwc = 0xe7c7; - } else if (i >= 19057 && i <= 19064) { - *pwc = gb18030_2022_charset2uni_pua1[i-19057]; - } else if (i >= 39076 && i <= 39085) { - *pwc = gb18030_2022_charset2uni_pua2[i-39076]; - } else { - unsigned int k1 = 0; - unsigned int k2 = 205; - while (k1 < k2) { - unsigned int k = (k1 + k2) / 2; - if (i <= gb18030uni_charset2uni_ranges[2*k+1]) - k2 = k; - else if (i >= gb18030uni_charset2uni_ranges[2*k+2]) - k1 = k + 1; - else - return RET_ILSEQ; - } + unsigned char c1 = s[0]; + if (c1 >= 0x81 && c1 <= 0x84) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x30 && c2 <= 0x39) + { + if (n >= 3) + { + unsigned char c3 = s[2]; + if (c3 >= 0x81 && c3 <= 0xfe) { - unsigned int diff = gb18030uni_ranges[k1]; - *pwc = (ucs4_t) (i + diff); + if (n >= 4) + { + unsigned char c4 = s[3]; + if (c4 >= 0x30 && c4 <= 0x39) + { + unsigned int i = + (((c1 - 0x81) * 10 + (c2 - 0x30)) * 126 + (c3 - 0x81)) * 10 + (c4 - 0x30); + if (i >= 0 && i <= 39419) + { + if (i == 7457) + { + *pwc = 0xe7c7; + } + else if (i >= 19057 && i <= 19064) + { + *pwc = gb18030_2022_charset2uni_pua1[i - 19057]; + } + else if (i >= 39076 && i <= 39085) + { + *pwc = gb18030_2022_charset2uni_pua2[i - 39076]; + } + else + { + unsigned int k1 = 0; + unsigned int k2 = 205; + while (k1 < k2) + { + unsigned int k = (k1 + k2) / 2; + if (i <= gb18030uni_charset2uni_ranges[2 * k + 1]) + k2 = k; + else if (i >= gb18030uni_charset2uni_ranges[2 * k + 2]) + k1 = k + 1; + else + return RET_ILSEQ; + } + { + unsigned int diff = gb18030uni_ranges[k1]; + *pwc = (ucs4_t)(i + diff); + } + } + return 4; + } + } + return RET_ILSEQ; + } + return RET_TOOFEW(0); } - } - return 4; + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } return RET_TOOFEW(0); - } - return RET_ILSEQ; } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned char gb18030_2022_uni2charset_pua1[71] = { @@ -297,95 +331,120 @@ static const unsigned char gb18030_2022_uni2charset_pua2[10] = { 0, 2, 1, 3, 4, 5, 6, 7, 8, 9 }; -static int -gb18030_2005_uni_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int gb18030_2005_uni_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 4) { - unsigned int i; - if (wc >= 0x0080 && wc <= 0xffff) { - if (wc == 0xe7c7) { - i = 7457; - } else { - unsigned int k1 = 0; - unsigned int k2 = 205; - i = wc; - while (k1 < k2) { - unsigned int k = (k1 + k2) / 2; - if (i <= gb18030uni_uni2charset_ranges[2*k+1]) - k2 = k; - else if (i >= gb18030uni_uni2charset_ranges[2*k+2]) - k1 = k + 1; - else - return RET_ILUNI; + if (n >= 4) + { + unsigned int i; + if (wc >= 0x0080 && wc <= 0xffff) + { + if (wc == 0xe7c7) + { + i = 7457; + } + else + { + unsigned int k1 = 0; + unsigned int k2 = 205; + i = wc; + while (k1 < k2) + { + unsigned int k = (k1 + k2) / 2; + if (i <= gb18030uni_uni2charset_ranges[2 * k + 1]) + k2 = k; + else if (i >= gb18030uni_uni2charset_ranges[2 * k + 2]) + k1 = k + 1; + else + return RET_ILUNI; + } + { + unsigned int diff = gb18030uni_ranges[k1]; + i -= diff; + } + } } + else if (wc >= 0x20087 && wc <= 0x241fe) { - unsigned int diff = gb18030uni_ranges[k1]; - i -= diff; + if (wc == 0x20087) + i = 0x3e2cf; + else if (wc == 0x20089) + i = 0x3e2d1; + else if (wc == 0x200cc) + i = 0x3e314; + else if (wc == 0x215d7) + i = 0x3f81f; + else if (wc == 0x2298f) + i = 0x40bd7; + else if (wc == 0x241fe) + i = 0x42446; + else + return RET_ILUNI; } - } - } else if (wc >= 0x20087 && wc <= 0x241fe) { - if (wc == 0x20087) - i = 0x3e2cf; - else if (wc == 0x20089) - i = 0x3e2d1; - else if (wc == 0x200cc) - i = 0x3e314; - else if (wc == 0x215d7) - i = 0x3f81f; - else if (wc == 0x2298f) - i = 0x40bd7; - else if (wc == 0x241fe) - i = 0x42446; - else - return RET_ILUNI; - } else - return RET_ILUNI; - r[3] = (i % 10) + 0x30; i = i / 10; - r[2] = (i % 126) + 0x81; i = i / 126; - r[1] = (i % 10) + 0x30; i = i / 10; - r[0] = i + 0x81; - return 4; - } - return RET_TOOSMALL; + else + return RET_ILUNI; + r[3] = (i % 10) + 0x30; + i = i / 10; + r[2] = (i % 126) + 0x81; + i = i / 126; + r[1] = (i % 10) + 0x30; + i = i / 10; + r[0] = i + 0x81; + return 4; + } + return RET_TOOSMALL; } -static int -gb18030_2022_uni_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int gb18030_2022_uni_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 4) { - if (wc >= 0x0080 && wc <= 0xffff) { - unsigned int i; - if (wc == 0xe7c7) { - i = 7457; - } else if (wc >= 0xe78d && wc <= 0xe796) { - i = 39076 + gb18030_2022_uni2charset_pua2[wc-0xe78d]; - } else if (wc >= 0xe81e && wc <= 0xe864 && gb18030_2022_uni2charset_pua1[wc-0xe81e]) { - i = 19056 + gb18030_2022_uni2charset_pua1[wc-0xe81e]; - } else { - unsigned int k1 = 0; - unsigned int k2 = 205; - i = wc; - while (k1 < k2) { - unsigned int k = (k1 + k2) / 2; - if (i <= gb18030uni_uni2charset_ranges[2*k+1]) - k2 = k; - else if (i >= gb18030uni_uni2charset_ranges[2*k+2]) - k1 = k + 1; - else - return RET_ILUNI; - } + if (n >= 4) + { + if (wc >= 0x0080 && wc <= 0xffff) { - unsigned int diff = gb18030uni_ranges[k1]; - i -= diff; + unsigned int i; + if (wc == 0xe7c7) + { + i = 7457; + } + else if (wc >= 0xe78d && wc <= 0xe796) + { + i = 39076 + gb18030_2022_uni2charset_pua2[wc - 0xe78d]; + } + else if (wc >= 0xe81e && wc <= 0xe864 && gb18030_2022_uni2charset_pua1[wc - 0xe81e]) + { + i = 19056 + gb18030_2022_uni2charset_pua1[wc - 0xe81e]; + } + else + { + unsigned int k1 = 0; + unsigned int k2 = 205; + i = wc; + while (k1 < k2) + { + unsigned int k = (k1 + k2) / 2; + if (i <= gb18030uni_uni2charset_ranges[2 * k + 1]) + k2 = k; + else if (i >= gb18030uni_uni2charset_ranges[2 * k + 2]) + k1 = k + 1; + else + return RET_ILUNI; + } + { + unsigned int diff = gb18030uni_ranges[k1]; + i -= diff; + } + } + r[3] = (i % 10) + 0x30; + i = i / 10; + r[2] = (i % 126) + 0x81; + i = i / 126; + r[1] = (i % 10) + 0x30; + i = i / 10; + r[0] = i + 0x81; + return 4; } - } - r[3] = (i % 10) + 0x30; i = i / 10; - r[2] = (i % 126) + 0x81; i = i / 126; - r[1] = (i % 10) + 0x30; i = i / 10; - r[0] = i + 0x81; - return 4; + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _GB18030UNI_H_ */ diff --git a/lib/gb2312.h b/lib/converters/gb2312.h similarity index 98% rename from lib/gb2312.h rename to lib/converters/gb2312.h index 280e6648..fdd67eaa 100644 --- a/lib/gb2312.h +++ b/lib/converters/gb2312.h @@ -1,5 +1,10 @@ +/** + * @file gb2312.h + * @brief GB2312.1980-0 + * @copyright Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * GB2312.1980-0 - */ +#ifndef _GB2312_H_ +#define _GB2312_H_ + +#include "reiconv_defines.h" static const unsigned short gb2312_2uni_page21[831] = { /* 0x21 */ @@ -1077,33 +1083,39 @@ static const unsigned short gb2312_2uni_page30[6768] = { 0x9f2f, 0x9f39, 0x9f37, 0x9f3d, 0x9f3e, 0x9f44, }; -static int -gb2312_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int gb2312_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x21 && c1 <= 0x29) || (c1 >= 0x30 && c1 <= 0x77)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 < 0x7f) { - unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); - unsigned short wc = 0xfffd; - if (i < 1410) { - if (i < 831) - wc = gb2312_2uni_page21[i]; - } else { - if (i < 8178) - wc = gb2312_2uni_page30[i-1410]; + unsigned char c1 = s[0]; + if ((c1 >= 0x21 && c1 <= 0x29) || (c1 >= 0x30 && c1 <= 0x77)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 < 0x7f) + { + unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); + unsigned short wc = 0xfffd; + if (i < 1410) + { + if (i < 831) + wc = gb2312_2uni_page21[i]; + } + else + { + if (i < 8178) + wc = gb2312_2uni_page30[i - 1410]; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; - } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned short gb2312_2charset[7445] = { @@ -2530,41 +2542,46 @@ static const Summary16 gb2312_uni2indx_pageff[15] = { { 7441, 0x0000 }, { 7441, 0x0000 }, { 7441, 0x002b }, }; -static int -gb2312_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int gb2312_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc >= 0x0000 && wc < 0x0460) - summary = &gb2312_uni2indx_page00[(wc>>4)]; - else if (wc >= 0x2000 && wc < 0x2650) - summary = &gb2312_uni2indx_page20[(wc>>4)-0x200]; - else if (wc >= 0x3000 && wc < 0x3230) - summary = &gb2312_uni2indx_page30[(wc>>4)-0x300]; - else if (wc >= 0x4e00 && wc < 0x9cf0) - summary = &gb2312_uni2indx_page4e[(wc>>4)-0x4e0]; - else if (wc >= 0x9e00 && wc < 0x9fb0) - summary = &gb2312_uni2indx_page9e[(wc>>4)-0x9e0]; - else if (wc >= 0xff00 && wc < 0xfff0) - summary = &gb2312_uni2indx_pageff[(wc>>4)-0xff0]; - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = gb2312_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc >= 0x0000 && wc < 0x0460) + summary = &gb2312_uni2indx_page00[(wc >> 4)]; + else if (wc >= 0x2000 && wc < 0x2650) + summary = &gb2312_uni2indx_page20[(wc >> 4) - 0x200]; + else if (wc >= 0x3000 && wc < 0x3230) + summary = &gb2312_uni2indx_page30[(wc >> 4) - 0x300]; + else if (wc >= 0x4e00 && wc < 0x9cf0) + summary = &gb2312_uni2indx_page4e[(wc >> 4) - 0x4e0]; + else if (wc >= 0x9e00 && wc < 0x9fb0) + summary = &gb2312_uni2indx_page9e[(wc >> 4) - 0x9e0]; + else if (wc >= 0xff00 && wc < 0xfff0) + summary = &gb2312_uni2indx_pageff[(wc >> 4) - 0xff0]; + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = gb2312_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _GB2312_H_ */ diff --git a/lib/converters/gbk.h b/lib/converters/gbk.h new file mode 100644 index 00000000..788c8954 --- /dev/null +++ b/lib/converters/gbk.h @@ -0,0 +1,197 @@ +/** + * @file gbk.h + * @brief GBK + * @copyright Copyright (C) 1999-2001, 2005, 2008, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * GBK, as described in Ken Lunde's book, is an extension of GB 2312-1980 + * (shifted by adding 0x8080 to the range 0xA1A1..0xFEFE, as used in EUC-CN). + * It adds the following ranges: + * + * (part of GBK/1) 0xA2A1-0xA2AA Small Roman numerals + * GBK/3 0x{81-A0}{40-7E,80-FE} 6080 new characters, all in Unicode + * GBK/4 0x{AA-FE}{40-7E,80-A0} 8160 new characters, 8080 in Unicode + * GBK/5 0x{A8-A9}{40-7E,80-A0} 166 new characters, 153 in Unicode + * + * Furthermore, all four tables I have looked at + * - the CP936 table by Microsoft, found on ftp.unicode.org in 1999, + * - the GBK table by Sun, investigated on a Solaris 2.7 machine, + * - the GBK tables by CWEX, found in the Big5+ package, + * - the GB18030 standard (second printing), + * agree in the following extensions. (Ken Lunde must have overlooked these + * differences between GB2312 and GBK. Also, the CWEX tables have additional + * differences.) + * + * 1. Some characters in the GB2312 range are defined differently: + * + * code GB2312 GBK + * 0xA1A4 0x30FB # KATAKANA MIDDLE DOT 0x00B7 # MIDDLE DOT + * 0xA1AA 0x2015 # HORIZONTAL BAR 0x2014 # EM DASH + * + * 2. 19 characters added in the range 0xA6E0-0xA6F5. + * + * 3. 4 characters added in the range 0xA8BB-0xA8C0. + * + * CP936 as of 1999 was identical to GBK. However, since 1999, Microsoft has + * added new mappings to CP936... + */ + +#ifndef _GBK_H_ +#define _GBK_H_ + +#include "converters/gb2312.h" +#include "reiconv_defines.h" + +#include "cp936ext.h" +#include "gbkext1.h" +#include "gbkext2.h" +#include "gbkext_inv.h" + +#include + +static int gbk_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + + if (c >= 0x81 && c < 0xff) + { + if (n < 2) + return RET_TOOFEW(0); + if (c >= 0xa1 && c <= 0xf7) + { + unsigned char c2 = s[1]; + if (c == 0xa1) + { + if (c2 == 0xa4) + { + *pwc = 0x00b7; + return 2; + } + if (c2 == 0xaa) + { + *pwc = 0x2014; + return 2; + } + } + if (c2 >= 0xa1 && c2 < 0xff) + { + unsigned char buf[2]; + int ret; + buf[0] = c - 0x80; + buf[1] = c2 - 0x80; + ret = gb2312_mbtowc(conv, pwc, buf, 2); + if (ret != RET_ILSEQ) + return ret; + buf[0] = c; + buf[1] = c2; + ret = cp936ext_mbtowc(conv, pwc, buf, 2); + if (ret != RET_ILSEQ) + return ret; + } + } + if (c >= 0x81 && c <= 0xa0) + return gbkext1_mbtowc(conv, pwc, s, 2); + if (c >= 0xa8 && c <= 0xfe) + return gbkext2_mbtowc(conv, pwc, s, 2); + if (c == 0xa2) + { + unsigned char c2 = s[1]; + if (c2 >= 0xa1 && c2 <= 0xaa) + { + *pwc = 0x2170 + (c2 - 0xa1); + return 2; + } + } + } + return RET_ILSEQ; +} + +static int gbk_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[2]; + int ret; + + if (wc != 0x30fb && wc != 0x2015) + { + ret = gb2312_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0] + 0x80; + r[1] = buf[1] + 0x80; + return 2; + } + } + ret = gbkext_inv_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0]; + r[1] = buf[1]; + return 2; + } + if (wc >= 0x2170 && wc <= 0x2179) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = 0xa2; + r[1] = 0xa1 + (wc - 0x2170); + return 2; + } + ret = cp936ext_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0]; + r[1] = buf[1]; + return 2; + } + if (wc == 0x00b7) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = 0xa1; + r[1] = 0xa4; + return 2; + } + if (wc == 0x2014) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = 0xa1; + r[1] = 0xaa; + return 2; + } + + return RET_ILUNI; +} + +#endif /* _GBK_H_ */ diff --git a/lib/gbkext1.h b/lib/converters/gbkext1.h similarity index 97% rename from lib/gbkext1.h rename to lib/converters/gbkext1.h index 01ed429a..ca30378b 100644 --- a/lib/gbkext1.h +++ b/lib/converters/gbkext1.h @@ -1,5 +1,10 @@ +/** + * @file gbkext1.h + * @brief GBK/3 extensions + * @copyright Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * GBK/3 extensions - */ +#ifndef _GBKEXT1_H_ +#define _GBKEXT1_H_ + +#include "reiconv_defines.h" static const unsigned short gbkext1_2uni_page81[6080] = { /* 0x81 */ @@ -824,29 +830,33 @@ static const unsigned short gbkext1_2uni_page81[6080] = { 0x72d4, 0x72d5, 0x72d6, 0x72d8, 0x72da, 0x72db, }; -static int -gbkext1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int gbkext1_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x81 && c1 <= 0xa0)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xff)) { - unsigned int i = 190 * (c1 - 0x81) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); - unsigned short wc = 0xfffd; + unsigned char c1 = s[0]; + if ((c1 >= 0x81 && c1 <= 0xa0)) + { + if (n >= 2) { - if (i < 6080) - wc = gbkext1_2uni_page81[i]; - } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xff)) + { + unsigned int i = 190 * (c1 - 0x81) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); + unsigned short wc = 0xfffd; + { + if (i < 6080) + wc = gbkext1_2uni_page81[i]; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } +#endif /* _GBKEXT1_H_ */ diff --git a/lib/gbkext2.h b/lib/converters/gbkext2.h similarity index 98% rename from lib/gbkext2.h rename to lib/converters/gbkext2.h index 03114db9..5a023530 100644 --- a/lib/gbkext2.h +++ b/lib/converters/gbkext2.h @@ -1,5 +1,10 @@ +/** + * @file gbkext2.h + * @brief GBK/4 and GBK/5 extensions + * @copyright Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * GBK/4 and GBK/5 extensions - */ +#ifndef _GBKEXT2_H_ +#define _GBKEXT2_H_ + +#include "reiconv_defines.h" static const unsigned short gbkext2_2uni_pagea8[8272] = { /* 0xa8 */ @@ -1145,29 +1151,33 @@ static const unsigned short gbkext2_2uni_pagea8[8272] = { 0xfa1f, 0xfa20, 0xfa21, 0xfa23, 0xfa24, 0xfa27, 0xfa28, 0xfa29, }; -static int -gbkext2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int gbkext2_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0xa8 && c1 <= 0xfe)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xa1)) { - unsigned int i = 96 * (c1 - 0x81) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); - unsigned short wc = 0xfffd; + unsigned char c1 = s[0]; + if ((c1 >= 0xa8 && c1 <= 0xfe)) + { + if (n >= 2) { - if (i < 12016) - wc = gbkext2_2uni_pagea8[i-3744]; - } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xa1)) + { + unsigned int i = 96 * (c1 - 0x81) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); + unsigned short wc = 0xfffd; + { + if (i < 12016) + wc = gbkext2_2uni_pagea8[i - 3744]; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } +#endif /* _GBKEXT2_H_ */ diff --git a/lib/gbkext_inv.h b/lib/converters/gbkext_inv.h similarity index 98% rename from lib/gbkext_inv.h rename to lib/converters/gbkext_inv.h index a2ffbf76..90298c7f 100644 --- a/lib/gbkext_inv.h +++ b/lib/converters/gbkext_inv.h @@ -1,5 +1,10 @@ +/** + * @file gbkext_inv.h + * @brief GBK extensions + * @copyright Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * GBK extensions - */ +#ifndef _GBKEXT_INV_H_ +#define _GBKEXT_INV_H_ + +#include "reiconv_defines.h" static const unsigned short gbkext_inv_2charset[14313] = { 0xa840, 0xa841, 0xa842, 0xa95c, 0xa843, 0xa844, 0xa845, 0xa846, @@ -2298,45 +2304,50 @@ static const Summary16 gbkext_inv_uni2indx_pagefe[31] = { { 14311, 0x0000 }, { 14311, 0x0000 }, { 14311, 0x0014 }, }; -static int -gbkext_inv_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int gbkext_inv_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc >= 0x0200 && wc < 0x02e0) - summary = &gbkext_inv_uni2indx_page02[(wc>>4)-0x020]; - else if (wc >= 0x2000 && wc < 0x22c0) - summary = &gbkext_inv_uni2indx_page20[(wc>>4)-0x200]; - else if (wc >= 0x2500 && wc < 0x2610) - summary = &gbkext_inv_uni2indx_page25[(wc>>4)-0x250]; - else if (wc >= 0x3000 && wc < 0x3100) - summary = &gbkext_inv_uni2indx_page30[(wc>>4)-0x300]; - else if (wc >= 0x3200 && wc < 0x33e0) - summary = &gbkext_inv_uni2indx_page32[(wc>>4)-0x320]; - else if (wc >= 0x4e00 && wc < 0x9fb0) - summary = &gbkext_inv_uni2indx_page4e[(wc>>4)-0x4e0]; - else if (wc >= 0xf900 && wc < 0xfa30) - summary = &gbkext_inv_uni2indx_pagef9[(wc>>4)-0xf90]; - else if (wc >= 0xfe00 && wc < 0xfff0) - summary = &gbkext_inv_uni2indx_pagefe[(wc>>4)-0xfe0]; - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = gbkext_inv_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc >= 0x0200 && wc < 0x02e0) + summary = &gbkext_inv_uni2indx_page02[(wc >> 4) - 0x020]; + else if (wc >= 0x2000 && wc < 0x22c0) + summary = &gbkext_inv_uni2indx_page20[(wc >> 4) - 0x200]; + else if (wc >= 0x2500 && wc < 0x2610) + summary = &gbkext_inv_uni2indx_page25[(wc >> 4) - 0x250]; + else if (wc >= 0x3000 && wc < 0x3100) + summary = &gbkext_inv_uni2indx_page30[(wc >> 4) - 0x300]; + else if (wc >= 0x3200 && wc < 0x33e0) + summary = &gbkext_inv_uni2indx_page32[(wc >> 4) - 0x320]; + else if (wc >= 0x4e00 && wc < 0x9fb0) + summary = &gbkext_inv_uni2indx_page4e[(wc >> 4) - 0x4e0]; + else if (wc >= 0xf900 && wc < 0xfa30) + summary = &gbkext_inv_uni2indx_pagef9[(wc >> 4) - 0xf90]; + else if (wc >= 0xfe00 && wc < 0xfff0) + summary = &gbkext_inv_uni2indx_pagefe[(wc >> 4) - 0xfe0]; + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = gbkext_inv_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _GBKEXT_INV_H_ */ diff --git a/lib/georgian_academy.h b/lib/converters/georgian_academy.h similarity index 65% rename from lib/georgian_academy.h rename to lib/converters/georgian_academy.h index 62e30920..8421d462 100644 --- a/lib/georgian_academy.h +++ b/lib/converters/georgian_academy.h @@ -1,5 +1,10 @@ +/** + * @file georgian_academy.h + * @brief GEORGIAN-ACADEMY + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * GEORGIAN-ACADEMY - */ +#ifndef _GEORGIAN_ACADEMY_H_ +#define _GEORGIAN_ACADEMY_H_ + +#include "reiconv_defines.h" static const unsigned short georgian_academy_2uni[32] = { /* 0x80 */ @@ -30,17 +36,16 @@ static const unsigned short georgian_academy_2uni[32] = { 0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x009d, 0x009e, 0x0178, }; -static int -georgian_academy_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int georgian_academy_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c >= 0x80 && c < 0xa0) - *pwc = (ucs4_t) georgian_academy_2uni[c-0x80]; - else if (c >= 0xc0 && c < 0xe7) - *pwc = (ucs4_t) c + 0x1010; - else - *pwc = (ucs4_t) c; - return 1; + unsigned char c = *s; + if (c >= 0x80 && c < 0xa0) + *pwc = (ucs4_t)georgian_academy_2uni[c - 0x80]; + else if (c >= 0xc0 && c < 0xe7) + *pwc = (ucs4_t)c + 0x1010; + else + *pwc = (ucs4_t)c; + return 1; } static const unsigned char georgian_academy_page00[32] = { @@ -75,31 +80,34 @@ static const unsigned char georgian_academy_page20[48] = { 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ }; -static int -georgian_academy_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int georgian_academy_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x0080 && wc < 0x00a0) - c = georgian_academy_page00[wc-0x0080]; - else if ((wc >= 0x00a0 && wc < 0x00c0) || (wc >= 0x00e7 && wc < 0x0100)) - c = wc; - else if (wc >= 0x0150 && wc < 0x0198) - c = georgian_academy_page01[wc-0x0150]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = georgian_academy_page02[wc-0x02c0]; - else if (wc >= 0x10d0 && wc < 0x10f7) - c = wc-0x1010; - else if (wc >= 0x2010 && wc < 0x2040) - c = georgian_academy_page20[wc-0x2010]; - else if (wc == 0x2122) - c = 0x99; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x0080 && wc < 0x00a0) + c = georgian_academy_page00[wc - 0x0080]; + else if ((wc >= 0x00a0 && wc < 0x00c0) || (wc >= 0x00e7 && wc < 0x0100)) + c = wc; + else if (wc >= 0x0150 && wc < 0x0198) + c = georgian_academy_page01[wc - 0x0150]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = georgian_academy_page02[wc - 0x02c0]; + else if (wc >= 0x10d0 && wc < 0x10f7) + c = wc - 0x1010; + else if (wc >= 0x2010 && wc < 0x2040) + c = georgian_academy_page20[wc - 0x2010]; + else if (wc == 0x2122) + c = 0x99; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _GEORGIAN_ACADEMY_H_ */ diff --git a/lib/georgian_ps.h b/lib/converters/georgian_ps.h similarity index 70% rename from lib/georgian_ps.h rename to lib/converters/georgian_ps.h index 4970a360..7c115027 100644 --- a/lib/georgian_ps.h +++ b/lib/converters/georgian_ps.h @@ -1,5 +1,10 @@ +/** + * @file georgian_ps.h + * @brief GEORGIAN-PS + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * GEORGIAN-PS - */ +#ifndef _GEORGIAN_PS_H_ +#define _GEORGIAN_PS_H_ + +#include "reiconv_defines.h" static const unsigned short georgian_ps_2uni_1[32] = { /* 0x80 */ @@ -40,17 +46,16 @@ static const unsigned short georgian_ps_2uni_2[39] = { 0x10ed, 0x10ee, 0x10f4, 0x10ef, 0x10f0, 0x10f5, }; -static int -georgian_ps_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int georgian_ps_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c >= 0x80 && c < 0xa0) - *pwc = (ucs4_t) georgian_ps_2uni_1[c-0x80]; - else if (c >= 0xc0 && c < 0xe6) - *pwc = (ucs4_t) georgian_ps_2uni_2[c-0xc0]; - else - *pwc = (ucs4_t) c; - return 1; + unsigned char c = *s; + if (c >= 0x80 && c < 0xa0) + *pwc = (ucs4_t)georgian_ps_2uni_1[c - 0x80]; + else if (c >= 0xc0 && c < 0xe6) + *pwc = (ucs4_t)georgian_ps_2uni_2[c - 0xc0]; + else + *pwc = (ucs4_t)c; + return 1; } static const unsigned char georgian_ps_page00[32] = { @@ -92,31 +97,34 @@ static const unsigned char georgian_ps_page20[48] = { 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ }; -static int -georgian_ps_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int georgian_ps_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x0080 && wc < 0x00a0) - c = georgian_ps_page00[wc-0x0080]; - else if ((wc >= 0x00a0 && wc < 0x00c0) || (wc >= 0x00e6 && wc < 0x0100)) - c = wc; - else if (wc >= 0x0150 && wc < 0x0198) - c = georgian_ps_page01[wc-0x0150]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = georgian_ps_page02[wc-0x02c0]; - else if (wc >= 0x10d0 && wc < 0x10f8) - c = georgian_ps_page10[wc-0x10d0]; - else if (wc >= 0x2010 && wc < 0x2040) - c = georgian_ps_page20[wc-0x2010]; - else if (wc == 0x2122) - c = 0x99; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x0080 && wc < 0x00a0) + c = georgian_ps_page00[wc - 0x0080]; + else if ((wc >= 0x00a0 && wc < 0x00c0) || (wc >= 0x00e6 && wc < 0x0100)) + c = wc; + else if (wc >= 0x0150 && wc < 0x0198) + c = georgian_ps_page01[wc - 0x0150]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = georgian_ps_page02[wc - 0x02c0]; + else if (wc >= 0x10d0 && wc < 0x10f8) + c = georgian_ps_page10[wc - 0x10d0]; + else if (wc >= 0x2010 && wc < 0x2040) + c = georgian_ps_page20[wc - 0x2010]; + else if (wc == 0x2122) + c = 0x99; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _GEORGIAN_PS_H_ */ diff --git a/lib/hkscs1999.h b/lib/converters/hkscs1999.h similarity index 97% rename from lib/hkscs1999.h rename to lib/converters/hkscs1999.h index 80f80278..16ac8e5c 100644 --- a/lib/hkscs1999.h +++ b/lib/converters/hkscs1999.h @@ -1,5 +1,10 @@ +/** + * @file hkscs1999.h + * @brief HKSCS:1999 + * @copyright Copyright (C) 1999-2006, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2006, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * HKSCS:1999 - */ +#ifndef _HKSCS1999_H_ +#define _HKSCS1999_H_ + +#include "reiconv_defines.h" static const unsigned short hkscs1999_2uni_page88[627] = { /* 0x88 */ @@ -848,44 +854,51 @@ static const ucs4_t hkscs1999_2uni_upages[973] = { 0x2f840, 0x2f880, 0x2f8c0, 0x2f980, 0x2f9c0, }; -static int -hkscs1999_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int hkscs1999_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x88 && c1 <= 0x8b) || (c1 >= 0x8d && c1 <= 0xa0) || (c1 >= 0xc6 && c1 <= 0xc8) || (c1 >= 0xf9 && c1 <= 0xfe)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) { - unsigned int i = 157 * (c1 - 0x80) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); - ucs4_t wc = 0xfffd; - unsigned short swc; - if (i < 2041) { - if (i < 1883) - swc = hkscs1999_2uni_page88[i-1256], - wc = hkscs1999_2uni_upages[swc>>6] | (swc & 0x3f); - } else if (i < 10990) { - if (i < 5181) - swc = hkscs1999_2uni_page8d[i-2041], - wc = hkscs1999_2uni_upages[swc>>6] | (swc & 0x3f); - } else if (i < 18997) { - if (i < 11461) - swc = hkscs1999_2uni_pagec6[i-10990], - wc = hkscs1999_2uni_upages[swc>>6] | (swc & 0x3f); - } else { - if (i < 19939) - swc = hkscs1999_2uni_pagef9[i-18997], - wc = hkscs1999_2uni_upages[swc>>6] | (swc & 0x3f); + unsigned char c1 = s[0]; + if ((c1 >= 0x88 && c1 <= 0x8b) || (c1 >= 0x8d && c1 <= 0xa0) || (c1 >= 0xc6 && c1 <= 0xc8) || + (c1 >= 0xf9 && c1 <= 0xfe)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) + { + unsigned int i = 157 * (c1 - 0x80) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); + ucs4_t wc = 0xfffd; + unsigned short swc; + if (i < 2041) + { + if (i < 1883) + swc = hkscs1999_2uni_page88[i - 1256], wc = hkscs1999_2uni_upages[swc >> 6] | (swc & 0x3f); + } + else if (i < 10990) + { + if (i < 5181) + swc = hkscs1999_2uni_page8d[i - 2041], wc = hkscs1999_2uni_upages[swc >> 6] | (swc & 0x3f); + } + else if (i < 18997) + { + if (i < 11461) + swc = hkscs1999_2uni_pagec6[i - 10990], wc = hkscs1999_2uni_upages[swc >> 6] | (swc & 0x3f); + } + else + { + if (i < 19939) + swc = hkscs1999_2uni_pagef9[i - 18997], wc = hkscs1999_2uni_upages[swc >> 6] | (swc & 0x3f); + } + if (wc != 0xfffd) + { + *pwc = wc; + return 2; + } + } + return RET_ILSEQ; } - if (wc != 0xfffd) { - *pwc = wc; - return 2; - } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned short hkscs1999_2charset[4698] = { @@ -2948,57 +2961,62 @@ static const Summary16 hkscs1999_uni2indx_page2f8[30] = { { 4697, 0x0000 }, { 4697, 0x0010 }, }; -static int -hkscs1999_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int hkscs1999_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc >= 0x0000 && wc < 0x02d0) - summary = &hkscs1999_uni2indx_page00[(wc>>4)]; - else if (wc >= 0x0400 && wc < 0x0460) - summary = &hkscs1999_uni2indx_page04[(wc>>4)-0x040]; - else if (wc >= 0x1e00 && wc < 0x1ed0) - summary = &hkscs1999_uni2indx_page1e[(wc>>4)-0x1e0]; - else if (wc >= 0x2100 && wc < 0x21f0) - summary = &hkscs1999_uni2indx_page21[(wc>>4)-0x210]; - else if (wc >= 0x2300 && wc < 0x2580) - summary = &hkscs1999_uni2indx_page23[(wc>>4)-0x230]; - else if (wc >= 0x2700 && wc < 0x2740) - summary = &hkscs1999_uni2indx_page27[(wc>>4)-0x270]; - else if (wc >= 0x2e00 && wc < 0x3240) - summary = &hkscs1999_uni2indx_page2e[(wc>>4)-0x2e0]; - else if (wc >= 0x3400 && wc < 0x9fc0) - summary = &hkscs1999_uni2indx_page34[(wc>>4)-0x340]; - else if (wc >= 0xf900 && wc < 0xf910) - summary = &hkscs1999_uni2indx_pagef9[(wc>>4)-0xf90]; - else if (wc >= 0xff00 && wc < 0xfff0) - summary = &hkscs1999_uni2indx_pageff[(wc>>4)-0xff0]; - else if (wc >= 0x20000 && wc < 0x291f0) - summary = &hkscs1999_uni2indx_page200[(wc>>4)-0x2000]; - else if (wc >= 0x29400 && wc < 0x29600) - summary = &hkscs1999_uni2indx_page294[(wc>>4)-0x2940]; - else if (wc >= 0x29700 && wc < 0x2a6b0) - summary = &hkscs1999_uni2indx_page297[(wc>>4)-0x2970]; - else if (wc >= 0x2f800 && wc < 0x2f9e0) - summary = &hkscs1999_uni2indx_page2f8[(wc>>4)-0x2f80]; - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = hkscs1999_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc >= 0x0000 && wc < 0x02d0) + summary = &hkscs1999_uni2indx_page00[(wc >> 4)]; + else if (wc >= 0x0400 && wc < 0x0460) + summary = &hkscs1999_uni2indx_page04[(wc >> 4) - 0x040]; + else if (wc >= 0x1e00 && wc < 0x1ed0) + summary = &hkscs1999_uni2indx_page1e[(wc >> 4) - 0x1e0]; + else if (wc >= 0x2100 && wc < 0x21f0) + summary = &hkscs1999_uni2indx_page21[(wc >> 4) - 0x210]; + else if (wc >= 0x2300 && wc < 0x2580) + summary = &hkscs1999_uni2indx_page23[(wc >> 4) - 0x230]; + else if (wc >= 0x2700 && wc < 0x2740) + summary = &hkscs1999_uni2indx_page27[(wc >> 4) - 0x270]; + else if (wc >= 0x2e00 && wc < 0x3240) + summary = &hkscs1999_uni2indx_page2e[(wc >> 4) - 0x2e0]; + else if (wc >= 0x3400 && wc < 0x9fc0) + summary = &hkscs1999_uni2indx_page34[(wc >> 4) - 0x340]; + else if (wc >= 0xf900 && wc < 0xf910) + summary = &hkscs1999_uni2indx_pagef9[(wc >> 4) - 0xf90]; + else if (wc >= 0xff00 && wc < 0xfff0) + summary = &hkscs1999_uni2indx_pageff[(wc >> 4) - 0xff0]; + else if (wc >= 0x20000 && wc < 0x291f0) + summary = &hkscs1999_uni2indx_page200[(wc >> 4) - 0x2000]; + else if (wc >= 0x29400 && wc < 0x29600) + summary = &hkscs1999_uni2indx_page294[(wc >> 4) - 0x2940]; + else if (wc >= 0x29700 && wc < 0x2a6b0) + summary = &hkscs1999_uni2indx_page297[(wc >> 4) - 0x2970]; + else if (wc >= 0x2f800 && wc < 0x2f9e0) + summary = &hkscs1999_uni2indx_page2f8[(wc >> 4) - 0x2f80]; + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = hkscs1999_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _HKSCS1999_H_ */ diff --git a/lib/hkscs2001.h b/lib/converters/hkscs2001.h similarity index 74% rename from lib/hkscs2001.h rename to lib/converters/hkscs2001.h index 840cead1..db62aa8e 100644 --- a/lib/hkscs2001.h +++ b/lib/converters/hkscs2001.h @@ -1,5 +1,10 @@ +/** + * @file hkscs2001.h + * @brief HKSCS:2001 + * @copyright Copyright (C) 1999-2006, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2006, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * HKSCS:2001 - */ +#ifndef _HKSCS2001_H_ +#define _HKSCS2001_H_ + +#include "reiconv_defines.h" static const unsigned short hkscs2001_2uni_page8c[123] = { /* 0x8c */ @@ -55,32 +61,34 @@ static const ucs4_t hkscs2001_2uni_upages[85] = { 0x28d00, 0x29900, 0x29c00, 0x2a100, 0x2a200, }; -static int -hkscs2001_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int hkscs2001_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if (c1 == (unsigned char)0x8c) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) { - unsigned int i = 157 * (c1 - 0x80) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); - ucs4_t wc = 0xfffd; - unsigned short swc; + unsigned char c1 = s[0]; + if (c1 == (unsigned char)0x8c) + { + if (n >= 2) { - if (i < 2007) - swc = hkscs2001_2uni_page8c[i-1884], - wc = hkscs2001_2uni_upages[swc>>8] | (swc & 0xff); + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) + { + unsigned int i = 157 * (c1 - 0x80) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); + ucs4_t wc = 0xfffd; + unsigned short swc; + { + if (i < 2007) + swc = hkscs2001_2uni_page8c[i - 1884], wc = hkscs2001_2uni_upages[swc >> 8] | (swc & 0xff); + } + if (wc != 0xfffd) + { + *pwc = wc; + return 2; + } + } + return RET_ILSEQ; } - if (wc != 0xfffd) { - *pwc = wc; - return 2; - } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned short hkscs2001_2charset[116] = { @@ -549,134 +557,148 @@ static const Summary16 hkscs2001_uni2indx_page2a1[28] = { { 115, 0x0000 }, { 115, 0x0000 }, { 115, 0x0000 }, { 115, 0x0400 }, }; -static int -hkscs2001_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int hkscs2001_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc < 0x9f00) { - if (wc < 0x6900) { - if (wc >= 0x3500 && wc < 0x3560) - summary = &hkscs2001_uni2indx_page35[(wc>>4)-0x350]; - else if (wc >= 0x3c00 && wc < 0x3ee0) - summary = &hkscs2001_uni2indx_page3c[(wc>>4)-0x3c0]; - else if (wc >= 0x4000 && wc < 0x4080) - summary = &hkscs2001_uni2indx_page40[(wc>>4)-0x400]; - else if (wc >= 0x4200 && wc < 0x42b0) - summary = &hkscs2001_uni2indx_page42[(wc>>4)-0x420]; - else if (wc >= 0x4b00 && wc < 0x4c90) - summary = &hkscs2001_uni2indx_page4b[(wc>>4)-0x4b0]; - else if (wc >= 0x4e00 && wc < 0x51b0) - summary = &hkscs2001_uni2indx_page4e[(wc>>4)-0x4e0]; - else if (wc >= 0x5300 && wc < 0x5440) - summary = &hkscs2001_uni2indx_page53[(wc>>4)-0x530]; - else if (wc >= 0x5700 && wc < 0x58e0) - summary = &hkscs2001_uni2indx_page57[(wc>>4)-0x570]; - else if (wc >= 0x5a00 && wc < 0x5fd0) - summary = &hkscs2001_uni2indx_page5a[(wc>>4)-0x5a0]; - else if (wc >= 0x6100 && wc < 0x6130) - summary = &hkscs2001_uni2indx_page61[(wc>>4)-0x610]; - else if (wc >= 0x6500 && wc < 0x6590) - summary = &hkscs2001_uni2indx_page65[(wc>>4)-0x650]; - else if (wc >= 0x6700 && wc < 0x6770) - summary = &hkscs2001_uni2indx_page67[(wc>>4)-0x670]; - } else { - if (wc >= 0x6900 && wc < 0x6a70) - summary = &hkscs2001_uni2indx_page69[(wc>>4)-0x690]; - else if (wc >= 0x6c00 && wc < 0x6e00) - summary = &hkscs2001_uni2indx_page6c[(wc>>4)-0x6c0]; - else if (wc >= 0x7000 && wc < 0x74c0) - summary = &hkscs2001_uni2indx_page70[(wc>>4)-0x700]; - else if (wc >= 0x7600 && wc < 0x78f0) - summary = &hkscs2001_uni2indx_page76[(wc>>4)-0x760]; - else if (wc >= 0x7a00 && wc < 0x7e70) - summary = &hkscs2001_uni2indx_page7a[(wc>>4)-0x7a0]; - else if (wc >= 0x8200 && wc < 0x8300) - summary = &hkscs2001_uni2indx_page82[(wc>>4)-0x820]; - else if (wc >= 0x8500 && wc < 0x8610) - summary = &hkscs2001_uni2indx_page85[(wc>>4)-0x850]; - else if (wc >= 0x8800 && wc < 0x88a0) - summary = &hkscs2001_uni2indx_page88[(wc>>4)-0x880]; - else if (wc >= 0x8b00 && wc < 0x8b90) - summary = &hkscs2001_uni2indx_page8b[(wc>>4)-0x8b0]; - else if (wc >= 0x8e00 && wc < 0x8fd0) - summary = &hkscs2001_uni2indx_page8e[(wc>>4)-0x8e0]; - else if (wc >= 0x9100 && wc < 0x9400) - summary = &hkscs2001_uni2indx_page91[(wc>>4)-0x910]; - else if (wc >= 0x9700 && wc < 0x99f0) - summary = &hkscs2001_uni2indx_page97[(wc>>4)-0x970]; - } - } else { - if (wc < 0x25600) { - if (wc >= 0x9f00 && wc < 0x9fb0) - summary = &hkscs2001_uni2indx_page9f[(wc>>4)-0x9f0]; - else if (wc >= 0x21400 && wc < 0x21440) - summary = &hkscs2001_uni2indx_page214[(wc>>4)-0x2140]; - else if (wc >= 0x21900 && wc < 0x21990) - summary = &hkscs2001_uni2indx_page219[(wc>>4)-0x2190]; - else if (wc >= 0x21d00 && wc < 0x21dc0) - summary = &hkscs2001_uni2indx_page21d[(wc>>4)-0x21d0]; - else if (wc >= 0x22000 && wc < 0x22080) - summary = &hkscs2001_uni2indx_page220[(wc>>4)-0x2200]; - else if (wc >= 0x22700 && wc < 0x22720) - summary = &hkscs2001_uni2indx_page227[(wc>>4)-0x2270]; - else if (wc >= 0x23200 && wc < 0x23400) - summary = &hkscs2001_uni2indx_page232[(wc>>4)-0x2320]; - else if (wc >= 0x23c00 && wc < 0x23c70) - summary = &hkscs2001_uni2indx_page23c[(wc>>4)-0x23c0]; - else if (wc >= 0x24100 && wc < 0x24150) - summary = &hkscs2001_uni2indx_page241[(wc>>4)-0x2410]; - else if (wc >= 0x24500 && wc < 0x24510) - summary = &hkscs2001_uni2indx_page245[(wc>>4)-0x2450]; - else if (wc >= 0x24900 && wc < 0x24a20) - summary = &hkscs2001_uni2indx_page249[(wc>>4)-0x2490]; - else if (wc >= 0x25100 && wc < 0x251d0) - summary = &hkscs2001_uni2indx_page251[(wc>>4)-0x2510]; - } else { - if (wc >= 0x25600 && wc < 0x256a0) - summary = &hkscs2001_uni2indx_page256[(wc>>4)-0x2560]; - else if (wc >= 0x25c00 && wc < 0x25d40) - summary = &hkscs2001_uni2indx_page25c[(wc>>4)-0x25c0]; - else if (wc >= 0x26b00 && wc < 0x26b20) - summary = &hkscs2001_uni2indx_page26b[(wc>>4)-0x26b0]; - else if (wc >= 0x26d00 && wc < 0x26d80) - summary = &hkscs2001_uni2indx_page26d[(wc>>4)-0x26d0]; - else if (wc >= 0x26f00 && wc < 0x26fc0) - summary = &hkscs2001_uni2indx_page26f[(wc>>4)-0x26f0]; - else if (wc >= 0x27100 && wc < 0x27110) - summary = &hkscs2001_uni2indx_page271[(wc>>4)-0x2710]; - else if (wc >= 0x28700 && wc < 0x28710) - summary = &hkscs2001_uni2indx_page287[(wc>>4)-0x2870]; - else if (wc >= 0x28900 && wc < 0x28af0) - summary = &hkscs2001_uni2indx_page289[(wc>>4)-0x2890]; - else if (wc >= 0x28d00 && wc < 0x28dc0) - summary = &hkscs2001_uni2indx_page28d[(wc>>4)-0x28d0]; - else if (wc >= 0x29900 && wc < 0x29950) - summary = &hkscs2001_uni2indx_page299[(wc>>4)-0x2990]; - else if (wc >= 0x29c00 && wc < 0x29c80) - summary = &hkscs2001_uni2indx_page29c[(wc>>4)-0x29c0]; - else if (wc >= 0x2a100 && wc < 0x2a2c0) - summary = &hkscs2001_uni2indx_page2a1[(wc>>4)-0x2a10]; - } - } - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = hkscs2001_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc < 0x9f00) + { + if (wc < 0x6900) + { + if (wc >= 0x3500 && wc < 0x3560) + summary = &hkscs2001_uni2indx_page35[(wc >> 4) - 0x350]; + else if (wc >= 0x3c00 && wc < 0x3ee0) + summary = &hkscs2001_uni2indx_page3c[(wc >> 4) - 0x3c0]; + else if (wc >= 0x4000 && wc < 0x4080) + summary = &hkscs2001_uni2indx_page40[(wc >> 4) - 0x400]; + else if (wc >= 0x4200 && wc < 0x42b0) + summary = &hkscs2001_uni2indx_page42[(wc >> 4) - 0x420]; + else if (wc >= 0x4b00 && wc < 0x4c90) + summary = &hkscs2001_uni2indx_page4b[(wc >> 4) - 0x4b0]; + else if (wc >= 0x4e00 && wc < 0x51b0) + summary = &hkscs2001_uni2indx_page4e[(wc >> 4) - 0x4e0]; + else if (wc >= 0x5300 && wc < 0x5440) + summary = &hkscs2001_uni2indx_page53[(wc >> 4) - 0x530]; + else if (wc >= 0x5700 && wc < 0x58e0) + summary = &hkscs2001_uni2indx_page57[(wc >> 4) - 0x570]; + else if (wc >= 0x5a00 && wc < 0x5fd0) + summary = &hkscs2001_uni2indx_page5a[(wc >> 4) - 0x5a0]; + else if (wc >= 0x6100 && wc < 0x6130) + summary = &hkscs2001_uni2indx_page61[(wc >> 4) - 0x610]; + else if (wc >= 0x6500 && wc < 0x6590) + summary = &hkscs2001_uni2indx_page65[(wc >> 4) - 0x650]; + else if (wc >= 0x6700 && wc < 0x6770) + summary = &hkscs2001_uni2indx_page67[(wc >> 4) - 0x670]; + } + else + { + if (wc >= 0x6900 && wc < 0x6a70) + summary = &hkscs2001_uni2indx_page69[(wc >> 4) - 0x690]; + else if (wc >= 0x6c00 && wc < 0x6e00) + summary = &hkscs2001_uni2indx_page6c[(wc >> 4) - 0x6c0]; + else if (wc >= 0x7000 && wc < 0x74c0) + summary = &hkscs2001_uni2indx_page70[(wc >> 4) - 0x700]; + else if (wc >= 0x7600 && wc < 0x78f0) + summary = &hkscs2001_uni2indx_page76[(wc >> 4) - 0x760]; + else if (wc >= 0x7a00 && wc < 0x7e70) + summary = &hkscs2001_uni2indx_page7a[(wc >> 4) - 0x7a0]; + else if (wc >= 0x8200 && wc < 0x8300) + summary = &hkscs2001_uni2indx_page82[(wc >> 4) - 0x820]; + else if (wc >= 0x8500 && wc < 0x8610) + summary = &hkscs2001_uni2indx_page85[(wc >> 4) - 0x850]; + else if (wc >= 0x8800 && wc < 0x88a0) + summary = &hkscs2001_uni2indx_page88[(wc >> 4) - 0x880]; + else if (wc >= 0x8b00 && wc < 0x8b90) + summary = &hkscs2001_uni2indx_page8b[(wc >> 4) - 0x8b0]; + else if (wc >= 0x8e00 && wc < 0x8fd0) + summary = &hkscs2001_uni2indx_page8e[(wc >> 4) - 0x8e0]; + else if (wc >= 0x9100 && wc < 0x9400) + summary = &hkscs2001_uni2indx_page91[(wc >> 4) - 0x910]; + else if (wc >= 0x9700 && wc < 0x99f0) + summary = &hkscs2001_uni2indx_page97[(wc >> 4) - 0x970]; + } + } + else + { + if (wc < 0x25600) + { + if (wc >= 0x9f00 && wc < 0x9fb0) + summary = &hkscs2001_uni2indx_page9f[(wc >> 4) - 0x9f0]; + else if (wc >= 0x21400 && wc < 0x21440) + summary = &hkscs2001_uni2indx_page214[(wc >> 4) - 0x2140]; + else if (wc >= 0x21900 && wc < 0x21990) + summary = &hkscs2001_uni2indx_page219[(wc >> 4) - 0x2190]; + else if (wc >= 0x21d00 && wc < 0x21dc0) + summary = &hkscs2001_uni2indx_page21d[(wc >> 4) - 0x21d0]; + else if (wc >= 0x22000 && wc < 0x22080) + summary = &hkscs2001_uni2indx_page220[(wc >> 4) - 0x2200]; + else if (wc >= 0x22700 && wc < 0x22720) + summary = &hkscs2001_uni2indx_page227[(wc >> 4) - 0x2270]; + else if (wc >= 0x23200 && wc < 0x23400) + summary = &hkscs2001_uni2indx_page232[(wc >> 4) - 0x2320]; + else if (wc >= 0x23c00 && wc < 0x23c70) + summary = &hkscs2001_uni2indx_page23c[(wc >> 4) - 0x23c0]; + else if (wc >= 0x24100 && wc < 0x24150) + summary = &hkscs2001_uni2indx_page241[(wc >> 4) - 0x2410]; + else if (wc >= 0x24500 && wc < 0x24510) + summary = &hkscs2001_uni2indx_page245[(wc >> 4) - 0x2450]; + else if (wc >= 0x24900 && wc < 0x24a20) + summary = &hkscs2001_uni2indx_page249[(wc >> 4) - 0x2490]; + else if (wc >= 0x25100 && wc < 0x251d0) + summary = &hkscs2001_uni2indx_page251[(wc >> 4) - 0x2510]; + } + else + { + if (wc >= 0x25600 && wc < 0x256a0) + summary = &hkscs2001_uni2indx_page256[(wc >> 4) - 0x2560]; + else if (wc >= 0x25c00 && wc < 0x25d40) + summary = &hkscs2001_uni2indx_page25c[(wc >> 4) - 0x25c0]; + else if (wc >= 0x26b00 && wc < 0x26b20) + summary = &hkscs2001_uni2indx_page26b[(wc >> 4) - 0x26b0]; + else if (wc >= 0x26d00 && wc < 0x26d80) + summary = &hkscs2001_uni2indx_page26d[(wc >> 4) - 0x26d0]; + else if (wc >= 0x26f00 && wc < 0x26fc0) + summary = &hkscs2001_uni2indx_page26f[(wc >> 4) - 0x26f0]; + else if (wc >= 0x27100 && wc < 0x27110) + summary = &hkscs2001_uni2indx_page271[(wc >> 4) - 0x2710]; + else if (wc >= 0x28700 && wc < 0x28710) + summary = &hkscs2001_uni2indx_page287[(wc >> 4) - 0x2870]; + else if (wc >= 0x28900 && wc < 0x28af0) + summary = &hkscs2001_uni2indx_page289[(wc >> 4) - 0x2890]; + else if (wc >= 0x28d00 && wc < 0x28dc0) + summary = &hkscs2001_uni2indx_page28d[(wc >> 4) - 0x28d0]; + else if (wc >= 0x29900 && wc < 0x29950) + summary = &hkscs2001_uni2indx_page299[(wc >> 4) - 0x2990]; + else if (wc >= 0x29c00 && wc < 0x29c80) + summary = &hkscs2001_uni2indx_page29c[(wc >> 4) - 0x29c0]; + else if (wc >= 0x2a100 && wc < 0x2a2c0) + summary = &hkscs2001_uni2indx_page2a1[(wc >> 4) - 0x2a10]; + } + } + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = hkscs2001_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _HKSCS2001_H_ */ diff --git a/lib/hkscs2004.h b/lib/converters/hkscs2004.h similarity index 72% rename from lib/hkscs2004.h rename to lib/converters/hkscs2004.h index 64966ca8..53f464eb 100644 --- a/lib/hkscs2004.h +++ b/lib/converters/hkscs2004.h @@ -1,5 +1,10 @@ +/** + * @file hkscs2004.h + * @brief HKSCS:2004 + * @copyright Copyright (C) 1999-2006, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2006, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * HKSCS:2004 - */ +#ifndef _HKSCS2004_H_ +#define _HKSCS2004_H_ + +#include "reiconv_defines.h" static const unsigned short hkscs2004_2uni_page87[58] = { /* 0x87 */ @@ -74,36 +80,40 @@ static const ucs4_t hkscs2004_2uni_upages[78] = { 0x29000, 0x29800, 0x29900, 0x29e00, 0x2a100, 0x2a300, }; -static int -hkscs2004_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int hkscs2004_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 == 0x87) || (c1 >= 0x8c && c1 <= 0x8d)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) { - unsigned int i = 157 * (c1 - 0x80) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); - ucs4_t wc = 0xfffd; - unsigned short swc; - if (i < 1884) { - if (i < 1157) - swc = hkscs2004_2uni_page87[i-1099], - wc = hkscs2004_2uni_upages[swc>>8] | (swc & 0xff); - } else { - if (i < 2073) - swc = hkscs2004_2uni_page8c[i-1884], - wc = hkscs2004_2uni_upages[swc>>8] | (swc & 0xff); - } - if (wc != 0xfffd) { - *pwc = wc; - return 2; + unsigned char c1 = s[0]; + if ((c1 == 0x87) || (c1 >= 0x8c && c1 <= 0x8d)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) + { + unsigned int i = 157 * (c1 - 0x80) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); + ucs4_t wc = 0xfffd; + unsigned short swc; + if (i < 1884) + { + if (i < 1157) + swc = hkscs2004_2uni_page87[i - 1099], wc = hkscs2004_2uni_upages[swc >> 8] | (swc & 0xff); + } + else + { + if (i < 2073) + swc = hkscs2004_2uni_page8c[i - 1884], wc = hkscs2004_2uni_upages[swc >> 8] | (swc & 0xff); + } + if (wc != 0xfffd) + { + *pwc = wc; + return 2; + } + } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned short hkscs2004_2charset[123] = { @@ -541,138 +551,152 @@ static const Summary16 hkscs2004_uni2indx_page2a3[6] = { { 122, 0x0000 }, { 122, 0x0002 }, }; -static int -hkscs2004_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int hkscs2004_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc < 0x21a00) { - if (wc < 0x6e00) { - if (wc >= 0x3400 && wc < 0x3450) - summary = &hkscs2004_uni2indx_page34[(wc>>4)-0x340]; - else if (wc >= 0x3600 && wc < 0x3980) - summary = &hkscs2004_uni2indx_page36[(wc>>4)-0x360]; - else if (wc >= 0x3b00 && wc < 0x3ba0) - summary = &hkscs2004_uni2indx_page3b[(wc>>4)-0x3b0]; - else if (wc >= 0x3d00 && wc < 0x3e00) - summary = &hkscs2004_uni2indx_page3d[(wc>>4)-0x3d0]; - else if (wc >= 0x3f00 && wc < 0x41f0) - summary = &hkscs2004_uni2indx_page3f[(wc>>4)-0x3f0]; - else if (wc >= 0x4300 && wc < 0x4750) - summary = &hkscs2004_uni2indx_page43[(wc>>4)-0x430]; - else if (wc >= 0x4a00 && wc < 0x4ab0) - summary = &hkscs2004_uni2indx_page4a[(wc>>4)-0x4a0]; - else if (wc >= 0x4c00 && wc < 0x4d90) - summary = &hkscs2004_uni2indx_page4c[(wc>>4)-0x4c0]; - else if (wc >= 0x4f00 && wc < 0x4fc0) - summary = &hkscs2004_uni2indx_page4f[(wc>>4)-0x4f0]; - else if (wc >= 0x5600 && wc < 0x5700) - summary = &hkscs2004_uni2indx_page56[(wc>>4)-0x560]; - else if (wc >= 0x5900 && wc < 0x5d80) - summary = &hkscs2004_uni2indx_page59[(wc>>4)-0x590]; - else if (wc >= 0x5f00 && wc < 0x5f40) - summary = &hkscs2004_uni2indx_page5f[(wc>>4)-0x5f0]; - else if (wc >= 0x6600 && wc < 0x6770) - summary = &hkscs2004_uni2indx_page66[(wc>>4)-0x660]; - } else { - if (wc >= 0x6e00 && wc < 0x6e60) - summary = &hkscs2004_uni2indx_page6e[(wc>>4)-0x6e0]; - else if (wc >= 0x7100 && wc < 0x7230) - summary = &hkscs2004_uni2indx_page71[(wc>>4)-0x710]; - else if (wc >= 0x7400 && wc < 0x74a0) - summary = &hkscs2004_uni2indx_page74[(wc>>4)-0x740]; - else if (wc >= 0x7900 && wc < 0x79d0) - summary = &hkscs2004_uni2indx_page79[(wc>>4)-0x790]; - else if (wc >= 0x7d00 && wc < 0x7da0) - summary = &hkscs2004_uni2indx_page7d[(wc>>4)-0x7d0]; - else if (wc >= 0x8100 && wc < 0x8170) - summary = &hkscs2004_uni2indx_page81[(wc>>4)-0x810]; - else if (wc >= 0x8500 && wc < 0x85a0) - summary = &hkscs2004_uni2indx_page85[(wc>>4)-0x850]; - else if (wc >= 0x8a00 && wc < 0x8b00) - summary = &hkscs2004_uni2indx_page8a[(wc>>4)-0x8a0]; - else if (wc >= 0x9700 && wc < 0x9860) - summary = &hkscs2004_uni2indx_page97[(wc>>4)-0x970]; - else if (wc >= 0x9f00 && wc < 0x9fc0) - summary = &hkscs2004_uni2indx_page9f[(wc>>4)-0x9f0]; - else if (wc >= 0x20100 && wc < 0x20240) - summary = &hkscs2004_uni2indx_page201[(wc>>4)-0x2010]; - else if (wc >= 0x20a00 && wc < 0x20ba0) - summary = &hkscs2004_uni2indx_page20a[(wc>>4)-0x20a0]; - } - } else { - if (wc < 0x26b00) { - if (wc >= 0x21a00 && wc < 0x21a70) - summary = &hkscs2004_uni2indx_page21a[(wc>>4)-0x21a0]; - else if (wc >= 0x21d00 && wc < 0x21e30) - summary = &hkscs2004_uni2indx_page21d[(wc>>4)-0x21d0]; - else if (wc >= 0x22100 && wc < 0x221d0) - summary = &hkscs2004_uni2indx_page221[(wc>>4)-0x2210]; - else if (wc >= 0x22700 && wc < 0x227a0) - summary = &hkscs2004_uni2indx_page227[(wc>>4)-0x2270]; - else if (wc >= 0x23200 && wc < 0x23260) - summary = &hkscs2004_uni2indx_page232[(wc>>4)-0x2320]; - else if (wc >= 0x23500 && wc < 0x23620) - summary = &hkscs2004_uni2indx_page235[(wc>>4)-0x2350]; - else if (wc >= 0x23b00 && wc < 0x23b20) - summary = &hkscs2004_uni2indx_page23b[(wc>>4)-0x23b0]; - else if (wc >= 0x23e00 && wc < 0x240f0) - summary = &hkscs2004_uni2indx_page23e[(wc>>4)-0x23e0]; - else if (wc >= 0x24200 && wc < 0x242c0) - summary = &hkscs2004_uni2indx_page242[(wc>>4)-0x2420]; - else if (wc >= 0x24b00 && wc < 0x24b10) - summary = &hkscs2004_uni2indx_page24b[(wc>>4)-0x24b0]; - else if (wc >= 0x25400 && wc < 0x254a0) - summary = &hkscs2004_uni2indx_page254[(wc>>4)-0x2540]; - else if (wc >= 0x25a00 && wc < 0x25a60) - summary = &hkscs2004_uni2indx_page25a[(wc>>4)-0x25a0]; - } else { - if (wc >= 0x26b00 && wc < 0x26c50) - summary = &hkscs2004_uni2indx_page26b[(wc>>4)-0x26b0]; - else if (wc >= 0x26e00 && wc < 0x26e90) - summary = &hkscs2004_uni2indx_page26e[(wc>>4)-0x26e0]; - else if (wc >= 0x27000 && wc < 0x270e0) - summary = &hkscs2004_uni2indx_page270[(wc>>4)-0x2700]; - else if (wc >= 0x27200 && wc < 0x27400) - summary = &hkscs2004_uni2indx_page272[(wc>>4)-0x2720]; - else if (wc >= 0x27b00 && wc < 0x27cd0) - summary = &hkscs2004_uni2indx_page27b[(wc>>4)-0x27b0]; - else if (wc >= 0x28600 && wc < 0x286c0) - summary = &hkscs2004_uni2indx_page286[(wc>>4)-0x2860]; - else if (wc >= 0x28900 && wc < 0x28970) - summary = &hkscs2004_uni2indx_page289[(wc>>4)-0x2890]; - else if (wc >= 0x28b00 && wc < 0x28bc0) - summary = &hkscs2004_uni2indx_page28b[(wc>>4)-0x28b0]; - else if (wc >= 0x29000 && wc < 0x29080) - summary = &hkscs2004_uni2indx_page290[(wc>>4)-0x2900]; - else if (wc >= 0x29800 && wc < 0x29950) - summary = &hkscs2004_uni2indx_page298[(wc>>4)-0x2980]; - else if (wc >= 0x29e00 && wc < 0x29ec0) - summary = &hkscs2004_uni2indx_page29e[(wc>>4)-0x29e0]; - else if (wc >= 0x2a100 && wc < 0x2a1c0) - summary = &hkscs2004_uni2indx_page2a1[(wc>>4)-0x2a10]; - else if (wc >= 0x2a300 && wc < 0x2a360) - summary = &hkscs2004_uni2indx_page2a3[(wc>>4)-0x2a30]; - } - } - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = hkscs2004_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc < 0x21a00) + { + if (wc < 0x6e00) + { + if (wc >= 0x3400 && wc < 0x3450) + summary = &hkscs2004_uni2indx_page34[(wc >> 4) - 0x340]; + else if (wc >= 0x3600 && wc < 0x3980) + summary = &hkscs2004_uni2indx_page36[(wc >> 4) - 0x360]; + else if (wc >= 0x3b00 && wc < 0x3ba0) + summary = &hkscs2004_uni2indx_page3b[(wc >> 4) - 0x3b0]; + else if (wc >= 0x3d00 && wc < 0x3e00) + summary = &hkscs2004_uni2indx_page3d[(wc >> 4) - 0x3d0]; + else if (wc >= 0x3f00 && wc < 0x41f0) + summary = &hkscs2004_uni2indx_page3f[(wc >> 4) - 0x3f0]; + else if (wc >= 0x4300 && wc < 0x4750) + summary = &hkscs2004_uni2indx_page43[(wc >> 4) - 0x430]; + else if (wc >= 0x4a00 && wc < 0x4ab0) + summary = &hkscs2004_uni2indx_page4a[(wc >> 4) - 0x4a0]; + else if (wc >= 0x4c00 && wc < 0x4d90) + summary = &hkscs2004_uni2indx_page4c[(wc >> 4) - 0x4c0]; + else if (wc >= 0x4f00 && wc < 0x4fc0) + summary = &hkscs2004_uni2indx_page4f[(wc >> 4) - 0x4f0]; + else if (wc >= 0x5600 && wc < 0x5700) + summary = &hkscs2004_uni2indx_page56[(wc >> 4) - 0x560]; + else if (wc >= 0x5900 && wc < 0x5d80) + summary = &hkscs2004_uni2indx_page59[(wc >> 4) - 0x590]; + else if (wc >= 0x5f00 && wc < 0x5f40) + summary = &hkscs2004_uni2indx_page5f[(wc >> 4) - 0x5f0]; + else if (wc >= 0x6600 && wc < 0x6770) + summary = &hkscs2004_uni2indx_page66[(wc >> 4) - 0x660]; + } + else + { + if (wc >= 0x6e00 && wc < 0x6e60) + summary = &hkscs2004_uni2indx_page6e[(wc >> 4) - 0x6e0]; + else if (wc >= 0x7100 && wc < 0x7230) + summary = &hkscs2004_uni2indx_page71[(wc >> 4) - 0x710]; + else if (wc >= 0x7400 && wc < 0x74a0) + summary = &hkscs2004_uni2indx_page74[(wc >> 4) - 0x740]; + else if (wc >= 0x7900 && wc < 0x79d0) + summary = &hkscs2004_uni2indx_page79[(wc >> 4) - 0x790]; + else if (wc >= 0x7d00 && wc < 0x7da0) + summary = &hkscs2004_uni2indx_page7d[(wc >> 4) - 0x7d0]; + else if (wc >= 0x8100 && wc < 0x8170) + summary = &hkscs2004_uni2indx_page81[(wc >> 4) - 0x810]; + else if (wc >= 0x8500 && wc < 0x85a0) + summary = &hkscs2004_uni2indx_page85[(wc >> 4) - 0x850]; + else if (wc >= 0x8a00 && wc < 0x8b00) + summary = &hkscs2004_uni2indx_page8a[(wc >> 4) - 0x8a0]; + else if (wc >= 0x9700 && wc < 0x9860) + summary = &hkscs2004_uni2indx_page97[(wc >> 4) - 0x970]; + else if (wc >= 0x9f00 && wc < 0x9fc0) + summary = &hkscs2004_uni2indx_page9f[(wc >> 4) - 0x9f0]; + else if (wc >= 0x20100 && wc < 0x20240) + summary = &hkscs2004_uni2indx_page201[(wc >> 4) - 0x2010]; + else if (wc >= 0x20a00 && wc < 0x20ba0) + summary = &hkscs2004_uni2indx_page20a[(wc >> 4) - 0x20a0]; + } + } + else + { + if (wc < 0x26b00) + { + if (wc >= 0x21a00 && wc < 0x21a70) + summary = &hkscs2004_uni2indx_page21a[(wc >> 4) - 0x21a0]; + else if (wc >= 0x21d00 && wc < 0x21e30) + summary = &hkscs2004_uni2indx_page21d[(wc >> 4) - 0x21d0]; + else if (wc >= 0x22100 && wc < 0x221d0) + summary = &hkscs2004_uni2indx_page221[(wc >> 4) - 0x2210]; + else if (wc >= 0x22700 && wc < 0x227a0) + summary = &hkscs2004_uni2indx_page227[(wc >> 4) - 0x2270]; + else if (wc >= 0x23200 && wc < 0x23260) + summary = &hkscs2004_uni2indx_page232[(wc >> 4) - 0x2320]; + else if (wc >= 0x23500 && wc < 0x23620) + summary = &hkscs2004_uni2indx_page235[(wc >> 4) - 0x2350]; + else if (wc >= 0x23b00 && wc < 0x23b20) + summary = &hkscs2004_uni2indx_page23b[(wc >> 4) - 0x23b0]; + else if (wc >= 0x23e00 && wc < 0x240f0) + summary = &hkscs2004_uni2indx_page23e[(wc >> 4) - 0x23e0]; + else if (wc >= 0x24200 && wc < 0x242c0) + summary = &hkscs2004_uni2indx_page242[(wc >> 4) - 0x2420]; + else if (wc >= 0x24b00 && wc < 0x24b10) + summary = &hkscs2004_uni2indx_page24b[(wc >> 4) - 0x24b0]; + else if (wc >= 0x25400 && wc < 0x254a0) + summary = &hkscs2004_uni2indx_page254[(wc >> 4) - 0x2540]; + else if (wc >= 0x25a00 && wc < 0x25a60) + summary = &hkscs2004_uni2indx_page25a[(wc >> 4) - 0x25a0]; + } + else + { + if (wc >= 0x26b00 && wc < 0x26c50) + summary = &hkscs2004_uni2indx_page26b[(wc >> 4) - 0x26b0]; + else if (wc >= 0x26e00 && wc < 0x26e90) + summary = &hkscs2004_uni2indx_page26e[(wc >> 4) - 0x26e0]; + else if (wc >= 0x27000 && wc < 0x270e0) + summary = &hkscs2004_uni2indx_page270[(wc >> 4) - 0x2700]; + else if (wc >= 0x27200 && wc < 0x27400) + summary = &hkscs2004_uni2indx_page272[(wc >> 4) - 0x2720]; + else if (wc >= 0x27b00 && wc < 0x27cd0) + summary = &hkscs2004_uni2indx_page27b[(wc >> 4) - 0x27b0]; + else if (wc >= 0x28600 && wc < 0x286c0) + summary = &hkscs2004_uni2indx_page286[(wc >> 4) - 0x2860]; + else if (wc >= 0x28900 && wc < 0x28970) + summary = &hkscs2004_uni2indx_page289[(wc >> 4) - 0x2890]; + else if (wc >= 0x28b00 && wc < 0x28bc0) + summary = &hkscs2004_uni2indx_page28b[(wc >> 4) - 0x28b0]; + else if (wc >= 0x29000 && wc < 0x29080) + summary = &hkscs2004_uni2indx_page290[(wc >> 4) - 0x2900]; + else if (wc >= 0x29800 && wc < 0x29950) + summary = &hkscs2004_uni2indx_page298[(wc >> 4) - 0x2980]; + else if (wc >= 0x29e00 && wc < 0x29ec0) + summary = &hkscs2004_uni2indx_page29e[(wc >> 4) - 0x29e0]; + else if (wc >= 0x2a100 && wc < 0x2a1c0) + summary = &hkscs2004_uni2indx_page2a1[(wc >> 4) - 0x2a10]; + else if (wc >= 0x2a300 && wc < 0x2a360) + summary = &hkscs2004_uni2indx_page2a3[(wc >> 4) - 0x2a30]; + } + } + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = hkscs2004_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _HKSCS2004_H_ */ diff --git a/lib/hkscs2008.h b/lib/converters/hkscs2008.h similarity index 69% rename from lib/hkscs2008.h rename to lib/converters/hkscs2008.h index 79eb1744..d6bd22a0 100644 --- a/lib/hkscs2008.h +++ b/lib/converters/hkscs2008.h @@ -1,5 +1,10 @@ +/** + * @file hkscs2008.h + * @brief HKSCS:2008 + * @copyright Copyright (C) 1999-2010, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2010, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * HKSCS:2008 - */ +#ifndef _HKSCS2008_H_ +#define _HKSCS2008_H_ + +#include "reiconv_defines.h" static const unsigned short hkscs2008_2uni_page87[126] = { /* 0x87 */ @@ -51,32 +57,34 @@ static const ucs4_t hkscs2008_2uni_upages[50] = { 0x28900, 0x2ad00, }; -static int -hkscs2008_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int hkscs2008_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if (c1 == (unsigned char)0x87) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) { - unsigned int i = 157 * (c1 - 0x80) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); - ucs4_t wc = 0xfffd; - unsigned short swc; + unsigned char c1 = s[0]; + if (c1 == (unsigned char)0x87) + { + if (n >= 2) { - if (i < 1225) - swc = hkscs2008_2uni_page87[i-1099], - wc = hkscs2008_2uni_upages[swc>>8] | (swc & 0xff); + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) + { + unsigned int i = 157 * (c1 - 0x80) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); + ucs4_t wc = 0xfffd; + unsigned short swc; + { + if (i < 1225) + swc = hkscs2008_2uni_page87[i - 1099], wc = hkscs2008_2uni_upages[swc >> 8] | (swc & 0xff); + } + if (wc != 0xfffd) + { + *pwc = wc; + return 2; + } + } + return RET_ILSEQ; } - if (wc != 0xfffd) { - *pwc = wc; - return 2; - } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned short hkscs2008_2charset[68] = { @@ -362,105 +370,110 @@ static const Summary16 hkscs2008_uni2indx_page2ad[16] = { { 67, 0x0000 }, { 67, 0x0000 }, { 67, 0x0000 }, { 67, 0x8000 }, }; -static int -hkscs2008_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int hkscs2008_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc >= 0x3400 && wc < 0x34f0) - summary = &hkscs2008_uni2indx_page34[(wc>>4)-0x340]; - else if (wc >= 0x3800 && wc < 0x3880) - summary = &hkscs2008_uni2indx_page38[(wc>>4)-0x380]; - else if (wc >= 0x3a00 && wc < 0x3b00) - summary = &hkscs2008_uni2indx_page3a[(wc>>4)-0x3a0]; - else if (wc >= 0x3e00 && wc < 0x3ef0) - summary = &hkscs2008_uni2indx_page3e[(wc>>4)-0x3e0]; - else if (wc >= 0x4000 && wc < 0x4190) - summary = &hkscs2008_uni2indx_page40[(wc>>4)-0x400]; - else if (wc >= 0x4300 && wc < 0x44f0) - summary = &hkscs2008_uni2indx_page43[(wc>>4)-0x430]; - else if (wc >= 0x4600 && wc < 0x46b0) - summary = &hkscs2008_uni2indx_page46[(wc>>4)-0x460]; - else if (wc >= 0x4900 && wc < 0x4940) - summary = &hkscs2008_uni2indx_page49[(wc>>4)-0x490]; - else if (wc >= 0x5200 && wc < 0x5250) - summary = &hkscs2008_uni2indx_page52[(wc>>4)-0x520]; - else if (wc >= 0x5400 && wc < 0x5450) - summary = &hkscs2008_uni2indx_page54[(wc>>4)-0x540]; - else if (wc >= 0x5700 && wc < 0x58a0) - summary = &hkscs2008_uni2indx_page57[(wc>>4)-0x570]; - else if (wc >= 0x6200 && wc < 0x62d0) - summary = &hkscs2008_uni2indx_page62[(wc>>4)-0x620]; - else if (wc >= 0x6600 && wc < 0x6790) - summary = &hkscs2008_uni2indx_page66[(wc>>4)-0x660]; - else if (wc >= 0x6a00 && wc < 0x6a30) - summary = &hkscs2008_uni2indx_page6a[(wc>>4)-0x6a0]; - else if (wc >= 0x7000 && wc < 0x7070) - summary = &hkscs2008_uni2indx_page70[(wc>>4)-0x700]; - else if (wc >= 0x7300 && wc < 0x74d0) - summary = &hkscs2008_uni2indx_page73[(wc>>4)-0x730]; - else if (wc >= 0x7900 && wc < 0x7bd0) - summary = &hkscs2008_uni2indx_page79[(wc>>4)-0x790]; - else if (wc >= 0x8400 && wc < 0x8620) - summary = &hkscs2008_uni2indx_page84[(wc>>4)-0x840]; - else if (wc >= 0x8800 && wc < 0x88a0) - summary = &hkscs2008_uni2indx_page88[(wc>>4)-0x880]; - else if (wc >= 0x8b00 && wc < 0x8b90) - summary = &hkscs2008_uni2indx_page8b[(wc>>4)-0x8b0]; - else if (wc >= 0x9000 && wc < 0x9050) - summary = &hkscs2008_uni2indx_page90[(wc>>4)-0x900]; - else if (wc >= 0x9200 && wc < 0x9220) - summary = &hkscs2008_uni2indx_page92[(wc>>4)-0x920]; - else if (wc >= 0x9400 && wc < 0x9430) - summary = &hkscs2008_uni2indx_page94[(wc>>4)-0x940]; - else if (wc >= 0x9700 && wc < 0x9750) - summary = &hkscs2008_uni2indx_page97[(wc>>4)-0x970]; - else if (wc >= 0x9f00 && wc < 0x9fd0) - summary = &hkscs2008_uni2indx_page9f[(wc>>4)-0x9f0]; - else if (wc >= 0x20a00 && wc < 0x20a90) - summary = &hkscs2008_uni2indx_page20a[(wc>>4)-0x20a0]; - else if (wc >= 0x21d00 && wc < 0x21d60) - summary = &hkscs2008_uni2indx_page21d[(wc>>4)-0x21d0]; - else if (wc >= 0x22400 && wc < 0x224d0) - summary = &hkscs2008_uni2indx_page224[(wc>>4)-0x2240]; - else if (wc >= 0x23100 && wc < 0x23260) - summary = &hkscs2008_uni2indx_page231[(wc>>4)-0x2310]; - else if (wc >= 0x23500 && wc < 0x236a0) - summary = &hkscs2008_uni2indx_page235[(wc>>4)-0x2350]; - else if (wc >= 0x24100 && wc < 0x24170) - summary = &hkscs2008_uni2indx_page241[(wc>>4)-0x2410]; - else if (wc >= 0x25800 && wc < 0x258e0) - summary = &hkscs2008_uni2indx_page258[(wc>>4)-0x2580]; - else if (wc >= 0x25d00 && wc < 0x25dc0) - summary = &hkscs2008_uni2indx_page25d[(wc>>4)-0x25d0]; - else if (wc >= 0x26000 && wc < 0x26030) - summary = &hkscs2008_uni2indx_page260[(wc>>4)-0x2600]; - else if (wc >= 0x26e00 && wc < 0x26e90) - summary = &hkscs2008_uni2indx_page26e[(wc>>4)-0x26e0]; - else if (wc >= 0x27b00 && wc < 0x27b70) - summary = &hkscs2008_uni2indx_page27b[(wc>>4)-0x27b0]; - else if (wc >= 0x28900 && wc < 0x28910) - summary = &hkscs2008_uni2indx_page289[(wc>>4)-0x2890]; - else if (wc >= 0x2ad00 && wc < 0x2ae00) - summary = &hkscs2008_uni2indx_page2ad[(wc>>4)-0x2ad0]; - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = hkscs2008_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc >= 0x3400 && wc < 0x34f0) + summary = &hkscs2008_uni2indx_page34[(wc >> 4) - 0x340]; + else if (wc >= 0x3800 && wc < 0x3880) + summary = &hkscs2008_uni2indx_page38[(wc >> 4) - 0x380]; + else if (wc >= 0x3a00 && wc < 0x3b00) + summary = &hkscs2008_uni2indx_page3a[(wc >> 4) - 0x3a0]; + else if (wc >= 0x3e00 && wc < 0x3ef0) + summary = &hkscs2008_uni2indx_page3e[(wc >> 4) - 0x3e0]; + else if (wc >= 0x4000 && wc < 0x4190) + summary = &hkscs2008_uni2indx_page40[(wc >> 4) - 0x400]; + else if (wc >= 0x4300 && wc < 0x44f0) + summary = &hkscs2008_uni2indx_page43[(wc >> 4) - 0x430]; + else if (wc >= 0x4600 && wc < 0x46b0) + summary = &hkscs2008_uni2indx_page46[(wc >> 4) - 0x460]; + else if (wc >= 0x4900 && wc < 0x4940) + summary = &hkscs2008_uni2indx_page49[(wc >> 4) - 0x490]; + else if (wc >= 0x5200 && wc < 0x5250) + summary = &hkscs2008_uni2indx_page52[(wc >> 4) - 0x520]; + else if (wc >= 0x5400 && wc < 0x5450) + summary = &hkscs2008_uni2indx_page54[(wc >> 4) - 0x540]; + else if (wc >= 0x5700 && wc < 0x58a0) + summary = &hkscs2008_uni2indx_page57[(wc >> 4) - 0x570]; + else if (wc >= 0x6200 && wc < 0x62d0) + summary = &hkscs2008_uni2indx_page62[(wc >> 4) - 0x620]; + else if (wc >= 0x6600 && wc < 0x6790) + summary = &hkscs2008_uni2indx_page66[(wc >> 4) - 0x660]; + else if (wc >= 0x6a00 && wc < 0x6a30) + summary = &hkscs2008_uni2indx_page6a[(wc >> 4) - 0x6a0]; + else if (wc >= 0x7000 && wc < 0x7070) + summary = &hkscs2008_uni2indx_page70[(wc >> 4) - 0x700]; + else if (wc >= 0x7300 && wc < 0x74d0) + summary = &hkscs2008_uni2indx_page73[(wc >> 4) - 0x730]; + else if (wc >= 0x7900 && wc < 0x7bd0) + summary = &hkscs2008_uni2indx_page79[(wc >> 4) - 0x790]; + else if (wc >= 0x8400 && wc < 0x8620) + summary = &hkscs2008_uni2indx_page84[(wc >> 4) - 0x840]; + else if (wc >= 0x8800 && wc < 0x88a0) + summary = &hkscs2008_uni2indx_page88[(wc >> 4) - 0x880]; + else if (wc >= 0x8b00 && wc < 0x8b90) + summary = &hkscs2008_uni2indx_page8b[(wc >> 4) - 0x8b0]; + else if (wc >= 0x9000 && wc < 0x9050) + summary = &hkscs2008_uni2indx_page90[(wc >> 4) - 0x900]; + else if (wc >= 0x9200 && wc < 0x9220) + summary = &hkscs2008_uni2indx_page92[(wc >> 4) - 0x920]; + else if (wc >= 0x9400 && wc < 0x9430) + summary = &hkscs2008_uni2indx_page94[(wc >> 4) - 0x940]; + else if (wc >= 0x9700 && wc < 0x9750) + summary = &hkscs2008_uni2indx_page97[(wc >> 4) - 0x970]; + else if (wc >= 0x9f00 && wc < 0x9fd0) + summary = &hkscs2008_uni2indx_page9f[(wc >> 4) - 0x9f0]; + else if (wc >= 0x20a00 && wc < 0x20a90) + summary = &hkscs2008_uni2indx_page20a[(wc >> 4) - 0x20a0]; + else if (wc >= 0x21d00 && wc < 0x21d60) + summary = &hkscs2008_uni2indx_page21d[(wc >> 4) - 0x21d0]; + else if (wc >= 0x22400 && wc < 0x224d0) + summary = &hkscs2008_uni2indx_page224[(wc >> 4) - 0x2240]; + else if (wc >= 0x23100 && wc < 0x23260) + summary = &hkscs2008_uni2indx_page231[(wc >> 4) - 0x2310]; + else if (wc >= 0x23500 && wc < 0x236a0) + summary = &hkscs2008_uni2indx_page235[(wc >> 4) - 0x2350]; + else if (wc >= 0x24100 && wc < 0x24170) + summary = &hkscs2008_uni2indx_page241[(wc >> 4) - 0x2410]; + else if (wc >= 0x25800 && wc < 0x258e0) + summary = &hkscs2008_uni2indx_page258[(wc >> 4) - 0x2580]; + else if (wc >= 0x25d00 && wc < 0x25dc0) + summary = &hkscs2008_uni2indx_page25d[(wc >> 4) - 0x25d0]; + else if (wc >= 0x26000 && wc < 0x26030) + summary = &hkscs2008_uni2indx_page260[(wc >> 4) - 0x2600]; + else if (wc >= 0x26e00 && wc < 0x26e90) + summary = &hkscs2008_uni2indx_page26e[(wc >> 4) - 0x26e0]; + else if (wc >= 0x27b00 && wc < 0x27b70) + summary = &hkscs2008_uni2indx_page27b[(wc >> 4) - 0x27b0]; + else if (wc >= 0x28900 && wc < 0x28910) + summary = &hkscs2008_uni2indx_page289[(wc >> 4) - 0x2890]; + else if (wc >= 0x2ad00 && wc < 0x2ae00) + summary = &hkscs2008_uni2indx_page2ad[(wc >> 4) - 0x2ad0]; + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = hkscs2008_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _HKSCS2008_H_ */ diff --git a/lib/hp_roman8.h b/lib/converters/hp_roman8.h similarity index 70% rename from lib/hp_roman8.h rename to lib/converters/hp_roman8.h index a51ea3a9..9b72760c 100644 --- a/lib/hp_roman8.h +++ b/lib/converters/hp_roman8.h @@ -1,5 +1,10 @@ +/** + * @file hp_roman8.h + * @brief HP-ROMAN8 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * HP-ROMAN8 - */ +#ifndef _HP_ROMAN8_H_ +#define _HP_ROMAN8_H_ + +#include "reiconv_defines.h" static const unsigned short hp_roman8_2uni[96] = { /* 0xa0 */ @@ -42,22 +48,24 @@ static const unsigned short hp_roman8_2uni[96] = { 0x00bd, 0x00aa, 0x00ba, 0x00ab, 0x25a0, 0x00bb, 0x00b1, 0xfffd, }; -static int -hp_roman8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int hp_roman8_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = hp_roman8_2uni[c-0xa0]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0xa0) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = hp_roman8_2uni[c - 0xa0]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char hp_roman8_page00[96] = { @@ -90,29 +98,32 @@ static const unsigned char hp_roman8_page02[32] = { 0x00, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ }; -static int -hp_roman8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int hp_roman8_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = hp_roman8_page00[wc-0x00a0]; - else if (wc >= 0x0160 && wc < 0x0198) - c = hp_roman8_page01[wc-0x0160]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = hp_roman8_page02[wc-0x02c0]; - else if (wc == 0x2014) - c = 0xf6; - else if (wc == 0x20a4) - c = 0xaf; - else if (wc == 0x25a0) - c = 0xfc; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = hp_roman8_page00[wc - 0x00a0]; + else if (wc >= 0x0160 && wc < 0x0198) + c = hp_roman8_page01[wc - 0x0160]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = hp_roman8_page02[wc - 0x02c0]; + else if (wc == 0x2014) + c = 0xf6; + else if (wc == 0x20a4) + c = 0xaf; + else if (wc == 0x25a0) + c = 0xfc; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _HP_ROMAN8_H_ */ diff --git a/lib/converters/hz.h b/lib/converters/hz.h new file mode 100644 index 00000000..583fdf7b --- /dev/null +++ b/lib/converters/hz.h @@ -0,0 +1,197 @@ +/** + * @file hz.h + * @brief HZ + * @copyright Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _HZ_H_ +#define _HZ_H_ + +#include "converters/ascii.h" +#include "converters/gb2312.h" +#include "reiconv_defines.h" +#include + +/* Specification: RFC 1842, RFC 1843 */ + +/* + * The state is 1 in GB mode, 0 in ASCII mode. + */ + +static int hz_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + state_t state = conv->istate; + unsigned int count = 0; + unsigned char c; + for (;;) + { + c = *s; + if (c == '~') + { + if (n < count + 2) + goto none; + c = s[1]; + if (state == 0) + { + if (c == '~') + { + *pwc = (ucs4_t)'~'; + conv->istate = state; + return count + 2; + } + if (c == '{') + { + state = 1; + s += 2; + count += 2; + if (n < count + 1) + goto none; + continue; + } + if (c == '\n') + { + s += 2; + count += 2; + if (n < count + 1) + goto none; + continue; + } + } + else + { + if (c == '}') + { + state = 0; + s += 2; + count += 2; + if (n < count + 1) + goto none; + continue; + } + } + goto ilseq; + } + break; + } + if (state == 0) + { + *pwc = (ucs4_t)c; + conv->istate = state; + return count + 1; + } + else + { + int ret; + if (n < count + 2) + goto none; + ret = gb2312_mbtowc(conv, pwc, s, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + conv->istate = state; + return count + 2; + } + +none: + conv->istate = state; + return RET_TOOFEW(count); + +ilseq: + conv->istate = state; + return RET_SHIFT_ILSEQ(count); +} + +static int hz_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + state_t state = conv->ostate; + unsigned char buf[2]; + int ret; + + /* Code set 0 (ASCII or GB 1988-89) */ + ret = ascii_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] < 0x80) + { + int count = (state ? 3 : 1); + if (n < count) + return RET_TOOSMALL; + if (state) + { + r[0] = '~'; + r[1] = '}'; + r += 2; + state = 0; + } + r[0] = buf[0]; + conv->ostate = state; + return count; + } + } + + /* Code set 1 (GB 2312-1980) */ + ret = gb2312_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state ? 2 : 4); + if (n < count) + return RET_TOOSMALL; + if (!state) + { + r[0] = '~'; + r[1] = '{'; + r += 2; + state = 1; + } + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = state; + return count; + } + } + + return RET_ILUNI; +} + +static int hz_reset(conv_t conv, unsigned char *r, size_t n) +{ + state_t state = conv->ostate; + if (state) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = '~'; + r[1] = '}'; + /* conv->ostate = 0; will be done by the caller */ + return 2; + } + else + return 0; +} + +#endif /* _HZ_H_ */ diff --git a/lib/converters/iso2022_cn.h b/lib/converters/iso2022_cn.h new file mode 100644 index 00000000..2110bc60 --- /dev/null +++ b/lib/converters/iso2022_cn.h @@ -0,0 +1,387 @@ +/** + * @file iso2022_cn.h + * @brief ISO-2022-CN + * @copyright Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _ISO2022_CN_H_ +#define _ISO2022_CN_H_ + +#include "converters/ascii.h" +#include "converters/cns11643.h" +#include "converters/cns11643_1.h" +#include "converters/cns11643_2.h" +#include "converters/gb2312.h" +#include "reiconv_defines.h" +#include + +/* Specification: RFC 1922 */ + +#define ESC 0x1b +#define SO 0x0e +#define SI 0x0f + +/* + * The state is composed of one of the following values + */ +#define STATE_ASCII 0 +#define STATE_TWOBYTE 1 +/* + * and one of the following values, << 8 + */ +#define STATE2_NONE 0 +#define STATE2_DESIGNATED_GB2312 1 +#define STATE2_DESIGNATED_CNS11643_1 2 +/* + * and one of the following values, << 16 + */ +#define STATE3_NONE 0 +#define STATE3_DESIGNATED_CNS11643_2 1 + +#define SPLIT_STATE unsigned int state1 = state & 0xff, state2 = (state >> 8) & 0xff, state3 = state >> 16 +#define COMBINE_STATE state = (state3 << 16) | (state2 << 8) | state1 + +static int iso2022_cn_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + state_t state = conv->istate; + SPLIT_STATE; + int count = 0; + unsigned char c; + for (;;) + { + c = *s; + if (c == ESC) + { + if (n < count + 4) + goto none; + if (s[1] == '$') + { + if (s[2] == ')') + { + if (s[3] == 'A') + { + state2 = STATE2_DESIGNATED_GB2312; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + if (s[3] == 'G') + { + state2 = STATE2_DESIGNATED_CNS11643_1; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + } + if (s[2] == '*') + { + if (s[3] == 'H') + { + state3 = STATE3_DESIGNATED_CNS11643_2; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + } + } + if (s[1] == 'N') + { + switch (state3) + { + case STATE3_NONE: + goto ilseq; + case STATE3_DESIGNATED_CNS11643_2: + if (s[2] < 0x80 && s[3] < 0x80) + { + int ret = cns11643_2_mbtowc(conv, pwc, s + 2, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 4; + } + else + goto ilseq; + default: + abort(); + } + } + goto ilseq; + } + if (c == SO) + { + if (state2 != STATE2_DESIGNATED_GB2312 && state2 != STATE2_DESIGNATED_CNS11643_1) + goto ilseq; + state1 = STATE_TWOBYTE; + s++; + count++; + if (n < count + 1) + goto none; + continue; + } + if (c == SI) + { + state1 = STATE_ASCII; + s++; + count++; + if (n < count + 1) + goto none; + continue; + } + break; + } + switch (state1) + { + case STATE_ASCII: + if (c < 0x80) + { + int ret = ascii_mbtowc(conv, pwc, s, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + if (*pwc == 0x000a || *pwc == 0x000d) + { + state2 = STATE2_NONE; + state3 = STATE3_NONE; + } + COMBINE_STATE; + conv->istate = state; + return count + 1; + } + else + goto ilseq; + case STATE_TWOBYTE: + if (n < count + 2) + goto none; + if (s[0] < 0x80 && s[1] < 0x80) + { + int ret; + switch (state2) + { + case STATE2_NONE: + goto ilseq; + case STATE2_DESIGNATED_GB2312: + ret = gb2312_mbtowc(conv, pwc, s, 2); + break; + case STATE2_DESIGNATED_CNS11643_1: + ret = cns11643_1_mbtowc(conv, pwc, s, 2); + break; + default: + abort(); + } + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 2; + } + else + goto ilseq; + default: + abort(); + } + +none: + COMBINE_STATE; + conv->istate = state; + return RET_TOOFEW(count); + +ilseq: + COMBINE_STATE; + conv->istate = state; + return RET_SHIFT_ILSEQ(count); +} + +static int iso2022_cn_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + state_t state = conv->ostate; + SPLIT_STATE; + unsigned char buf[3]; + int ret; + + /* There is no need to handle Unicode 3.1 tag characters and to look for + "zh-CN" or "zh-TW" tags, because GB2312 and CNS11643 are disjoint. */ + + /* Try ASCII. */ + ret = ascii_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] < 0x80) + { + int count = (state1 == STATE_ASCII ? 1 : 2); + if (n < count) + return RET_TOOSMALL; + if (state1 != STATE_ASCII) + { + r[0] = SI; + r += 1; + state1 = STATE_ASCII; + } + r[0] = buf[0]; + if (wc == 0x000a || wc == 0x000d) + { + state2 = STATE2_NONE; + state3 = STATE3_NONE; + } + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + /* Try GB 2312-1980. */ + ret = gb2312_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state2 == STATE2_DESIGNATED_GB2312 ? 0 : 4) + (state1 == STATE_TWOBYTE ? 0 : 1) + 2; + if (n < count) + return RET_TOOSMALL; + if (state2 != STATE2_DESIGNATED_GB2312) + { + r[0] = ESC; + r[1] = '$'; + r[2] = ')'; + r[3] = 'A'; + r += 4; + state2 = STATE2_DESIGNATED_GB2312; + } + if (state1 != STATE_TWOBYTE) + { + r[0] = SO; + r += 1; + state1 = STATE_TWOBYTE; + } + r[0] = buf[0]; + r[1] = buf[1]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + ret = cns11643_wctomb(conv, buf, wc, 3); + if (ret != RET_ILUNI) + { + if (ret != 3) + abort(); + + /* Try CNS 11643-1992 Plane 1. */ + if (buf[0] == 1 && buf[1] < 0x80 && buf[2] < 0x80) + { + int count = (state2 == STATE2_DESIGNATED_CNS11643_1 ? 0 : 4) + (state1 == STATE_TWOBYTE ? 0 : 1) + 2; + if (n < count) + return RET_TOOSMALL; + if (state2 != STATE2_DESIGNATED_CNS11643_1) + { + r[0] = ESC; + r[1] = '$'; + r[2] = ')'; + r[3] = 'G'; + r += 4; + state2 = STATE2_DESIGNATED_CNS11643_1; + } + if (state1 != STATE_TWOBYTE) + { + r[0] = SO; + r += 1; + state1 = STATE_TWOBYTE; + } + r[0] = buf[1]; + r[1] = buf[2]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + + /* Try CNS 11643-1992 Plane 2. */ + if (buf[0] == 2 && buf[1] < 0x80 && buf[2] < 0x80) + { + int count = (state3 == STATE3_DESIGNATED_CNS11643_2 ? 0 : 4) + 4; + if (n < count) + return RET_TOOSMALL; + if (state3 != STATE3_DESIGNATED_CNS11643_2) + { + r[0] = ESC; + r[1] = '$'; + r[2] = '*'; + r[3] = 'H'; + r += 4; + state3 = STATE3_DESIGNATED_CNS11643_2; + } + r[0] = ESC; + r[1] = 'N'; + r[2] = buf[1]; + r[3] = buf[2]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + return RET_ILUNI; +} + +static int iso2022_cn_reset(conv_t conv, unsigned char *r, size_t n) +{ + state_t state = conv->ostate; + SPLIT_STATE; + (void)state2; + (void)state3; + if (state1 != STATE_ASCII) + { + if (n < 1) + return RET_TOOSMALL; + r[0] = SI; + /* conv->ostate = 0; will be done by the caller */ + return 1; + } + else + return 0; +} + +#undef COMBINE_STATE +#undef SPLIT_STATE +#undef STATE3_DESIGNATED_CNS11643_2 +#undef STATE3_NONE +#undef STATE2_DESIGNATED_CNS11643_1 +#undef STATE2_DESIGNATED_GB2312 +#undef STATE2_NONE +#undef STATE_TWOBYTE +#undef STATE_ASCII + +#endif /* _ISO2022_CN_H_ */ diff --git a/lib/converters/iso2022_cnext.h b/lib/converters/iso2022_cnext.h new file mode 100644 index 00000000..a4fcb360 --- /dev/null +++ b/lib/converters/iso2022_cnext.h @@ -0,0 +1,710 @@ +/** + * @file iso2022_cnext.h + * @brief ISO-2022-CN-EXT + * @copyright Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _ISO2022_CNEXT_H_ +#define _ISO2022_CNEXT_H_ + +#include "converters/ascii.h" +#include "converters/cns11643.h" +#include "converters/cns11643_1.h" +#include "converters/cns11643_2.h" +#include "converters/cns11643_3.h" +#include "converters/cns11643_4.h" +#include "converters/cns11643_5.h" +#include "converters/cns11643_6.h" +#include "converters/cns11643_7.h" +#include "converters/gb2312.h" +#include "converters/isoir165.h" +#include "reiconv_defines.h" +#include + +/* Specification: RFC 1922 */ + +#define ESC 0x1b +#define SO 0x0e +#define SI 0x0f + +/* + * The state is composed of one of the following values + */ +#define STATE_ASCII 0 +#define STATE_TWOBYTE 1 +/* + * and one of the following values, << 8 + */ +#define STATE2_NONE 0 +#define STATE2_DESIGNATED_GB2312 1 +#define STATE2_DESIGNATED_CNS11643_1 2 +#define STATE2_DESIGNATED_ISO_IR_165 3 +/* + * and one of the following values, << 16 + */ +#define STATE3_NONE 0 +#define STATE3_DESIGNATED_CNS11643_2 1 +/* + * and one of the following values, << 24 + */ +#define STATE4_NONE 0 +#define STATE4_DESIGNATED_CNS11643_3 1 +#define STATE4_DESIGNATED_CNS11643_4 2 +#define STATE4_DESIGNATED_CNS11643_5 3 +#define STATE4_DESIGNATED_CNS11643_6 4 +#define STATE4_DESIGNATED_CNS11643_7 5 + +#define SPLIT_STATE \ + unsigned int state1 = state & 0xff, state2 = (state >> 8) & 0xff, state3 = (state >> 16) & 0xff, \ + state4 = state >> 24 +#define COMBINE_STATE state = (state4 << 24) | (state3 << 16) | (state2 << 8) | state1 + +static int iso2022_cn_ext_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + state_t state = conv->istate; + SPLIT_STATE; + int count = 0; + unsigned char c; + for (;;) + { + c = *s; + if (c == ESC) + { + if (n < count + 4) + goto none; + if (s[1] == '$') + { + if (s[2] == ')') + { + if (s[3] == 'A') + { + state2 = STATE2_DESIGNATED_GB2312; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + if (s[3] == 'G') + { + state2 = STATE2_DESIGNATED_CNS11643_1; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + if (s[3] == 'E') + { + state2 = STATE2_DESIGNATED_ISO_IR_165; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + } + if (s[2] == '*') + { + if (s[3] == 'H') + { + state3 = STATE3_DESIGNATED_CNS11643_2; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + } + if (s[2] == '+') + { + if (s[3] == 'I') + { + state4 = STATE4_DESIGNATED_CNS11643_3; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + if (s[3] == 'J') + { + state4 = STATE4_DESIGNATED_CNS11643_4; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + if (s[3] == 'K') + { + state4 = STATE4_DESIGNATED_CNS11643_5; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + if (s[3] == 'L') + { + state4 = STATE4_DESIGNATED_CNS11643_6; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + if (s[3] == 'M') + { + state4 = STATE4_DESIGNATED_CNS11643_7; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + } + } + if (s[1] == 'N') + { + switch (state3) + { + case STATE3_NONE: + goto ilseq; + case STATE3_DESIGNATED_CNS11643_2: + if (s[2] < 0x80 && s[3] < 0x80) + { + int ret = cns11643_2_mbtowc(conv, pwc, s + 2, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 4; + } + else + goto ilseq; + default: + abort(); + } + } + if (s[1] == 'O') + { + switch (state4) + { + case STATE4_NONE: + goto ilseq; + case STATE4_DESIGNATED_CNS11643_3: + if (s[2] < 0x80 && s[3] < 0x80) + { + int ret = cns11643_3_mbtowc(conv, pwc, s + 2, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 4; + } + else + goto ilseq; + case STATE4_DESIGNATED_CNS11643_4: + if (s[2] < 0x80 && s[3] < 0x80) + { + int ret = cns11643_4_mbtowc(conv, pwc, s + 2, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 4; + } + else + goto ilseq; + case STATE4_DESIGNATED_CNS11643_5: + if (s[2] < 0x80 && s[3] < 0x80) + { + int ret = cns11643_5_mbtowc(conv, pwc, s + 2, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 4; + } + else + goto ilseq; + case STATE4_DESIGNATED_CNS11643_6: + if (s[2] < 0x80 && s[3] < 0x80) + { + int ret = cns11643_6_mbtowc(conv, pwc, s + 2, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 4; + } + else + goto ilseq; + case STATE4_DESIGNATED_CNS11643_7: + if (s[2] < 0x80 && s[3] < 0x80) + { + int ret = cns11643_7_mbtowc(conv, pwc, s + 2, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 4; + } + else + goto ilseq; + default: + abort(); + } + } + goto ilseq; + } + if (c == SO) + { + if (state2 != STATE2_DESIGNATED_GB2312 && state2 != STATE2_DESIGNATED_CNS11643_1 && + state2 != STATE2_DESIGNATED_ISO_IR_165) + goto ilseq; + state1 = STATE_TWOBYTE; + s++; + count++; + if (n < count + 1) + goto none; + continue; + } + if (c == SI) + { + state1 = STATE_ASCII; + s++; + count++; + if (n < count + 1) + goto none; + continue; + } + break; + } + switch (state1) + { + case STATE_ASCII: + if (c < 0x80) + { + int ret = ascii_mbtowc(conv, pwc, s, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + if (*pwc == 0x000a || *pwc == 0x000d) + { + state2 = STATE2_NONE; + state3 = STATE3_NONE; + state4 = STATE3_NONE; + } + COMBINE_STATE; + conv->istate = state; + return count + 1; + } + else + goto ilseq; + case STATE_TWOBYTE: + if (n < count + 2) + goto none; + if (s[0] < 0x80 && s[1] < 0x80) + { + int ret; + switch (state2) + { + case STATE2_NONE: + goto ilseq; + case STATE2_DESIGNATED_GB2312: + ret = gb2312_mbtowc(conv, pwc, s, 2); + break; + case STATE2_DESIGNATED_CNS11643_1: + ret = cns11643_1_mbtowc(conv, pwc, s, 2); + break; + case STATE2_DESIGNATED_ISO_IR_165: + ret = isoir165_mbtowc(conv, pwc, s, 2); + break; + default: + abort(); + } + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 2; + } + else + goto ilseq; + default: + abort(); + } + +none: + COMBINE_STATE; + conv->istate = state; + return RET_TOOFEW(count); + +ilseq: + COMBINE_STATE; + conv->istate = state; + return RET_SHIFT_ILSEQ(count); +} + +static int iso2022_cn_ext_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + state_t state = conv->ostate; + SPLIT_STATE; + unsigned char buf[3]; + int ret; + + /* There is no need to handle Unicode 3.1 tag characters and to look for + "zh-CN" or "zh-TW" tags, because GB2312 and CNS11643 are disjoint. */ + + /* Try ASCII. */ + ret = ascii_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] < 0x80) + { + int count = (state1 == STATE_ASCII ? 1 : 2); + if (n < count) + return RET_TOOSMALL; + if (state1 != STATE_ASCII) + { + r[0] = SI; + r += 1; + state1 = STATE_ASCII; + } + r[0] = buf[0]; + if (wc == 0x000a || wc == 0x000d) + { + state2 = STATE2_NONE; + state3 = STATE3_NONE; + state4 = STATE3_NONE; + } + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + /* Try GB 2312-1980. */ + ret = gb2312_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state2 == STATE2_DESIGNATED_GB2312 ? 0 : 4) + (state1 == STATE_TWOBYTE ? 0 : 1) + 2; + if (n < count) + return RET_TOOSMALL; + if (state2 != STATE2_DESIGNATED_GB2312) + { + r[0] = ESC; + r[1] = '$'; + r[2] = ')'; + r[3] = 'A'; + r += 4; + state2 = STATE2_DESIGNATED_GB2312; + } + if (state1 != STATE_TWOBYTE) + { + r[0] = SO; + r += 1; + state1 = STATE_TWOBYTE; + } + r[0] = buf[0]; + r[1] = buf[1]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + ret = cns11643_wctomb(conv, buf, wc, 3); + if (ret != RET_ILUNI) + { + if (ret != 3) + abort(); + + /* Try CNS 11643-1992 Plane 1. */ + if (buf[0] == 1 && buf[1] < 0x80 && buf[2] < 0x80) + { + int count = (state2 == STATE2_DESIGNATED_CNS11643_1 ? 0 : 4) + (state1 == STATE_TWOBYTE ? 0 : 1) + 2; + if (n < count) + return RET_TOOSMALL; + if (state2 != STATE2_DESIGNATED_CNS11643_1) + { + r[0] = ESC; + r[1] = '$'; + r[2] = ')'; + r[3] = 'G'; + r += 4; + state2 = STATE2_DESIGNATED_CNS11643_1; + } + if (state1 != STATE_TWOBYTE) + { + r[0] = SO; + r += 1; + state1 = STATE_TWOBYTE; + } + r[0] = buf[1]; + r[1] = buf[2]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + + /* Try CNS 11643-1992 Plane 2. */ + if (buf[0] == 2 && buf[1] < 0x80 && buf[2] < 0x80) + { + int count = (state3 == STATE3_DESIGNATED_CNS11643_2 ? 0 : 4) + 4; + if (n < count) + return RET_TOOSMALL; + if (state3 != STATE3_DESIGNATED_CNS11643_2) + { + r[0] = ESC; + r[1] = '$'; + r[2] = '*'; + r[3] = 'H'; + r += 4; + state3 = STATE3_DESIGNATED_CNS11643_2; + } + r[0] = ESC; + r[1] = 'N'; + r[2] = buf[1]; + r[3] = buf[2]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + + /* Try CNS 11643-1992 Plane 3. */ + if (buf[0] == 3 && buf[1] < 0x80 && buf[2] < 0x80) + { + int count = (state4 == STATE4_DESIGNATED_CNS11643_3 ? 0 : 4) + 4; + if (n < count) + return RET_TOOSMALL; + if (state4 != STATE4_DESIGNATED_CNS11643_3) + { + r[0] = ESC; + r[1] = '$'; + r[2] = '+'; + r[3] = 'I'; + r += 4; + state4 = STATE4_DESIGNATED_CNS11643_3; + } + r[0] = ESC; + r[1] = 'O'; + r[2] = buf[1]; + r[3] = buf[2]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + + /* Try CNS 11643-1992 Plane 4. */ + if (buf[0] == 4 && buf[1] < 0x80 && buf[2] < 0x80) + { + int count = (state4 == STATE4_DESIGNATED_CNS11643_4 ? 0 : 4) + 4; + if (n < count) + return RET_TOOSMALL; + if (state4 != STATE4_DESIGNATED_CNS11643_4) + { + r[0] = ESC; + r[1] = '$'; + r[2] = '+'; + r[3] = 'J'; + r += 4; + state4 = STATE4_DESIGNATED_CNS11643_4; + } + r[0] = ESC; + r[1] = 'O'; + r[2] = buf[1]; + r[3] = buf[2]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + + /* Try CNS 11643-1992 Plane 5. */ + if (buf[0] == 5 && buf[1] < 0x80 && buf[2] < 0x80) + { + int count = (state4 == STATE4_DESIGNATED_CNS11643_5 ? 0 : 4) + 4; + if (n < count) + return RET_TOOSMALL; + if (state4 != STATE4_DESIGNATED_CNS11643_5) + { + r[0] = ESC; + r[1] = '$'; + r[2] = '+'; + r[3] = 'K'; + r += 4; + state4 = STATE4_DESIGNATED_CNS11643_5; + } + r[0] = ESC; + r[1] = 'O'; + r[2] = buf[1]; + r[3] = buf[2]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + + /* Try CNS 11643-1992 Plane 6. */ + if (buf[0] == 6 && buf[1] < 0x80 && buf[2] < 0x80) + { + int count = (state4 == STATE4_DESIGNATED_CNS11643_6 ? 0 : 4) + 4; + if (n < count) + return RET_TOOSMALL; + if (state4 != STATE4_DESIGNATED_CNS11643_6) + { + r[0] = ESC; + r[1] = '$'; + r[2] = '+'; + r[3] = 'L'; + r += 4; + state4 = STATE4_DESIGNATED_CNS11643_6; + } + r[0] = ESC; + r[1] = 'O'; + r[2] = buf[1]; + r[3] = buf[2]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + + /* Try CNS 11643-1992 Plane 7. */ + if (buf[0] == 7 && buf[1] < 0x80 && buf[2] < 0x80) + { + int count = (state4 == STATE4_DESIGNATED_CNS11643_7 ? 0 : 4) + 4; + if (n < count) + return RET_TOOSMALL; + if (state4 != STATE4_DESIGNATED_CNS11643_7) + { + r[0] = ESC; + r[1] = '$'; + r[2] = '+'; + r[3] = 'M'; + r += 4; + state4 = STATE4_DESIGNATED_CNS11643_7; + } + r[0] = ESC; + r[1] = 'O'; + r[2] = buf[1]; + r[3] = buf[2]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + /* Try ISO-IR-165. */ + ret = isoir165_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state2 == STATE2_DESIGNATED_ISO_IR_165 ? 0 : 4) + (state1 == STATE_TWOBYTE ? 0 : 1) + 2; + if (n < count) + return RET_TOOSMALL; + if (state2 != STATE2_DESIGNATED_ISO_IR_165) + { + r[0] = ESC; + r[1] = '$'; + r[2] = ')'; + r[3] = 'E'; + r += 4; + state2 = STATE2_DESIGNATED_ISO_IR_165; + } + if (state1 != STATE_TWOBYTE) + { + r[0] = SO; + r += 1; + state1 = STATE_TWOBYTE; + } + r[0] = buf[0]; + r[1] = buf[1]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + return RET_ILUNI; +} + +static int iso2022_cn_ext_reset(conv_t conv, unsigned char *r, size_t n) +{ + state_t state = conv->ostate; + SPLIT_STATE; + (void)state2; + (void)state3; + (void)state4; + if (state1 != STATE_ASCII) + { + if (n < 1) + return RET_TOOSMALL; + r[0] = SI; + /* conv->ostate = 0; will be done by the caller */ + return 1; + } + else + return 0; +} + +#undef COMBINE_STATE +#undef SPLIT_STATE +#undef STATE4_DESIGNATED_CNS11643_7 +#undef STATE4_DESIGNATED_CNS11643_6 +#undef STATE4_DESIGNATED_CNS11643_5 +#undef STATE4_DESIGNATED_CNS11643_4 +#undef STATE4_DESIGNATED_CNS11643_3 +#undef STATE4_NONE +#undef STATE3_DESIGNATED_CNS11643_2 +#undef STATE3_NONE +#undef STATE2_DESIGNATED_ISO_IR_165 +#undef STATE2_DESIGNATED_CNS11643_1 +#undef STATE2_DESIGNATED_GB2312 +#undef STATE2_NONE +#undef STATE_TWOBYTE +#undef STATE_ASCII + +#endif /* _ISO2022_CNEXT_H_ */ diff --git a/lib/converters/iso2022_jp.h b/lib/converters/iso2022_jp.h new file mode 100644 index 00000000..4048c791 --- /dev/null +++ b/lib/converters/iso2022_jp.h @@ -0,0 +1,260 @@ +/** + * @file iso2022_jp.h + * @brief ISO-2022-JP + * @copyright Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _ISO2022_JP_H_ +#define _ISO2022_JP_H_ + +#include "converters/ascii.h" +#include "converters/jisx0201.h" +#include "converters/jisx0208.h" +#include "reiconv_defines.h" + +#include + +/* Specification: RFC 1468 */ + +#define ESC 0x1b + +/* + * The state can be one of the following values. + */ +#define STATE_ASCII 0 +#define STATE_JISX0201ROMAN 1 +#define STATE_JISX0208 2 + +static int iso2022_jp_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + state_t state = conv->istate; + int count = 0; + unsigned char c; + for (;;) + { + c = *s; + if (c == ESC) + { + if (n < count + 3) + goto none; + if (s[1] == '(') + { + if (s[2] == 'B') + { + state = STATE_ASCII; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + if (s[2] == 'J') + { + state = STATE_JISX0201ROMAN; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + goto ilseq; + } + if (s[1] == '$') + { + if (s[2] == '@' || s[2] == 'B') + { + /* We don't distinguish JIS X 0208-1978 and JIS X 0208-1983. */ + state = STATE_JISX0208; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + goto ilseq; + } + goto ilseq; + } + break; + } + switch (state) + { + case STATE_ASCII: + if (c < 0x80) + { + int ret = ascii_mbtowc(conv, pwc, s, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + conv->istate = state; + return count + 1; + } + else + goto ilseq; + case STATE_JISX0201ROMAN: + if (c < 0x80) + { + int ret = jisx0201_mbtowc(conv, pwc, s, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + conv->istate = state; + return count + 1; + } + else + goto ilseq; + case STATE_JISX0208: + if (n < count + 2) + goto none; + if (s[0] < 0x80 && s[1] < 0x80) + { + int ret = jisx0208_mbtowc(conv, pwc, s, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + conv->istate = state; + return count + 2; + } + else + goto ilseq; + default: + abort(); + } + +none: + conv->istate = state; + return RET_TOOFEW(count); + +ilseq: + conv->istate = state; + return RET_SHIFT_ILSEQ(count); +} + +static int iso2022_jp_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + state_t state = conv->ostate; + unsigned char buf[2]; + int ret; + + /* Try ASCII. */ + ret = ascii_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] < 0x80) + { + int count = (state == STATE_ASCII ? 1 : 4); + if (n < count) + return RET_TOOSMALL; + if (state != STATE_ASCII) + { + r[0] = ESC; + r[1] = '('; + r[2] = 'B'; + r += 3; + state = STATE_ASCII; + } + r[0] = buf[0]; + conv->ostate = state; + return count; + } + } + + /* Try JIS X 0201-1976 Roman. */ + ret = jisx0201_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] < 0x80) + { + int count = (state == STATE_JISX0201ROMAN ? 1 : 4); + if (n < count) + return RET_TOOSMALL; + if (state != STATE_JISX0201ROMAN) + { + r[0] = ESC; + r[1] = '('; + r[2] = 'J'; + r += 3; + state = STATE_JISX0201ROMAN; + } + r[0] = buf[0]; + conv->ostate = state; + return count; + } + } + + /* Try JIS X 0208-1990 in place of JIS X 0208-1978 and JIS X 0208-1983. */ + ret = jisx0208_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state == STATE_JISX0208 ? 2 : 5); + if (n < count) + return RET_TOOSMALL; + if (state != STATE_JISX0208) + { + r[0] = ESC; + r[1] = '$'; + r[2] = 'B'; + r += 3; + state = STATE_JISX0208; + } + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = state; + return count; + } + } + + return RET_ILUNI; +} + +static int iso2022_jp_reset(conv_t conv, unsigned char *r, size_t n) +{ + state_t state = conv->ostate; + if (state != STATE_ASCII) + { + if (n < 3) + return RET_TOOSMALL; + r[0] = ESC; + r[1] = '('; + r[2] = 'B'; + /* conv->ostate = 0; will be done by the caller */ + return 3; + } + else + return 0; +} + +#undef STATE_JISX0208 +#undef STATE_JISX0201ROMAN +#undef STATE_ASCII + +#endif /* _ISO2022_JP_H_ */ diff --git a/lib/converters/iso2022_jp1.h b/lib/converters/iso2022_jp1.h new file mode 100644 index 00000000..0c0aba8b --- /dev/null +++ b/lib/converters/iso2022_jp1.h @@ -0,0 +1,318 @@ +/** + * @file iso2022_jp1.h + * @brief ISO-2022-JP-1 + * @copyright Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _ISO2022_JP1_H_ +#define _ISO2022_JP1_H_ + +#include "converters/ascii.h" +#include "converters/jisx0201.h" +#include "converters/jisx0208.h" +#include "converters/jisx0212.h" +#include "reiconv_defines.h" +#include + +/* Specification: RFC 2237 */ + +#define ESC 0x1b + +/* + * The state can be one of the following values. + */ +#define STATE_ASCII 0 +#define STATE_JISX0201ROMAN 1 +#define STATE_JISX0208 2 +#define STATE_JISX0212 3 + +static int iso2022_jp1_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + state_t state = conv->istate; + int count = 0; + unsigned char c; + for (;;) + { + c = *s; + if (c == ESC) + { + if (n < count + 3) + goto none; + if (s[1] == '(') + { + if (s[2] == 'B') + { + state = STATE_ASCII; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + if (s[2] == 'J') + { + state = STATE_JISX0201ROMAN; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + goto ilseq; + } + if (s[1] == '$') + { + if (s[2] == '@' || s[2] == 'B') + { + /* We don't distinguish JIS X 0208-1978 and JIS X 0208-1983. */ + state = STATE_JISX0208; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + if (s[2] == '(') + { + if (n < count + 4) + goto none; + if (s[3] == 'D') + { + state = STATE_JISX0212; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + } + goto ilseq; + } + goto ilseq; + } + break; + } + switch (state) + { + case STATE_ASCII: + if (c < 0x80) + { + int ret = ascii_mbtowc(conv, pwc, s, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + conv->istate = state; + return count + 1; + } + else + goto ilseq; + case STATE_JISX0201ROMAN: + if (c < 0x80) + { + int ret = jisx0201_mbtowc(conv, pwc, s, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + conv->istate = state; + return count + 1; + } + else + goto ilseq; + case STATE_JISX0208: + if (n < count + 2) + goto none; + if (s[0] < 0x80 && s[1] < 0x80) + { + int ret = jisx0208_mbtowc(conv, pwc, s, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + conv->istate = state; + return count + 2; + } + else + goto ilseq; + case STATE_JISX0212: + if (n < count + 2) + goto none; + if (s[0] < 0x80 && s[1] < 0x80) + { + int ret = jisx0212_mbtowc(conv, pwc, s, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + conv->istate = state; + return count + 2; + } + else + goto ilseq; + default: + abort(); + } + +none: + conv->istate = state; + return RET_TOOFEW(count); + +ilseq: + conv->istate = state; + return RET_SHIFT_ILSEQ(count); +} + +static int iso2022_jp1_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + state_t state = conv->ostate; + unsigned char buf[2]; + int ret; + + /* Try ASCII. */ + ret = ascii_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] < 0x80) + { + int count = (state == STATE_ASCII ? 1 : 4); + if (n < count) + return RET_TOOSMALL; + if (state != STATE_ASCII) + { + r[0] = ESC; + r[1] = '('; + r[2] = 'B'; + r += 3; + state = STATE_ASCII; + } + r[0] = buf[0]; + conv->ostate = state; + return count; + } + } + + /* Try JIS X 0201-1976 Roman. */ + ret = jisx0201_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] < 0x80) + { + int count = (state == STATE_JISX0201ROMAN ? 1 : 4); + if (n < count) + return RET_TOOSMALL; + if (state != STATE_JISX0201ROMAN) + { + r[0] = ESC; + r[1] = '('; + r[2] = 'J'; + r += 3; + state = STATE_JISX0201ROMAN; + } + r[0] = buf[0]; + conv->ostate = state; + return count; + } + } + + /* Try JIS X 0208-1990 in place of JIS X 0208-1978 and JIS X 0208-1983. */ + ret = jisx0208_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state == STATE_JISX0208 ? 2 : 5); + if (n < count) + return RET_TOOSMALL; + if (state != STATE_JISX0208) + { + r[0] = ESC; + r[1] = '$'; + r[2] = 'B'; + r += 3; + state = STATE_JISX0208; + } + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = state; + return count; + } + } + + /* Try JIS X 0212-1990. */ + ret = jisx0212_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state == STATE_JISX0212 ? 2 : 6); + if (n < count) + return RET_TOOSMALL; + if (state != STATE_JISX0212) + { + r[0] = ESC; + r[1] = '$'; + r[2] = '('; + r[3] = 'D'; + r += 4; + state = STATE_JISX0212; + } + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = state; + return count; + } + } + + return RET_ILUNI; +} + +static int iso2022_jp1_reset(conv_t conv, unsigned char *r, size_t n) +{ + state_t state = conv->ostate; + if (state != STATE_ASCII) + { + if (n < 3) + return RET_TOOSMALL; + r[0] = ESC; + r[1] = '('; + r[2] = 'B'; + /* conv->ostate = 0; will be done by the caller */ + return 3; + } + else + return 0; +} + +#undef STATE_JISX0212 +#undef STATE_JISX0208 +#undef STATE_JISX0201ROMAN +#undef STATE_ASCII + +#endif /* _ISO2022_JP1_H_ */ diff --git a/lib/converters/iso2022_jp2.h b/lib/converters/iso2022_jp2.h new file mode 100644 index 00000000..c75c735d --- /dev/null +++ b/lib/converters/iso2022_jp2.h @@ -0,0 +1,814 @@ +/** + * @file iso2022_jp2.h + * @brief ISO-2022-JP-2 + * @copyright Copyright (C) 1999-2001, 2008, 2016, 2024 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _ISO2022_JP2_H_ +#define _ISO2022_JP2_H_ + +#include "converters/ascii.h" +#include "converters/gb2312.h" +#include "converters/iso8859_1.h" +#include "converters/iso8859_7.h" +#include "converters/jisx0201.h" +#include "converters/jisx0208.h" +#include "converters/jisx0212.h" +#include "converters/ksc5601.h" +#include "reiconv_defines.h" + +#include + +/* Specification: RFC 1554 */ +/* ESC '(' 'I' for JISX0201 Katakana is an extension not found in RFC 1554 or + CJK.INF, but implemented in glibc-2.1 and qt-2.0. */ + +#define ESC 0x1b + +/* + * The state is composed of one of the following values + */ +#define STATE_ASCII 0 +#define STATE_JISX0201ROMAN 1 +#define STATE_JISX0201KATAKANA 2 +#define STATE_JISX0208 3 +#define STATE_JISX0212 4 +#define STATE_GB2312 5 +#define STATE_KSC5601 6 +/* + * and one of the following values, << 8 + */ +#define STATE_G2_NONE 0 +#define STATE_G2_ISO8859_1 1 +#define STATE_G2_ISO8859_7 2 + +#define SPLIT_STATE unsigned int state1 = state & 0xff, state2 = state >> 8 +#define COMBINE_STATE state = (state2 << 8) | state1 + +static int iso2022_jp2_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + state_t state = conv->istate; + SPLIT_STATE; + int count = 0; + unsigned char c; + for (;;) + { + c = *s; + if (c == ESC) + { + if (n < count + 3) + goto none; + if (s[1] == '(') + { + if (s[2] == 'B') + { + state1 = STATE_ASCII; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + if (s[2] == 'J') + { + state1 = STATE_JISX0201ROMAN; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + if (s[2] == 'I') + { + state1 = STATE_JISX0201KATAKANA; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + goto ilseq; + } + if (s[1] == '$') + { + if (s[2] == '@' || s[2] == 'B') + { + /* We don't distinguish JIS X 0208-1978 and JIS X 0208-1983. */ + state1 = STATE_JISX0208; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + if (s[2] == 'A') + { + state1 = STATE_GB2312; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + if (s[2] == '(') + { + if (n < count + 4) + goto none; + if (s[3] == 'D') + { + state1 = STATE_JISX0212; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + if (s[3] == 'C') + { + state1 = STATE_KSC5601; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + goto ilseq; + } + goto ilseq; + } + if (s[1] == '.') + { + if (n < count + 3) + goto none; + if (s[2] == 'A') + { + state2 = STATE_G2_ISO8859_1; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + if (s[2] == 'F') + { + state2 = STATE_G2_ISO8859_7; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + goto ilseq; + } + if (s[1] == 'N') + { + switch (state2) + { + case STATE_G2_NONE: + goto ilseq; + case STATE_G2_ISO8859_1: + if (s[2] < 0x80) + { + unsigned char buf = s[2] + 0x80; + int ret = iso8859_1_mbtowc(conv, pwc, &buf, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 3; + } + else + goto ilseq; + case STATE_G2_ISO8859_7: + if (s[2] < 0x80) + { + unsigned char buf = s[2] + 0x80; + int ret = iso8859_7_mbtowc(conv, pwc, &buf, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 3; + } + else + goto ilseq; + default: + abort(); + } + } + goto ilseq; + } + break; + } + switch (state1) + { + case STATE_ASCII: + if (c < 0x80) + { + int ret = ascii_mbtowc(conv, pwc, s, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + if (*pwc == 0x000a || *pwc == 0x000d) + state2 = STATE_G2_NONE; + COMBINE_STATE; + conv->istate = state; + return count + 1; + } + else + goto ilseq; + case STATE_JISX0201ROMAN: + if (c < 0x80) + { + int ret = jisx0201_mbtowc(conv, pwc, s, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + if (*pwc == 0x000a || *pwc == 0x000d) + state2 = STATE_G2_NONE; + COMBINE_STATE; + conv->istate = state; + return count + 1; + } + else + goto ilseq; + case STATE_JISX0201KATAKANA: + if (c < 0x80) + { + unsigned char buf = c + 0x80; + int ret = jisx0201_mbtowc(conv, pwc, &buf, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 1; + } + else + goto ilseq; + case STATE_JISX0208: + if (n < count + 2) + goto none; + if (s[0] < 0x80 && s[1] < 0x80) + { + int ret = jisx0208_mbtowc(conv, pwc, s, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 2; + } + else + goto ilseq; + case STATE_JISX0212: + if (n < count + 2) + goto none; + if (s[0] < 0x80 && s[1] < 0x80) + { + int ret = jisx0212_mbtowc(conv, pwc, s, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 2; + } + else + goto ilseq; + case STATE_GB2312: + if (n < count + 2) + goto none; + if (s[0] < 0x80 && s[1] < 0x80) + { + int ret = gb2312_mbtowc(conv, pwc, s, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 2; + } + else + goto ilseq; + case STATE_KSC5601: + if (n < count + 2) + goto none; + if (s[0] < 0x80 && s[1] < 0x80) + { + int ret = ksc5601_mbtowc(conv, pwc, s, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 2; + } + else + goto ilseq; + default: + abort(); + } + +none: + COMBINE_STATE; + conv->istate = state; + return RET_TOOFEW(count); + +ilseq: + COMBINE_STATE; + conv->istate = state; + return RET_SHIFT_ILSEQ(count); +} + +#undef COMBINE_STATE +#undef SPLIT_STATE + +/* + * The state can also contain one of the following values, << 16. + * Values >= STATE_TAG_LANGUAGE are temporary tag parsing states. + */ +#define STATE_TAG_NONE 0 +#define STATE_TAG_LANGUAGE 4 +#define STATE_TAG_LANGUAGE_j 5 +#define STATE_TAG_LANGUAGE_ja 1 +#define STATE_TAG_LANGUAGE_k 6 +#define STATE_TAG_LANGUAGE_ko 2 +#define STATE_TAG_LANGUAGE_z 7 +#define STATE_TAG_LANGUAGE_zh 3 + +#define SPLIT_STATE unsigned int state1 = state & 0xff, state2 = (state >> 8) & 0xff, state3 = state >> 16 +#define COMBINE_STATE state = (state3 << 16) | (state2 << 8) | state1 + +static int iso2022_jp2_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + state_t state = conv->ostate; + SPLIT_STATE; + unsigned char buf[2]; + int ret; + /* This defines the conversion preferences depending on the current + language tag. */ + enum conversion + { + none = 0, + european, + japanese, + chinese, + korean, + other + }; + static const unsigned int conversion_lists[STATE_TAG_LANGUAGE] = { + /* STATE_TAG_NONE */ + japanese + (european << 3) + (chinese << 6) + (korean << 9) + (other << 12), + /* STATE_TAG_LANGUAGE_ja */ + japanese + (european << 3) + (chinese << 6) + (korean << 9) + (other << 12), + /* STATE_TAG_LANGUAGE_ko */ + korean + (european << 3) + (japanese << 6) + (chinese << 9) + (other << 12), + /* STATE_TAG_LANGUAGE_zh */ + chinese + (european << 3) + (japanese << 6) + (korean << 9) + (other << 12)}; + unsigned int conversion_list; + + /* Handle Unicode tag characters (range U+E0000..U+E007F). */ + if ((wc >> 7) == (0xe0000 >> 7)) + { + char c = wc & 0x7f; + if (c >= 'A' && c <= 'Z') + c += 'a' - 'A'; + switch (c) + { + case 0x01: + state3 = STATE_TAG_LANGUAGE; + COMBINE_STATE; + conv->ostate = state; + return 0; + case 'j': + if (state3 == STATE_TAG_LANGUAGE) + { + state3 = STATE_TAG_LANGUAGE_j; + COMBINE_STATE; + conv->ostate = state; + return 0; + } + break; + case 'a': + if (state3 == STATE_TAG_LANGUAGE_j) + { + state3 = STATE_TAG_LANGUAGE_ja; + COMBINE_STATE; + conv->ostate = state; + return 0; + } + break; + case 'k': + if (state3 == STATE_TAG_LANGUAGE) + { + state3 = STATE_TAG_LANGUAGE_k; + COMBINE_STATE; + conv->ostate = state; + return 0; + } + break; + case 'o': + if (state3 == STATE_TAG_LANGUAGE_k) + { + state3 = STATE_TAG_LANGUAGE_ko; + COMBINE_STATE; + conv->ostate = state; + return 0; + } + break; + case 'z': + if (state3 == STATE_TAG_LANGUAGE) + { + state3 = STATE_TAG_LANGUAGE_z; + COMBINE_STATE; + conv->ostate = state; + return 0; + } + break; + case 'h': + if (state3 == STATE_TAG_LANGUAGE_z) + { + state3 = STATE_TAG_LANGUAGE_zh; + COMBINE_STATE; + conv->ostate = state; + return 0; + } + break; + case 0x7f: + state3 = STATE_TAG_NONE; + COMBINE_STATE; + conv->ostate = state; + return 0; + default: + break; + } + /* Other tag characters reset the tag parsing state or are ignored. */ + if (state3 >= STATE_TAG_LANGUAGE) + state3 = STATE_TAG_NONE; + COMBINE_STATE; + conv->ostate = state; + return 0; + } + if (state3 >= STATE_TAG_LANGUAGE) + state3 = STATE_TAG_NONE; + + /* Try ASCII. */ + ret = ascii_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] < 0x80) + { + int count = (state1 == STATE_ASCII ? 1 : 4); + if (n < count) + return RET_TOOSMALL; + if (state1 != STATE_ASCII) + { + r[0] = ESC; + r[1] = '('; + r[2] = 'B'; + r += 3; + state1 = STATE_ASCII; + } + r[0] = buf[0]; + if (wc == 0x000a || wc == 0x000d) + state2 = STATE_G2_NONE; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + conversion_list = conversion_lists[state3]; + + do + { + switch (conversion_list & ((1 << 3) - 1)) + { + + case european: + + /* Try ISO-8859-1. */ + ret = iso8859_1_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] >= 0x80) + { + int count = (state2 == STATE_G2_ISO8859_1 ? 3 : 6); + if (n < count) + return RET_TOOSMALL; + if (state2 != STATE_G2_ISO8859_1) + { + r[0] = ESC; + r[1] = '.'; + r[2] = 'A'; + r += 3; + state2 = STATE_G2_ISO8859_1; + } + r[0] = ESC; + r[1] = 'N'; + r[2] = buf[0] - 0x80; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + /* Try ISO-8859-7. */ + ret = iso8859_7_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] >= 0x80) + { + int count = (state2 == STATE_G2_ISO8859_7 ? 3 : 6); + if (n < count) + return RET_TOOSMALL; + if (state2 != STATE_G2_ISO8859_7) + { + r[0] = ESC; + r[1] = '.'; + r[2] = 'F'; + r += 3; + state2 = STATE_G2_ISO8859_7; + } + r[0] = ESC; + r[1] = 'N'; + r[2] = buf[0] - 0x80; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + break; + + case japanese: + + /* Try JIS X 0201-1976 Roman. */ + ret = jisx0201_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] < 0x80) + { + int count = (state1 == STATE_JISX0201ROMAN ? 1 : 4); + if (n < count) + return RET_TOOSMALL; + if (state1 != STATE_JISX0201ROMAN) + { + r[0] = ESC; + r[1] = '('; + r[2] = 'J'; + r += 3; + state1 = STATE_JISX0201ROMAN; + } + r[0] = buf[0]; + if (wc == 0x000a || wc == 0x000d) + state2 = STATE_G2_NONE; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + /* Try JIS X 0208-1990 in place of JIS X 0208-1978 and + JIS X 0208-1983. */ + ret = jisx0208_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state1 == STATE_JISX0208 ? 2 : 5); + if (n < count) + return RET_TOOSMALL; + if (state1 != STATE_JISX0208) + { + r[0] = ESC; + r[1] = '$'; + r[2] = 'B'; + r += 3; + state1 = STATE_JISX0208; + } + r[0] = buf[0]; + r[1] = buf[1]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + /* Try JIS X 0212-1990. */ + ret = jisx0212_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state1 == STATE_JISX0212 ? 2 : 6); + if (n < count) + return RET_TOOSMALL; + if (state1 != STATE_JISX0212) + { + r[0] = ESC; + r[1] = '$'; + r[2] = '('; + r[3] = 'D'; + r += 4; + state1 = STATE_JISX0212; + } + r[0] = buf[0]; + r[1] = buf[1]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + break; + + case chinese: + + /* Try GB 2312-1980. */ + ret = gb2312_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state1 == STATE_GB2312 ? 2 : 5); + if (n < count) + return RET_TOOSMALL; + if (state1 != STATE_GB2312) + { + r[0] = ESC; + r[1] = '$'; + r[2] = 'A'; + r += 3; + state1 = STATE_GB2312; + } + r[0] = buf[0]; + r[1] = buf[1]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + break; + + case korean: + + /* Try KS C 5601-1992. */ + ret = ksc5601_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state1 == STATE_KSC5601 ? 2 : 6); + if (n < count) + return RET_TOOSMALL; + if (state1 != STATE_KSC5601) + { + r[0] = ESC; + r[1] = '$'; + r[2] = '('; + r[3] = 'C'; + r += 4; + state1 = STATE_KSC5601; + } + r[0] = buf[0]; + r[1] = buf[1]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + break; + + case other: + + /* Try JIS X 0201-1976 Kana. This is not officially part of + ISO-2022-JP-2, according to RFC 1554. Therefore we try this + only after all other attempts. */ + ret = jisx0201_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] >= 0x80) + { + int count = (state1 == STATE_JISX0201KATAKANA ? 1 : 4); + if (n < count) + return RET_TOOSMALL; + if (state1 != STATE_JISX0201KATAKANA) + { + r[0] = ESC; + r[1] = '('; + r[2] = 'I'; + r += 3; + state1 = STATE_JISX0201KATAKANA; + } + r[0] = buf[0] - 0x80; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + break; + + default: + abort(); + } + + conversion_list = conversion_list >> 3; + } while (conversion_list != 0); + + return RET_ILUNI; +} + +static int iso2022_jp2_reset(conv_t conv, unsigned char *r, size_t n) +{ + state_t state = conv->ostate; + SPLIT_STATE; + (void)state2; + (void)state3; + if (state1 != STATE_ASCII) + { + if (n < 3) + return RET_TOOSMALL; + r[0] = ESC; + r[1] = '('; + r[2] = 'B'; + /* conv->ostate = 0; will be done by the caller */ + return 3; + } + else + return 0; +} + +#undef COMBINE_STATE +#undef SPLIT_STATE +#undef STATE_TAG_LANGUAGE_zh +#undef STATE_TAG_LANGUAGE_z +#undef STATE_TAG_LANGUAGE_ko +#undef STATE_TAG_LANGUAGE_k +#undef STATE_TAG_LANGUAGE_ja +#undef STATE_TAG_LANGUAGE_j +#undef STATE_TAG_LANGUAGE +#undef STATE_TAG_NONE +#undef STATE_G2_ISO8859_7 +#undef STATE_G2_ISO8859_1 +#undef STATE_G2_NONE +#undef STATE_KSC5601 +#undef STATE_GB2312 +#undef STATE_JISX0212 +#undef STATE_JISX0208 +#undef STATE_JISX0201KATAKANA +#undef STATE_JISX0201ROMAN +#undef STATE_ASCII + +#endif /* _ISO2022_JP2_H_ */ diff --git a/lib/iso2022_jp3.h b/lib/converters/iso2022_jp3.h similarity index 96% rename from lib/iso2022_jp3.h rename to lib/converters/iso2022_jp3.h index 4c81d2fc..cc171718 100644 --- a/lib/iso2022_jp3.h +++ b/lib/converters/iso2022_jp3.h @@ -1,5 +1,10 @@ +/** + * @file iso2022_jp3.h + * @brief ISO-2022-JP-3 + * @copyright Copyright (C) 1999-2004, 2008, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2004, 2008, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,21 +18,27 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ /* - * ISO-2022-JP-3 + * The state is composed of one of the following values */ -#include "jisx0213.h" +#ifndef _ISO2022_JP3_H_ +#define _ISO2022_JP3_H_ + +#include "converters/ascii.h" +#include "converters/jisx0201.h" +#include "converters/jisx0208.h" +#include "converters/jisx0213.h" +#include "reiconv_defines.h" + +#include #define ESC 0x1b -/* - * The state is composed of one of the following values - */ #define STATE_ASCII 0 /* Esc ( B */ #define STATE_JISX0201ROMAN 1 /* Esc ( J */ #define STATE_JISX0201KATAKANA 2 /* Esc ( I */ @@ -535,3 +546,5 @@ iso2022_jp3_reset (conv_t conv, unsigned char *r, size_t n) #undef STATE_JISX0201KATAKANA #undef STATE_JISX0201ROMAN #undef STATE_ASCII + +#endif /* _ISO2022_JP3_H_ */ diff --git a/lib/converters/iso2022_jpms.h b/lib/converters/iso2022_jpms.h new file mode 100644 index 00000000..7d0ddb25 --- /dev/null +++ b/lib/converters/iso2022_jpms.h @@ -0,0 +1,549 @@ +/** + * @file iso2022_jpms.h + * @brief ISO-2022-JP-MS + * @copyright Copyright (C) 1999-2001, 2008, 2011-2012, 2016, 2018, 2024 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * alias CP50221 + * + * This is an extension of ISO-2022-JP-1 with larger character sets. + * It uses ESC $ B and ESC $ ( D to denote *extensions* of JIS X 0208 and + * JIS X 0212, respectively. This violates the principles of ISO 2022, + * where + * 1. character sets to be used by ISO 2022 have to be registered at the + * ISO IR registry , + * 2. different character sets are designated by different escape + * sequences. + * It's a typical instance of the "embrace and extend" strategy by Microsoft + * . + */ + +#ifndef _ISO2022_JPMS_H_ +#define _ISO2022_JPMS_H_ + +#include "converters/ascii.h" +#include "converters/cp932ext.h" +#include "converters/jisx0201.h" +#include "converters/jisx0208.h" +#include "converters/jisx0212.h" +#include "converters/cp50221_0208_ext.h" +#include "converters/cp50221_0212_ext.h" +#include "reiconv_defines.h" + +#include + +/* + * Windows has three encodings CP50220, CP50221, CP50222. + * The common parts are: + * - US-ASCII (0x00..0x7F) + * - JIS X 0208 extended by + * - one row (0x2D), + * - a private use area (rows 0x75..0x7E = U+E000..U+E3AB), + * enabled with ESC $ B, disabled with ESC ( B. + * - JIS X 0212 extended by + * - two rows (0x73..0x74), + * - a private use area (rows 0x75..0x7E = U+E3AC..U+E757), + * enabled with ESC $ ( D, disabled with ESC ( B. + * They differ in the handling of JIS X 0201 characters (halfwidth Katakana) + * in the conversion direction Unicode -> CP5022x: + * * CP50220 maps the halfwidth Katakana to fullwidth Katakana characters. + * * CP50221 contains the JIS X 0201 halfwidth Katakana characters, + * enabled with ESC ( I, disabled with ESC ( B. + * * CP50222 contains the JIS X 0201 halfwidth Katakana characters, + * enabled with ESC ( J 0x0E, disabled with ESC ( B. + * In the conversion direction CP5022x -> Unicode, all three operate the same: + * - ESC ( I is supported and understood. + * - ESC ( J 0x0E is not accepted. (Tested on Windows XP SP3.) + * Conclusion: + * - CP50222 should not be used, because the multibyte sequence that it + * produces cannot be parsed by either of the three encodings. + * - CP50221 is preferable to CP50220, because it can faithfully represent + * the halfwidth Katakana characters. + * We therefore implement CP50221. As an extension, in the mbtowc conversion + * direction, we support also ESC ( J 0x0E, just in case. + */ + +#define ESC 0x1b +#define SO 0x0e +#define SI 0x0f + +/* + * The state can be one of the following values. + */ +#define STATE_ASCII 0 /* Esc ( B */ +#define STATE_JISX0201ROMAN 1 /* Esc ( J */ /* only in mbtowc direction */ +#define STATE_JISX0201KATAKANA 2 /* Esc ( I */ +#define STATE_JISX0208MS 3 /* Esc $ @ or Esc $ B */ +#define STATE_JISX0212MS 4 /* Esc $ ( D */ + +static int iso2022_jpms_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + state_t state = conv->istate; + int count = 0; + unsigned char c; + for (;;) + { + c = *s; + if (c == ESC) + { + if (n < count + 3) + goto none; + if (s[1] == '(') + { + if (s[2] == 'B') + { + state = STATE_ASCII; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + if (s[2] == 'I') + { + state = STATE_JISX0201KATAKANA; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + if (s[2] == 'J') + { + state = STATE_JISX0201ROMAN; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + goto ilseq; + } + if (s[1] == '$') + { + if (s[2] == '@' || s[2] == 'B') + { + /* We don't distinguish JIS X 0208-1978 and JIS X 0208-1983. */ + state = STATE_JISX0208MS; + s += 3; + count += 3; + if (n < count + 1) + goto none; + continue; + } + if (s[2] == '(') + { + if (n < count + 4) + goto none; + if (s[3] == 'D') + { + state = STATE_JISX0212MS; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + } + goto ilseq; + } + goto ilseq; + } + if (c == SO) + { + if (state == STATE_JISX0201ROMAN) + state = STATE_JISX0201KATAKANA; + s += 1; + count += 1; + if (n < count + 1) + goto none; + continue; + } + if (c == SI) + { + if (state == STATE_JISX0201KATAKANA) + state = STATE_JISX0201ROMAN; + s += 1; + count += 1; + if (n < count + 1) + goto none; + continue; + } + break; + } + switch (state) + { + case STATE_ASCII: + if (c < 0x80) + { + int ret = ascii_mbtowc(conv, pwc, s, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + conv->istate = state; + return count + 1; + } + else + goto ilseq; + case STATE_JISX0201ROMAN: + if (c < 0x80) + { + int ret = jisx0201_mbtowc(conv, pwc, s, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + conv->istate = state; + return count + 1; + } + else + goto ilseq; + case STATE_JISX0201KATAKANA: + if (c < 0x80) + { + unsigned char buf = c + 0x80; + int ret = jisx0201_mbtowc(conv, pwc, &buf, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); + conv->istate = state; + return count + 1; + } + else + goto ilseq; + case STATE_JISX0208MS: + if (n < count + 2) + goto none; + if (s[0] < 0x80 && s[1] < 0x80) + { + int ret; + if (s[0] < 0x75) + { + if (s[0] == 0x2d) + { + /* Extension of JIS X 0208. */ + if (s[1] >= 0x21 && s[1] <= 0x79) + { + unsigned char i = (s[1] - 0x21) + 1; + ret = cp50221_0208_ext_mbtowc(conv, pwc, &i, 1); + if (ret == 1) + ret = 2; + } + else + ret = RET_ILSEQ; + } + else + { + /* JIS X 0208. */ + ret = jisx0208_mbtowc(conv, pwc, s, 2); + } + } + else + { + /* Extension of JIS X 0208. + 0x{75..7E}{21..8E} maps to U+E000..U+E3AB. + But some rows maps to characters present in CP932. */ + if (s[0] <= 0x7e && (s[1] >= 0x21 && s[1] <= 0x7e)) + { + unsigned short wc = 0xfffd; + if (s[0] >= 0x79 && s[0] <= 0x7c) + wc = cp932ext_2uni_pageed[(s[0] - 0x79) * 94 + (s[1] - 0x21)]; + if (wc == 0xfffd) + wc = (s[0] - 0x75) * 94 + (s[1] - 0x21) + 0xe000; + *pwc = wc; + ret = 2; + } + else + ret = RET_ILSEQ; + } + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + conv->istate = state; + return count + 2; + } + else + goto ilseq; + case STATE_JISX0212MS: + if (n < count + 2) + goto none; + if (s[0] < 0x80 && s[1] < 0x80) + { + int ret; + if (s[0] < 0x73) + { + /* JIS X 0212. */ + ret = jisx0212_mbtowc(conv, pwc, s, 2); + } + else + { + if (s[0] < 0x75) + { + /* Extension of JIS X 0212. */ + if (s[1] >= 0x21 && s[1] <= 0x7e) + { + unsigned char i = (s[0] - 0x73) * 94 + (s[1] - 0x21) + 1; + ret = cp50221_0212_ext_mbtowc(conv, pwc, &i, 1); + if (ret == 1) + ret = 2; + } + else + ret = RET_ILSEQ; + } + else + { + /* Extension of JIS X 0208. + 0x{75..7E}{21..8E} maps to U+E3AC..U+E757. */ + if (s[0] <= 0x7e && (s[1] >= 0x21 && s[1] <= 0x7e)) + { + *pwc = (s[0] - 0x75) * 94 + (s[1] - 0x21) + 0xe3ac; + ret = 2; + } + else + ret = RET_ILSEQ; + } + } + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + conv->istate = state; + return count + 2; + } + else + goto ilseq; + default: + abort(); + } + +none: + conv->istate = state; + return RET_TOOFEW(count); + +ilseq: + conv->istate = state; + return RET_SHIFT_ILSEQ(count); +} + +static int iso2022_jpms_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + state_t state = conv->ostate; + unsigned char buf[2]; + int ret; + + /* Try ASCII. */ + ret = ascii_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] < 0x80) + { + int count = (state == STATE_ASCII ? 1 : 4); + if (n < count) + return RET_TOOSMALL; + if (state != STATE_ASCII) + { + r[0] = ESC; + r[1] = '('; + r[2] = 'B'; + r += 3; + state = STATE_ASCII; + } + r[0] = buf[0]; + conv->ostate = state; + return count; + } + } + + /* Try JIS X 0201-1976 Katakana. */ + ret = jisx0201_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] >= 0x80) + { + int count = (state == STATE_JISX0201KATAKANA ? 1 : 4); + if (n < count) + return RET_TOOSMALL; + if (state != STATE_JISX0201KATAKANA) + { + r[0] = ESC; + r[1] = '('; + r[2] = 'I'; + r += 3; + state = STATE_JISX0201KATAKANA; + } + r[0] = buf[0] - 0x80; + conv->ostate = state; + return count; + } + } + + /* Try JIS X 0208-1990, in place of JIS X 0208-1978 and JIS X 0208-1983, + and the extensions mentioned above. */ + if (wc >= 0xe000 && wc < 0xe3ac) + { + unsigned short i = wc - 0xe000; + buf[0] = (i / 94) + 0x75; + buf[1] = (i % 94) + 0x21; + ret = 2; + } + else + { + ret = jisx0208_wctomb(conv, buf, wc, 2); + if (ret == RET_ILUNI) + { + /* Extension of JIS X 0208. */ + unsigned char i; + ret = cp50221_0208_ext_wctomb(conv, &i, wc, 1); + if (ret == 1) + { + buf[0] = 0x2d; + buf[1] = i - 1 + 0x21; + ret = 2; + } + else if (wc == 0x663B) + { + buf[0] = 0x7a; + buf[1] = 0x36; + ret = 2; + } + else if (wc == 0xffe2) + { + buf[0] = 0x7c; + buf[1] = 0x7b; + ret = 2; + } + else if (wc == 0xffe4) + { + buf[0] = 0x7c; + buf[1] = 0x7c; + ret = 2; + } + } + } + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state == STATE_JISX0208MS ? 2 : 5); + if (n < count) + return RET_TOOSMALL; + if (state != STATE_JISX0208MS) + { + r[0] = ESC; + r[1] = '$'; + r[2] = 'B'; + r += 3; + state = STATE_JISX0208MS; + } + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = state; + return count; + } + } + + /* Try JIS X 0212-1990 and the extensions mentioned above. */ + if (wc >= 0xe3ac && wc < 0xe758) + { + unsigned short i = wc - 0xe3ac; + buf[0] = (i / 94) + 0x75; + buf[1] = (i % 94) + 0x21; + ret = 2; + } + else + { + ret = jisx0212_wctomb(conv, buf, wc, 2); + if (ret == RET_ILUNI) + { + /* Extension of JIS X 0212. */ + unsigned char i; + ret = cp50221_0212_ext_wctomb(conv, &i, wc, 1); + if (ret == 1) + { + i -= 1; + buf[0] = (i / 94) + 0x73; + buf[1] = (i % 94) + 0x21; + ret = 2; + } + } + } + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state == STATE_JISX0212MS ? 2 : 6); + if (n < count) + return RET_TOOSMALL; + if (state != STATE_JISX0212MS) + { + r[0] = ESC; + r[1] = '$'; + r[2] = '('; + r[3] = 'D'; + r += 4; + state = STATE_JISX0212MS; + } + r[0] = buf[0]; + r[1] = buf[1]; + conv->ostate = state; + return count; + } + } + + return RET_ILUNI; +} + +static int iso2022_jpms_reset(conv_t conv, unsigned char *r, size_t n) +{ + state_t state = conv->ostate; + if (state != STATE_ASCII) + { + if (n < 3) + return RET_TOOSMALL; + r[0] = ESC; + r[1] = '('; + r[2] = 'B'; + /* conv->ostate = 0; will be done by the caller */ + return 3; + } + else + return 0; +} + +#undef STATE_JISX0212MS +#undef STATE_JISX0208MS +#undef STATE_JISX0201KATAKANA +#undef STATE_JISX0201ROMAN +#undef STATE_ASCII + +#endif /* _ISO2022_JPMS_H_ */ diff --git a/lib/converters/iso2022_kr.h b/lib/converters/iso2022_kr.h new file mode 100644 index 00000000..ec309891 --- /dev/null +++ b/lib/converters/iso2022_kr.h @@ -0,0 +1,258 @@ +/** + * @file iso2022_kr.h + * @brief ISO-2022-KR + * @copyright Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _ISO2022_KR_H_ +#define _ISO2022_KR_H_ + +#include "converters/ascii.h" +#include "converters/ksc5601.h" +#include "reiconv_defines.h" + +#include + +/* Specification: RFC 1557 */ + +/* Note: CJK.INF says the SO designator needs to appear only once at the + beginning of a text, but to decrease the risk of ambiguities, when + producing ISO-2022-KR, we repeat the designator in every line containing + SO characters. RFC 1557 does not mandate this. */ + +#define ESC 0x1b +#define SO 0x0e +#define SI 0x0f + +/* + * The state is composed of one of the following values + */ +#define STATE_ASCII 0 +#define STATE_TWOBYTE 1 +/* + * and one of the following values, << 8 + */ +#define STATE2_NONE 0 +#define STATE2_DESIGNATED_KSC5601 1 + +#define SPLIT_STATE unsigned int state1 = state & 0xff, state2 = state >> 8 +#define COMBINE_STATE state = (state2 << 8) | state1 + +static int iso2022_kr_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + state_t state = conv->istate; + SPLIT_STATE; + int count = 0; + unsigned char c; + for (;;) + { + c = *s; + if (c == ESC) + { + if (n < count + 4) + goto none; + if (s[1] == '$') + { + if (s[2] == ')') + { + if (s[3] == 'C') + { + state2 = STATE2_DESIGNATED_KSC5601; + s += 4; + count += 4; + if (n < count + 1) + goto none; + continue; + } + } + } + goto ilseq; + } + if (c == SO) + { + if (state2 != STATE2_DESIGNATED_KSC5601) + goto ilseq; + state1 = STATE_TWOBYTE; + s++; + count++; + if (n < count + 1) + goto none; + continue; + } + if (c == SI) + { + state1 = STATE_ASCII; + s++; + count++; + if (n < count + 1) + goto none; + continue; + } + break; + } + switch (state1) + { + case STATE_ASCII: + if (c < 0x80) + { + int ret = ascii_mbtowc(conv, pwc, s, 1); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 1) + abort(); +#if 0 /* Accept ISO-2022-KR according to CJK.INF. */ + if (*pwc == 0x000a || *pwc == 0x000d) + state2 = STATE2_NONE; +#endif + COMBINE_STATE; + conv->istate = state; + return count + 1; + } + else + goto ilseq; + case STATE_TWOBYTE: + if (n < count + 2) + goto none; + if (state2 != STATE2_DESIGNATED_KSC5601) + abort(); + if (s[0] < 0x80 && s[1] < 0x80) + { + int ret = ksc5601_mbtowc(conv, pwc, s, 2); + if (ret == RET_ILSEQ) + goto ilseq; + if (ret != 2) + abort(); + COMBINE_STATE; + conv->istate = state; + return count + 2; + } + else + goto ilseq; + default: + abort(); + } + +none: + COMBINE_STATE; + conv->istate = state; + return RET_TOOFEW(count); + +ilseq: + COMBINE_STATE; + conv->istate = state; + return RET_SHIFT_ILSEQ(count); +} + +static int iso2022_kr_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + state_t state = conv->ostate; + SPLIT_STATE; + unsigned char buf[2]; + int ret; + + /* Try ASCII. */ + ret = ascii_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] < 0x80) + { + int count = (state1 == STATE_ASCII ? 1 : 2); + if (n < count) + return RET_TOOSMALL; + if (state1 != STATE_ASCII) + { + r[0] = SI; + r += 1; + state1 = STATE_ASCII; + } + r[0] = buf[0]; + if (wc == 0x000a || wc == 0x000d) + state2 = STATE2_NONE; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + /* Try KS C 5601-1992. */ + ret = ksc5601_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (buf[0] < 0x80 && buf[1] < 0x80) + { + int count = (state2 == STATE2_DESIGNATED_KSC5601 ? 0 : 4) + (state1 == STATE_TWOBYTE ? 0 : 1) + 2; + if (n < count) + return RET_TOOSMALL; + if (state2 != STATE2_DESIGNATED_KSC5601) + { + r[0] = ESC; + r[1] = '$'; + r[2] = ')'; + r[3] = 'C'; + r += 4; + state2 = STATE2_DESIGNATED_KSC5601; + } + if (state1 != STATE_TWOBYTE) + { + r[0] = SO; + r += 1; + state1 = STATE_TWOBYTE; + } + r[0] = buf[0]; + r[1] = buf[1]; + COMBINE_STATE; + conv->ostate = state; + return count; + } + } + + return RET_ILUNI; +} + +static int iso2022_kr_reset(conv_t conv, unsigned char *r, size_t n) +{ + state_t state = conv->ostate; + SPLIT_STATE; + (void)state2; + if (state1 != STATE_ASCII) + { + if (n < 1) + return RET_TOOSMALL; + r[0] = SI; + /* conv->ostate = 0; will be done by the caller */ + return 1; + } + else + return 0; +} + +#undef COMBINE_STATE +#undef SPLIT_STATE +#undef STATE2_DESIGNATED_KSC5601 +#undef STATE2_NONE +#undef STATE_TWOBYTE +#undef STATE_ASCII + +#endif /* _ISO2022_KR_H_ */ diff --git a/lib/converters/iso646_cn.h b/lib/converters/iso646_cn.h new file mode 100644 index 00000000..69ff074e --- /dev/null +++ b/lib/converters/iso646_cn.h @@ -0,0 +1,70 @@ +/** + * @file iso646_cn.h + * @brief ISO646-CN + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * also known as GB_1988-80 + */ + +#ifndef _ISO646_CN_H_ +#define _ISO646_CN_H_ + +#include "reiconv_defines.h" + +static int iso646_cn_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + if (c < 0x80) + { + if (c == 0x24) + *pwc = (ucs4_t)0x00a5; + else if (c == 0x7e) + *pwc = (ucs4_t)0x203e; + else + *pwc = (ucs4_t)c; + return 1; + } + return RET_ILSEQ; +} + +static int iso646_cn_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0x0080 && !(wc == 0x0024 || wc == 0x007e)) + { + *r = wc; + return 1; + } + if (wc == 0x00a5) + { + *r = 0x24; + return 1; + } + if (wc == 0x203e) + { + *r = 0x7e; + return 1; + } + return RET_ILUNI; +} + +#endif /* _ISO646_CN_H_ */ diff --git a/lib/converters/iso646_jp.h b/lib/converters/iso646_jp.h new file mode 100644 index 00000000..2eabc04d --- /dev/null +++ b/lib/converters/iso646_jp.h @@ -0,0 +1,72 @@ +/** + * @file iso646_jp.h + * @brief ISO646-JP + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * also known as JIS_C6220-1969-RO + */ + +#ifndef _ISO646_JP_H_ +#define _ISO646_JP_H_ + +#include "reiconv_defines.h" + +/* This is the lower half of JIS_X0201. */ + +static int iso646_jp_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + if (c < 0x80) + { + if (c == 0x5c) + *pwc = (ucs4_t)0x00a5; + else if (c == 0x7e) + *pwc = (ucs4_t)0x203e; + else + *pwc = (ucs4_t)c; + return 1; + } + return RET_ILSEQ; +} + +static int iso646_jp_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0x0080 && !(wc == 0x005c || wc == 0x007e)) + { + *r = wc; + return 1; + } + if (wc == 0x00a5) + { + *r = 0x5c; + return 1; + } + if (wc == 0x203e) + { + *r = 0x7e; + return 1; + } + return RET_ILUNI; +} + +#endif /* _ISO646_JP_H_ */ diff --git a/lib/ucs4be.h b/lib/converters/iso8859_1.h similarity index 52% rename from lib/ucs4be.h rename to lib/converters/iso8859_1.h index ecdf8f3e..a9789cf6 100644 --- a/lib/ucs4be.h +++ b/lib/converters/iso8859_1.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_1.h + * @brief ISO-8859-1 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,33 +18,30 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * UCS-4BE = UCS-4 big endian - */ +#ifndef _ISO8859_1_H_ +#define _ISO8859_1_H_ -static int -ucs4be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +#include "reiconv_defines.h" + +static int iso8859_1_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - if (n >= 4) { - *pwc = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]; - return 4; - } - return RET_TOOFEW(0); + unsigned char c = *s; + *pwc = (ucs4_t)c; + return 1; } -static int -ucs4be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_1_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 4) { - r[0] = (unsigned char) (wc >> 24); - r[1] = (unsigned char) (wc >> 16); - r[2] = (unsigned char) (wc >> 8); - r[3] = (unsigned char) wc; - return 4; - } else - return RET_TOOSMALL; + if (wc < 0x0100) + { + *r = wc; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_1_H_ */ diff --git a/lib/iso8859_10.h b/lib/converters/iso8859_10.h similarity index 78% rename from lib/iso8859_10.h rename to lib/converters/iso8859_10.h index 9de1fd0c..4b26e398 100644 --- a/lib/iso8859_10.h +++ b/lib/converters/iso8859_10.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_10.h + * @brief ISO-8859-10 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-10 - */ +#ifndef _ISO8859_10_H_ +#define _ISO8859_10_H_ + +#include "reiconv_defines.h" static const unsigned short iso8859_10_2uni[96] = { /* 0xa0 */ @@ -42,15 +48,14 @@ static const unsigned short iso8859_10_2uni[96] = { 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x0138, }; -static int -iso8859_10_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int iso8859_10_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) iso8859_10_2uni[c-0xa0]; - return 1; + unsigned char c = *s; + if (c < 0xa0) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)iso8859_10_2uni[c - 0xa0]; + return 1; } static const unsigned char iso8859_10_page00[224] = { @@ -85,21 +90,24 @@ static const unsigned char iso8859_10_page00[224] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0xac, 0xbc, 0x00, /* 0x78-0x7f */ }; -static int -iso8859_10_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_10_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0180) - c = iso8859_10_page00[wc-0x00a0]; - else if (wc == 0x2015) - c = 0xbd; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0180) + c = iso8859_10_page00[wc - 0x00a0]; + else if (wc == 0x2015) + c = 0xbd; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_10_H_ */ diff --git a/lib/converters/iso8859_11.h b/lib/converters/iso8859_11.h new file mode 100644 index 00000000..476eb8bd --- /dev/null +++ b/lib/converters/iso8859_11.h @@ -0,0 +1,61 @@ +/** + * @file iso8859_11.h + * @brief ISO-8859-11 + * @copyright Copyright (C) 1999-2004, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _ISO8859_11_H_ +#define _ISO8859_11_H_ + +#include "reiconv_defines.h" + +static int iso8859_11_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + if (c < 0xa1) + { + *pwc = (ucs4_t)c; + return 1; + } + else if (c <= 0xfb && !(c >= 0xdb && c <= 0xde)) + { + *pwc = (ucs4_t)(c + 0x0d60); + return 1; + } + return RET_ILSEQ; +} + +static int iso8859_11_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0x00a1) + { + *r = wc; + return 1; + } + else if (wc >= 0x0e01 && wc <= 0x0e5b && !(wc >= 0x0e3b && wc <= 0x0e3e)) + { + *r = wc - 0x0d60; + return 1; + } + return RET_ILUNI; +} + +#endif /* _ISO8859_11_H_ */ diff --git a/lib/iso8859_13.h b/lib/converters/iso8859_13.h similarity index 78% rename from lib/iso8859_13.h rename to lib/converters/iso8859_13.h index 643d6177..8b84ea91 100644 --- a/lib/iso8859_13.h +++ b/lib/converters/iso8859_13.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_13.h + * @brief ISO-8859-13 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-13 - */ +#ifndef _ISO8859_13_H_ +#define _ISO8859_13_H_ + +#include "reiconv_defines.h" static const unsigned short iso8859_13_2uni[96] = { /* 0xa0 */ @@ -42,15 +48,14 @@ static const unsigned short iso8859_13_2uni[96] = { 0x0173, 0x0142, 0x015b, 0x016b, 0x00fc, 0x017c, 0x017e, 0x2019, }; -static int -iso8859_13_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int iso8859_13_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) iso8859_13_2uni[c-0xa0]; - return 1; + unsigned char c = *s; + if (c < 0xa0) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)iso8859_13_2uni[c - 0xa0]; + return 1; } static const unsigned char iso8859_13_page00[224] = { @@ -88,21 +93,24 @@ static const unsigned char iso8859_13_page20[8] = { 0x00, 0xff, 0x00, 0x00, 0xb4, 0xa1, 0xa5, 0x00, /* 0x18-0x1f */ }; -static int -iso8859_13_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_13_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0180) - c = iso8859_13_page00[wc-0x00a0]; - else if (wc >= 0x2018 && wc < 0x2020) - c = iso8859_13_page20[wc-0x2018]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0180) + c = iso8859_13_page00[wc - 0x00a0]; + else if (wc >= 0x2018 && wc < 0x2020) + c = iso8859_13_page20[wc - 0x2018]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_13_H_ */ diff --git a/lib/iso8859_14.h b/lib/converters/iso8859_14.h similarity index 77% rename from lib/iso8859_14.h rename to lib/converters/iso8859_14.h index 8a096e24..8415346a 100644 --- a/lib/iso8859_14.h +++ b/lib/converters/iso8859_14.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_14.h + * @brief ISO-8859-14 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-14 - */ +#ifndef _ISO8859_14_H_ +#define _ISO8859_14_H_ + +#include "reiconv_defines.h" static const unsigned short iso8859_14_2uni[96] = { /* 0xa0 */ @@ -42,15 +48,14 @@ static const unsigned short iso8859_14_2uni[96] = { 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x0177, 0x00ff, }; -static int -iso8859_14_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int iso8859_14_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c >= 0xa0) - *pwc = (ucs4_t) iso8859_14_2uni[c-0xa0]; - else - *pwc = (ucs4_t) c; - return 1; + unsigned char c = *s; + if (c >= 0xa0) + *pwc = (ucs4_t)iso8859_14_2uni[c - 0xa0]; + else + *pwc = (ucs4_t)c; + return 1; } static const unsigned char iso8859_14_page00[96] = { @@ -100,27 +105,30 @@ static const unsigned char iso8859_14_page1e_1[8] = { 0x00, 0x00, 0xac, 0xbc, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ }; -static int -iso8859_14_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_14_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = iso8859_14_page00[wc-0x00a0]; - else if (wc >= 0x0108 && wc < 0x0128) - c = iso8859_14_page01_0[wc-0x0108]; - else if (wc >= 0x0170 && wc < 0x0180) - c = iso8859_14_page01_1[wc-0x0170]; - else if (wc >= 0x1e00 && wc < 0x1e88) - c = iso8859_14_page1e_0[wc-0x1e00]; - else if (wc >= 0x1ef0 && wc < 0x1ef8) - c = iso8859_14_page1e_1[wc-0x1ef0]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = iso8859_14_page00[wc - 0x00a0]; + else if (wc >= 0x0108 && wc < 0x0128) + c = iso8859_14_page01_0[wc - 0x0108]; + else if (wc >= 0x0170 && wc < 0x0180) + c = iso8859_14_page01_1[wc - 0x0170]; + else if (wc >= 0x1e00 && wc < 0x1e88) + c = iso8859_14_page1e_0[wc - 0x1e00]; + else if (wc >= 0x1ef0 && wc < 0x1ef8) + c = iso8859_14_page1e_1[wc - 0x1ef0]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_14_H_ */ diff --git a/lib/iso8859_15.h b/lib/converters/iso8859_15.h similarity index 62% rename from lib/iso8859_15.h rename to lib/converters/iso8859_15.h index 0b3193f5..05aff7d1 100644 --- a/lib/iso8859_15.h +++ b/lib/converters/iso8859_15.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_15.h + * @brief ISO-8859-15 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-15 - */ +#ifndef _ISO8859_15_H_ +#define _ISO8859_15_H_ + +#include "reiconv_defines.h" static const unsigned short iso8859_15_2uni[32] = { /* 0xa0 */ @@ -30,15 +36,14 @@ static const unsigned short iso8859_15_2uni[32] = { 0x017e, 0x00b9, 0x00ba, 0x00bb, 0x0152, 0x0153, 0x0178, 0x00bf, }; -static int -iso8859_15_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int iso8859_15_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c >= 0xa0 && c < 0xc0) - *pwc = (ucs4_t) iso8859_15_2uni[c-0xa0]; - else - *pwc = (ucs4_t) c; - return 1; + unsigned char c = *s; + if (c >= 0xa0 && c < 0xc0) + *pwc = (ucs4_t)iso8859_15_2uni[c - 0xa0]; + else + *pwc = (ucs4_t)c; + return 1; } static const unsigned char iso8859_15_page00[32] = { @@ -56,25 +61,28 @@ static const unsigned char iso8859_15_page01[48] = { 0xbe, 0x00, 0x00, 0x00, 0x00, 0xb4, 0xb8, 0x00, /* 0x78-0x7f */ }; -static int -iso8859_15_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_15_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00c0) - c = iso8859_15_page00[wc-0x00a0]; - else if (wc >= 0x00c0 && wc < 0x0100) - c = wc; - else if (wc >= 0x0150 && wc < 0x0180) - c = iso8859_15_page01[wc-0x0150]; - else if (wc == 0x20ac) - c = 0xa4; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00c0) + c = iso8859_15_page00[wc - 0x00a0]; + else if (wc >= 0x00c0 && wc < 0x0100) + c = wc; + else if (wc >= 0x0150 && wc < 0x0180) + c = iso8859_15_page01[wc - 0x0150]; + else if (wc == 0x20ac) + c = 0xa4; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_15_H_ */ diff --git a/lib/iso8859_16.h b/lib/converters/iso8859_16.h similarity index 77% rename from lib/iso8859_16.h rename to lib/converters/iso8859_16.h index 8e77fd52..3e4c5fcf 100644 --- a/lib/iso8859_16.h +++ b/lib/converters/iso8859_16.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_16.h + * @brief ISO-8859-16 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-16 - */ +#ifndef _ISO8859_16_H_ +#define _ISO8859_16_H_ + +#include "reiconv_defines.h" static const unsigned short iso8859_16_2uni[96] = { /* 0xa0 */ @@ -42,15 +48,14 @@ static const unsigned short iso8859_16_2uni[96] = { 0x0171, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0119, 0x021b, 0x00ff, }; -static int -iso8859_16_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int iso8859_16_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) iso8859_16_2uni[c-0xa0]; - return 1; + unsigned char c = *s; + if (c < 0xa0) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)iso8859_16_2uni[c - 0xa0]; + return 1; } static const unsigned char iso8859_16_page00[224] = { @@ -91,25 +96,28 @@ static const unsigned char iso8859_16_page20[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, 0xa5, 0x00, /* 0x18-0x1f */ }; -static int -iso8859_16_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_16_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0180) - c = iso8859_16_page00[wc-0x00a0]; - else if (wc >= 0x0218 && wc < 0x0220) - c = iso8859_16_page02[wc-0x0218]; - else if (wc >= 0x2018 && wc < 0x2020) - c = iso8859_16_page20[wc-0x2018]; - else if (wc == 0x20ac) - c = 0xa4; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0180) + c = iso8859_16_page00[wc - 0x00a0]; + else if (wc >= 0x0218 && wc < 0x0220) + c = iso8859_16_page02[wc - 0x0218]; + else if (wc >= 0x2018 && wc < 0x2020) + c = iso8859_16_page20[wc - 0x2018]; + else if (wc == 0x20ac) + c = 0xa4; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_16_H_ */ diff --git a/lib/iso8859_2.h b/lib/converters/iso8859_2.h similarity index 79% rename from lib/iso8859_2.h rename to lib/converters/iso8859_2.h index 362d687c..ddb51f72 100644 --- a/lib/iso8859_2.h +++ b/lib/converters/iso8859_2.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_2.h + * @brief ISO-8859-2 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-2 - */ +#ifndef _ISO8859_2_H_ +#define _ISO8859_2_H_ + +#include "reiconv_defines.h" static const unsigned short iso8859_2_2uni[96] = { /* 0xa0 */ @@ -42,15 +48,14 @@ static const unsigned short iso8859_2_2uni[96] = { 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9, }; -static int -iso8859_2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int iso8859_2_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) iso8859_2_2uni[c-0xa0]; - return 1; + unsigned char c = *s; + if (c < 0xa0) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)iso8859_2_2uni[c - 0xa0]; + return 1; } static const unsigned char iso8859_2_page00[224] = { @@ -91,21 +96,24 @@ static const unsigned char iso8859_2_page02[32] = { 0xa2, 0xff, 0x00, 0xb2, 0x00, 0xbd, 0x00, 0x00, /* 0xd8-0xdf */ }; -static int -iso8859_2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_2_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0180) - c = iso8859_2_page00[wc-0x00a0]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = iso8859_2_page02[wc-0x02c0]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0180) + c = iso8859_2_page00[wc - 0x00a0]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = iso8859_2_page02[wc - 0x02c0]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_2_H_ */ diff --git a/lib/iso8859_3.h b/lib/converters/iso8859_3.h similarity index 74% rename from lib/iso8859_3.h rename to lib/converters/iso8859_3.h index 027f6608..6eb215fd 100644 --- a/lib/iso8859_3.h +++ b/lib/converters/iso8859_3.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_3.h + * @brief ISO-8859-3 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-3 - */ +#ifndef _ISO8859_3_H_ +#define _ISO8859_3_H_ + +#include "reiconv_defines.h" static const unsigned short iso8859_3_2uni[96] = { /* 0xa0 */ @@ -42,22 +48,24 @@ static const unsigned short iso8859_3_2uni[96] = { 0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9, }; -static int -iso8859_3_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int iso8859_3_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = iso8859_3_2uni[c-0xa0]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0xa0) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = iso8859_3_2uni[c - 0xa0]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char iso8859_3_page00[96] = { @@ -95,23 +103,26 @@ static const unsigned char iso8859_3_page02[8] = { 0xa2, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ }; -static int -iso8859_3_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_3_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = iso8859_3_page00[wc-0x00a0]; - else if (wc >= 0x0108 && wc < 0x0180) - c = iso8859_3_page01[wc-0x0108]; - else if (wc >= 0x02d8 && wc < 0x02e0) - c = iso8859_3_page02[wc-0x02d8]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = iso8859_3_page00[wc - 0x00a0]; + else if (wc >= 0x0108 && wc < 0x0180) + c = iso8859_3_page01[wc - 0x0108]; + else if (wc >= 0x02d8 && wc < 0x02e0) + c = iso8859_3_page02[wc - 0x02d8]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_3_H_ */ diff --git a/lib/iso8859_4.h b/lib/converters/iso8859_4.h similarity index 79% rename from lib/iso8859_4.h rename to lib/converters/iso8859_4.h index 015777d2..6cb064b7 100644 --- a/lib/iso8859_4.h +++ b/lib/converters/iso8859_4.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_4.h + * @brief ISO-8859-4 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-4 - */ +#ifndef _ISO8859_4_H_ +#define _ISO8859_4_H_ + +#include "reiconv_defines.h" static const unsigned short iso8859_4_2uni[96] = { /* 0xa0 */ @@ -42,15 +48,14 @@ static const unsigned short iso8859_4_2uni[96] = { 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9, }; -static int -iso8859_4_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int iso8859_4_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) iso8859_4_2uni[c-0xa0]; - return 1; + unsigned char c = *s; + if (c < 0xa0) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)iso8859_4_2uni[c - 0xa0]; + return 1; } static const unsigned char iso8859_4_page00[224] = { @@ -91,21 +96,24 @@ static const unsigned char iso8859_4_page02[32] = { 0x00, 0xff, 0x00, 0xb2, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ }; -static int -iso8859_4_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_4_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0180) - c = iso8859_4_page00[wc-0x00a0]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = iso8859_4_page02[wc-0x02c0]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0180) + c = iso8859_4_page00[wc - 0x00a0]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = iso8859_4_page02[wc - 0x02c0]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_4_H_ */ diff --git a/lib/iso8859_5.h b/lib/converters/iso8859_5.h similarity index 72% rename from lib/iso8859_5.h rename to lib/converters/iso8859_5.h index f9ed4ee0..4c8d1605 100644 --- a/lib/iso8859_5.h +++ b/lib/converters/iso8859_5.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_5.h + * @brief ISO-8859-5 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-5 - */ +#ifndef _ISO8859_5_H_ +#define _ISO8859_5_H_ + +#include "reiconv_defines.h" static const unsigned short iso8859_5_2uni[96] = { /* 0xa0 */ @@ -42,15 +48,14 @@ static const unsigned short iso8859_5_2uni[96] = { 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x00a7, 0x045e, 0x045f, }; -static int -iso8859_5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int iso8859_5_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) iso8859_5_2uni[c-0xa0]; - return 1; + unsigned char c = *s; + if (c < 0xa0) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)iso8859_5_2uni[c - 0xa0]; + return 1; } static const unsigned char iso8859_5_page00[16] = { @@ -72,23 +77,26 @@ static const unsigned char iso8859_5_page04[96] = { 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0xfe, 0xff, /* 0x58-0x5f */ }; -static int -iso8859_5_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_5_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00b0) - c = iso8859_5_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x0460) - c = iso8859_5_page04[wc-0x0400]; - else if (wc == 0x2116) - c = 0xf0; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00b0) + c = iso8859_5_page00[wc - 0x00a0]; + else if (wc >= 0x0400 && wc < 0x0460) + c = iso8859_5_page04[wc - 0x0400]; + else if (wc == 0x2116) + c = 0xf0; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_5_H_ */ diff --git a/lib/iso8859_6.h b/lib/converters/iso8859_6.h similarity index 69% rename from lib/iso8859_6.h rename to lib/converters/iso8859_6.h index f1f30ac1..68951ed2 100644 --- a/lib/iso8859_6.h +++ b/lib/converters/iso8859_6.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_6.h + * @brief ISO-8859-6 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-6 - */ +#ifndef _ISO8859_6_H_ +#define _ISO8859_6_H_ + +#include "reiconv_defines.h" static const unsigned short iso8859_6_2uni[96] = { /* 0xa0 */ @@ -42,22 +48,24 @@ static const unsigned short iso8859_6_2uni[96] = { 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, }; -static int -iso8859_6_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int iso8859_6_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = iso8859_6_2uni[c-0xa0]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0xa0) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = iso8859_6_2uni[c - 0xa0]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char iso8859_6_page00[16] = { @@ -77,21 +85,24 @@ static const unsigned char iso8859_6_page06[80] = { 0xf0, 0xf1, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ }; -static int -iso8859_6_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_6_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00b0) - c = iso8859_6_page00[wc-0x00a0]; - else if (wc >= 0x0608 && wc < 0x0658) - c = iso8859_6_page06[wc-0x0608]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00b0) + c = iso8859_6_page00[wc - 0x00a0]; + else if (wc >= 0x0608 && wc < 0x0658) + c = iso8859_6_page06[wc - 0x0608]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_6_H_ */ diff --git a/lib/iso8859_7.h b/lib/converters/iso8859_7.h similarity index 68% rename from lib/iso8859_7.h rename to lib/converters/iso8859_7.h index fa1db656..4c5d0da0 100644 --- a/lib/iso8859_7.h +++ b/lib/converters/iso8859_7.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_7.h + * @brief ISO-8859-7 + * @copyright Copyright (C) 1999-2004, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2004, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-7 - */ +#ifndef _ISO8859_7_H_ +#define _ISO8859_7_H_ + +#include "reiconv_defines.h" static const unsigned short iso8859_7_2uni[96] = { /* 0xa0 */ @@ -42,22 +48,24 @@ static const unsigned short iso8859_7_2uni[96] = { 0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0xfffd, }; -static int -iso8859_7_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int iso8859_7_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = iso8859_7_2uni[c-0xa0]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0xa0) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = iso8859_7_2uni[c - 0xa0]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char iso8859_7_page00[32] = { @@ -84,27 +92,30 @@ static const unsigned char iso8859_7_page20[16] = { 0xa1, 0xa2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ }; -static int -iso8859_7_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_7_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00c0) - c = iso8859_7_page00[wc-0x00a0]; - else if (wc >= 0x0378 && wc < 0x03d0) - c = iso8859_7_page03[wc-0x0378]; - else if (wc >= 0x2010 && wc < 0x2020) - c = iso8859_7_page20[wc-0x2010]; - else if (wc == 0x20ac) - c = 0xa4; - else if (wc == 0x20af) - c = 0xa5; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00c0) + c = iso8859_7_page00[wc - 0x00a0]; + else if (wc >= 0x0378 && wc < 0x03d0) + c = iso8859_7_page03[wc - 0x0378]; + else if (wc >= 0x2010 && wc < 0x2020) + c = iso8859_7_page20[wc - 0x2010]; + else if (wc == 0x20ac) + c = 0xa4; + else if (wc == 0x20af) + c = 0xa5; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_7_H_ */ diff --git a/lib/iso8859_8.h b/lib/converters/iso8859_8.h similarity index 70% rename from lib/iso8859_8.h rename to lib/converters/iso8859_8.h index 4908b853..022cfb9c 100644 --- a/lib/iso8859_8.h +++ b/lib/converters/iso8859_8.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_8.h + * @brief ISO-8859-8 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-8 - */ +#ifndef _ISO8859_8_H_ +#define _ISO8859_8_H_ + +#include "reiconv_defines.h" static const unsigned short iso8859_8_2uni[96] = { /* 0xa0 */ @@ -42,22 +48,24 @@ static const unsigned short iso8859_8_2uni[96] = { 0x05e8, 0x05e9, 0x05ea, 0xfffd, 0xfffd, 0x200e, 0x200f, 0xfffd, }; -static int -iso8859_8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int iso8859_8_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c >= 0xa0) { - unsigned short wc = iso8859_8_2uni[c-0xa0]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c >= 0xa0) + { + unsigned short wc = iso8859_8_2uni[c - 0xa0]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } } - } - else { - *pwc = (ucs4_t) c; - return 1; - } - return RET_ILSEQ; + else + { + *pwc = (ucs4_t)c; + return 1; + } + return RET_ILSEQ; } static const unsigned char iso8859_8_page00[88] = { @@ -84,23 +92,26 @@ static const unsigned char iso8859_8_page20[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdf, /* 0x10-0x17 */ }; -static int -iso8859_8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_8_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00f8) - c = iso8859_8_page00[wc-0x00a0]; - else if (wc >= 0x05d0 && wc < 0x05f0) - c = iso8859_8_page05[wc-0x05d0]; - else if (wc >= 0x2008 && wc < 0x2018) - c = iso8859_8_page20[wc-0x2008]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00f8) + c = iso8859_8_page00[wc - 0x00a0]; + else if (wc >= 0x05d0 && wc < 0x05f0) + c = iso8859_8_page05[wc - 0x05d0]; + else if (wc >= 0x2008 && wc < 0x2018) + c = iso8859_8_page20[wc - 0x2008]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_8_H_ */ diff --git a/lib/iso8859_9.h b/lib/converters/iso8859_9.h similarity index 76% rename from lib/iso8859_9.h rename to lib/converters/iso8859_9.h index 63b84eb5..6e22eb81 100644 --- a/lib/iso8859_9.h +++ b/lib/converters/iso8859_9.h @@ -1,5 +1,10 @@ +/** + * @file iso8859_9.h + * @brief ISO-8859-9 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-9 - */ +#ifndef _ISO8859_9_H_ +#define _ISO8859_9_H_ + +#include "reiconv_defines.h" static const unsigned short iso8859_9_2uni[48] = { /* 0xd0 */ @@ -64,21 +70,24 @@ static const unsigned char iso8859_9_page01[72] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xfe, /* 0x58-0x5f */ }; -static int -iso8859_9_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int iso8859_9_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00d0) { - *r = wc; - return 1; - } - else if (wc >= 0x00d0 && wc < 0x0100) - c = iso8859_9_page00[wc-0x00d0]; - else if (wc >= 0x0118 && wc < 0x0160) - c = iso8859_9_page01[wc-0x0118]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00d0) + { + *r = wc; + return 1; + } + else if (wc >= 0x00d0 && wc < 0x0100) + c = iso8859_9_page00[wc - 0x00d0]; + else if (wc >= 0x0118 && wc < 0x0160) + c = iso8859_9_page01[wc - 0x0118]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _ISO8859_9_H_ */ diff --git a/lib/isoir165.h b/lib/converters/isoir165.h similarity index 57% rename from lib/isoir165.h rename to lib/converters/isoir165.h index da668fc0..d9cfac60 100644 --- a/lib/isoir165.h +++ b/lib/converters/isoir165.h @@ -1,5 +1,10 @@ +/** + * @file isoir165.h + * @brief ISO-IR-165 + * @copyright Copyright (C) 1999-2001, 2005, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2005, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,14 +18,10 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-IR-165 - */ - /* * ISO-IR-165 is an extension of GB 2312, consisting of: * 1. GB 6345.1-86 corrections: @@ -77,82 +78,106 @@ * Row 0x2F: Taken from Koichi Yasuoka's Uni2GB table. */ +#ifndef _ISOIR165_H_ +#define _ISOIR165_H_ + +#include "converters/gb2312.h" +#include "converters/iso646_cn.h" +#include "reiconv_defines.h" + #include "isoir165ext.h" -static int -isoir165_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +#include + +static int isoir165_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - int ret; + int ret; - /* Map full-width pinyin (row 0x28) like half-width pinyin (row 0x2B). */ - if (s[0] == 0x28) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 <= 0x40) { - unsigned char buf[2]; - buf[0] = 0x2b; - buf[1] = c2; - ret = isoir165ext_mbtowc(conv,pwc,buf,2); - if (ret != RET_ILSEQ) - return ret; - } + /* Map full-width pinyin (row 0x28) like half-width pinyin (row 0x2B). */ + if (s[0] == 0x28) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 <= 0x40) + { + unsigned char buf[2]; + buf[0] = 0x2b; + buf[1] = c2; + ret = isoir165ext_mbtowc(conv, pwc, buf, 2); + if (ret != RET_ILSEQ) + return ret; + } + } } - } - /* Try the GB2312 -> Unicode table. */ - ret = gb2312_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - /* Row 0x2A is GB_1988-80. */ - if (s[0] == 0x2a) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 < 0x7f) { - ret = iso646_cn_mbtowc(conv,pwc,s+1,1); - if (ret != 1) abort(); - return 2; - } - return RET_ILSEQ; + /* Try the GB2312 -> Unicode table. */ + ret = gb2312_mbtowc(conv, pwc, s, n); + if (ret != RET_ILSEQ) + return ret; + /* Row 0x2A is GB_1988-80. */ + if (s[0] == 0x2a) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 < 0x7f) + { + ret = iso646_cn_mbtowc(conv, pwc, s + 1, 1); + if (ret != 1) + abort(); + return 2; + } + return RET_ILSEQ; + } + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - /* Try the ISO-IR-165 extensions -> Unicode table. */ - ret = isoir165ext_mbtowc(conv,pwc,s,n); - return ret; + /* Try the ISO-IR-165 extensions -> Unicode table. */ + ret = isoir165ext_mbtowc(conv, pwc, s, n); + return ret; } -static int -isoir165_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int isoir165_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char buf[2]; - int ret; + unsigned char buf[2]; + int ret; - /* Try the Unicode -> GB2312 table. */ - ret = gb2312_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (!(buf[0] == 0x28 && buf[1] >= 0x21 && buf[1] <= 0x40)) { - if (n >= 2) { - r[0] = buf[0]; - r[1] = buf[1]; - return 2; - } - return RET_TOOSMALL; + /* Try the Unicode -> GB2312 table. */ + ret = gb2312_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (!(buf[0] == 0x28 && buf[1] >= 0x21 && buf[1] <= 0x40)) + { + if (n >= 2) + { + r[0] = buf[0]; + r[1] = buf[1]; + return 2; + } + return RET_TOOSMALL; + } } - } - /* Row 0x2A is GB_1988-80. */ - ret = iso646_cn_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] >= 0x21 && buf[0] < 0x7f) { - if (n >= 2) { - r[0] = 0x2a; - r[1] = buf[0]; - return 2; - } - return RET_TOOSMALL; + /* Row 0x2A is GB_1988-80. */ + ret = iso646_cn_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + if (ret != 1) + abort(); + if (buf[0] >= 0x21 && buf[0] < 0x7f) + { + if (n >= 2) + { + r[0] = 0x2a; + r[1] = buf[0]; + return 2; + } + return RET_TOOSMALL; + } } - } - /* Try the Unicode -> ISO-IR-165 extensions table. */ - ret = isoir165ext_wctomb(conv,r,wc,n); - return ret; + /* Try the Unicode -> ISO-IR-165 extensions table. */ + ret = isoir165ext_wctomb(conv, r, wc, n); + return ret; } + +#endif /* _ISOIR165_H_ */ diff --git a/lib/isoir165ext.h b/lib/converters/isoir165ext.h similarity index 92% rename from lib/isoir165ext.h rename to lib/converters/isoir165ext.h index ef0796ce..5f43dbaf 100644 --- a/lib/isoir165ext.h +++ b/lib/converters/isoir165ext.h @@ -1,5 +1,10 @@ +/** + * @file isoir165ext.h + * @brief ISO-IR-165 extensions + * @copyright Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-IR-165 extensions - */ +#ifndef _ISOIR165EXT_H_ +#define _ISOIR165EXT_H_ + +#include "reiconv_defines.h" static const unsigned short isoir165ext_2uni_page2b[470] = { /* 0x2b */ @@ -156,33 +162,39 @@ static const unsigned short isoir165ext_2uni_page7a[470] = { 0x68d0, 0x7306, 0x9f81, 0x9f82, 0x92c6, 0x9491, }; -static int -isoir165ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int isoir165ext_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x2b && c1 <= 0x2f) || (c1 >= 0x7a && c1 <= 0x7e)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 < 0x7f) { - unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); - unsigned short wc = 0xfffd; - if (i < 8366) { - if (i < 1410) - wc = isoir165ext_2uni_page2b[i-940]; - } else { - if (i < 8836) - wc = isoir165ext_2uni_page7a[i-8366]; + unsigned char c1 = s[0]; + if ((c1 >= 0x2b && c1 <= 0x2f) || (c1 >= 0x7a && c1 <= 0x7e)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 < 0x7f) + { + unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); + unsigned short wc = 0xfffd; + if (i < 8366) + { + if (i < 1410) + wc = isoir165ext_2uni_page2b[i - 940]; + } + else + { + if (i < 8836) + wc = isoir165ext_2uni_page7a[i - 8366]; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; - } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned short isoir165ext_2charset[876] = { @@ -751,49 +763,54 @@ static const Summary16 isoir165ext_uni2indx_pageff[5] = { { 875, 0x0080 }, }; -static int -isoir165ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int isoir165ext_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc >= 0x0000 && wc < 0x0200) - summary = &isoir165ext_uni2indx_page00[(wc>>4)]; - else if (wc >= 0x0300 && wc < 0x03c0) - summary = &isoir165ext_uni2indx_page03[(wc>>4)-0x030]; - else if (wc >= 0x1e00 && wc < 0x1fc0) - summary = &isoir165ext_uni2indx_page1e[(wc>>4)-0x1e0]; - else if (wc >= 0x3000 && wc < 0x3040) - summary = &isoir165ext_uni2indx_page30[(wc>>4)-0x300]; - else if (wc >= 0x3200 && wc < 0x3400) - summary = &isoir165ext_uni2indx_page32[(wc>>4)-0x320]; - else if (wc >= 0x4e00 && wc < 0x7d00) - summary = &isoir165ext_uni2indx_page4e[(wc>>4)-0x4e0]; - else if (wc >= 0x7e00 && wc < 0x92d0) - summary = &isoir165ext_uni2indx_page7e[(wc>>4)-0x7e0]; - else if (wc >= 0x9400 && wc < 0x9cf0) - summary = &isoir165ext_uni2indx_page94[(wc>>4)-0x940]; - else if (wc >= 0x9e00 && wc < 0x9f90) - summary = &isoir165ext_uni2indx_page9e[(wc>>4)-0x9e0]; - else if (wc >= 0xff00 && wc < 0xff50) - summary = &isoir165ext_uni2indx_pageff[(wc>>4)-0xff0]; - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = isoir165ext_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc >= 0x0000 && wc < 0x0200) + summary = &isoir165ext_uni2indx_page00[(wc >> 4)]; + else if (wc >= 0x0300 && wc < 0x03c0) + summary = &isoir165ext_uni2indx_page03[(wc >> 4) - 0x030]; + else if (wc >= 0x1e00 && wc < 0x1fc0) + summary = &isoir165ext_uni2indx_page1e[(wc >> 4) - 0x1e0]; + else if (wc >= 0x3000 && wc < 0x3040) + summary = &isoir165ext_uni2indx_page30[(wc >> 4) - 0x300]; + else if (wc >= 0x3200 && wc < 0x3400) + summary = &isoir165ext_uni2indx_page32[(wc >> 4) - 0x320]; + else if (wc >= 0x4e00 && wc < 0x7d00) + summary = &isoir165ext_uni2indx_page4e[(wc >> 4) - 0x4e0]; + else if (wc >= 0x7e00 && wc < 0x92d0) + summary = &isoir165ext_uni2indx_page7e[(wc >> 4) - 0x7e0]; + else if (wc >= 0x9400 && wc < 0x9cf0) + summary = &isoir165ext_uni2indx_page94[(wc >> 4) - 0x940]; + else if (wc >= 0x9e00 && wc < 0x9f90) + summary = &isoir165ext_uni2indx_page9e[(wc >> 4) - 0x9e0]; + else if (wc >= 0xff00 && wc < 0xff50) + summary = &isoir165ext_uni2indx_pageff[(wc >> 4) - 0xff0]; + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = isoir165ext_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _ISOIR165EXT_H_ */ diff --git a/lib/converters/java.h b/lib/converters/java.h new file mode 100644 index 00000000..b93172b1 --- /dev/null +++ b/lib/converters/java.h @@ -0,0 +1,170 @@ +/** + * @file java.h + * @brief JAVA + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* + * This is ISO 8859-1 with \uXXXX escape sequences, denoting Unicode BMP + * characters. Consecutive pairs of \uXXXX escape sequences in the surrogate + * range, as in UTF-16, denote Unicode characters outside the BMP. + */ + +#ifndef _JAVA_H_ +#define _JAVA_H_ + +#include "reiconv_defines.h" + +static int java_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c; + ucs4_t wc, wc2; + int i; + + c = s[0]; + if (c != '\\') + { + *pwc = c; + return 1; + } + if (n < 2) + return RET_TOOFEW(0); + if (s[1] != 'u') + goto simply_backslash; + wc = 0; + for (i = 2; i < 6; i++) + { + if (n <= i) + return RET_TOOFEW(0); + c = s[i]; + if (c >= '0' && c <= '9') + c -= '0'; + else if (c >= 'A' && c <= 'Z') + c -= 'A' - 10; + else if (c >= 'a' && c <= 'z') + c -= 'a' - 10; + else + goto simply_backslash; + wc |= (ucs4_t)c << (4 * (5 - i)); + } + if (!(wc >= 0xd800 && wc < 0xe000)) + { + *pwc = wc; + return 6; + } + if (wc >= 0xdc00) + goto simply_backslash; + if (n < 7) + return RET_TOOFEW(0); + if (s[6] != '\\') + goto simply_backslash; + if (n < 8) + return RET_TOOFEW(0); + if (s[7] != 'u') + goto simply_backslash; + wc2 = 0; + for (i = 8; i < 12; i++) + { + if (n <= i) + return RET_TOOFEW(0); + c = s[i]; + if (c >= '0' && c <= '9') + c -= '0'; + else if (c >= 'A' && c <= 'Z') + c -= 'A' - 10; + else if (c >= 'a' && c <= 'z') + c -= 'a' - 10; + else + goto simply_backslash; + wc2 |= (ucs4_t)c << (4 * (11 - i)); + } + if (!(wc2 >= 0xdc00 && wc2 < 0xe000)) + goto simply_backslash; + *pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00); + return 12; +simply_backslash: + *pwc = '\\'; + return 1; +} + +static int java_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0x80) + { + *r = wc; + return 1; + } + else if (wc < 0x10000) + { + if (n >= 6) + { + unsigned int i; + r[0] = '\\'; + r[1] = 'u'; + i = (wc >> 12) & 0x0f; + r[2] = (i < 10 ? '0' + i : 'a' - 10 + i); + i = (wc >> 8) & 0x0f; + r[3] = (i < 10 ? '0' + i : 'a' - 10 + i); + i = (wc >> 4) & 0x0f; + r[4] = (i < 10 ? '0' + i : 'a' - 10 + i); + i = wc & 0x0f; + r[5] = (i < 10 ? '0' + i : 'a' - 10 + i); + return 6; + } + else + return RET_TOOSMALL; + } + else if (wc < 0x110000) + { + if (n >= 12) + { + ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10); + ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff); + unsigned int i; + r[0] = '\\'; + r[1] = 'u'; + i = (wc1 >> 12) & 0x0f; + r[2] = (i < 10 ? '0' + i : 'a' - 10 + i); + i = (wc1 >> 8) & 0x0f; + r[3] = (i < 10 ? '0' + i : 'a' - 10 + i); + i = (wc1 >> 4) & 0x0f; + r[4] = (i < 10 ? '0' + i : 'a' - 10 + i); + i = wc1 & 0x0f; + r[5] = (i < 10 ? '0' + i : 'a' - 10 + i); + r[6] = '\\'; + r[7] = 'u'; + i = (wc2 >> 12) & 0x0f; + r[8] = (i < 10 ? '0' + i : 'a' - 10 + i); + i = (wc2 >> 8) & 0x0f; + r[9] = (i < 10 ? '0' + i : 'a' - 10 + i); + i = (wc2 >> 4) & 0x0f; + r[10] = (i < 10 ? '0' + i : 'a' - 10 + i); + i = wc2 & 0x0f; + r[11] = (i < 10 ? '0' + i : 'a' - 10 + i); + return 12; + } + else + return RET_TOOSMALL; + } + return RET_ILUNI; +} + +#endif /* _JAVA_H_ */ diff --git a/lib/converters/jisx0201.h b/lib/converters/jisx0201.h new file mode 100644 index 00000000..988b6c6c --- /dev/null +++ b/lib/converters/jisx0201.h @@ -0,0 +1,79 @@ +/** + * @file jisx0201.h + * @brief JISX0201.1976-0 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _JISX0201_H_ +#define _JISX0201_H_ + +#include "reiconv_defines.h" + +static int jisx0201_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + if (c < 0x80) + { + if (c == 0x5c) + *pwc = (ucs4_t)0x00a5; + else if (c == 0x7e) + *pwc = (ucs4_t)0x203e; + else + *pwc = (ucs4_t)c; + return 1; + } + else + { + if (c >= 0xa1 && c < 0xe0) + { + *pwc = (ucs4_t)c + 0xfec0; + return 1; + } + } + return RET_ILSEQ; +} + +static int jisx0201_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0x0080 && !(wc == 0x005c || wc == 0x007e)) + { + *r = wc; + return 1; + } + if (wc == 0x00a5) + { + *r = 0x5c; + return 1; + } + if (wc == 0x203e) + { + *r = 0x7e; + return 1; + } + if (wc >= 0xff61 && wc < 0xffa0) + { + *r = wc - 0xfec0; + return 1; + } + return RET_ILUNI; +} + +#endif /* _JISX0201_H_ */ diff --git a/lib/jisx0208.h b/lib/converters/jisx0208.h similarity index 98% rename from lib/jisx0208.h rename to lib/converters/jisx0208.h index ef45ba68..fd28f9ef 100644 --- a/lib/jisx0208.h +++ b/lib/converters/jisx0208.h @@ -1,5 +1,10 @@ +/** + * @file jisx0208.h + * @brief JISX0208.1990-0 + * @copyright Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * JISX0208.1990-0 - */ +#ifndef _JISX0208_H_ +#define _JISX0208_H_ + +#include "reiconv_defines.h" static const unsigned short jisx0208_2uni_page21[690] = { /* 0x21 */ @@ -2372,43 +2378,48 @@ static const Summary16 jisx0208_uni2indx_pageff[15] = { { 6877, 0x0000 }, { 6877, 0x0000 }, { 6877, 0x0028 }, }; -static int -jisx0208_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int jisx0208_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc >= 0x0000 && wc < 0x0100) - summary = &jisx0208_uni2indx_page00[(wc>>4)]; - else if (wc >= 0x0300 && wc < 0x0460) - summary = &jisx0208_uni2indx_page03[(wc>>4)-0x030]; - else if (wc >= 0x2000 && wc < 0x2320) - summary = &jisx0208_uni2indx_page20[(wc>>4)-0x200]; - else if (wc >= 0x2500 && wc < 0x2670) - summary = &jisx0208_uni2indx_page25[(wc>>4)-0x250]; - else if (wc >= 0x3000 && wc < 0x3100) - summary = &jisx0208_uni2indx_page30[(wc>>4)-0x300]; - else if (wc >= 0x4e00 && wc < 0x9fb0) - summary = &jisx0208_uni2indx_page4e[(wc>>4)-0x4e0]; - else if (wc >= 0xff00 && wc < 0xfff0) - summary = &jisx0208_uni2indx_pageff[(wc>>4)-0xff0]; - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = jisx0208_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc >= 0x0000 && wc < 0x0100) + summary = &jisx0208_uni2indx_page00[(wc >> 4)]; + else if (wc >= 0x0300 && wc < 0x0460) + summary = &jisx0208_uni2indx_page03[(wc >> 4) - 0x030]; + else if (wc >= 0x2000 && wc < 0x2320) + summary = &jisx0208_uni2indx_page20[(wc >> 4) - 0x200]; + else if (wc >= 0x2500 && wc < 0x2670) + summary = &jisx0208_uni2indx_page25[(wc >> 4) - 0x250]; + else if (wc >= 0x3000 && wc < 0x3100) + summary = &jisx0208_uni2indx_page30[(wc >> 4) - 0x300]; + else if (wc >= 0x4e00 && wc < 0x9fb0) + summary = &jisx0208_uni2indx_page4e[(wc >> 4) - 0x4e0]; + else if (wc >= 0xff00 && wc < 0xfff0) + summary = &jisx0208_uni2indx_pageff[(wc >> 4) - 0xff0]; + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = jisx0208_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _JISX0208_H_ */ diff --git a/lib/jisx0212.h b/lib/converters/jisx0212.h similarity index 97% rename from lib/jisx0212.h rename to lib/converters/jisx0212.h index 7479004c..713edf46 100644 --- a/lib/jisx0212.h +++ b/lib/converters/jisx0212.h @@ -1,5 +1,10 @@ +/** + * @file jisx0212.h + * @brief JISX0212.1990-0 + * @copyright Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * JISX0212.1990-0 - */ +#ifndef _JISX0212_H_ +#define _JISX0212_H_ + +#include "reiconv_defines.h" static const unsigned short jisx0212_2uni_page22[81] = { /* 0x22 */ @@ -909,39 +915,49 @@ static const unsigned short jisx0212_2uni_page30[5801] = { 0x9fa2, 0x9fa3, 0x9fa5, }; -static int -jisx0212_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int jisx0212_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 == 0x22) || (c1 >= 0x26 && c1 <= 0x27) || (c1 >= 0x29 && c1 <= 0x2b) || (c1 >= 0x30 && c1 <= 0x6d)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 < 0x7f) { - unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); - unsigned short wc = 0xfffd; - if (i < 470) { - if (i < 175) - wc = jisx0212_2uni_page22[i-94]; - } else if (i < 752) { - if (i < 658) - wc = jisx0212_2uni_page26[i-470]; - } else if (i < 1410) { - if (i < 1027) - wc = jisx0212_2uni_page29[i-752]; - } else { - if (i < 7211) - wc = jisx0212_2uni_page30[i-1410]; + unsigned char c1 = s[0]; + if ((c1 == 0x22) || (c1 >= 0x26 && c1 <= 0x27) || (c1 >= 0x29 && c1 <= 0x2b) || (c1 >= 0x30 && c1 <= 0x6d)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 < 0x7f) + { + unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); + unsigned short wc = 0xfffd; + if (i < 470) + { + if (i < 175) + wc = jisx0212_2uni_page22[i - 94]; + } + else if (i < 752) + { + if (i < 658) + wc = jisx0212_2uni_page26[i - 470]; + } + else if (i < 1410) + { + if (i < 1027) + wc = jisx0212_2uni_page29[i - 752]; + } + else + { + if (i < 7211) + wc = jisx0212_2uni_page30[i - 1410]; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; - } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned short jisx0212_2charset[6067] = { @@ -2152,37 +2168,42 @@ static const Summary16 jisx0212_uni2indx_pageff[6] = { { 6066, 0x0000 }, { 6066, 0x4000 }, }; -static int -jisx0212_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int jisx0212_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc >= 0x0000 && wc < 0x0460) - summary = &jisx0212_uni2indx_page00[(wc>>4)]; - else if (wc >= 0x2100 && wc < 0x2130) - summary = &jisx0212_uni2indx_page21[(wc>>4)-0x210]; - else if (wc >= 0x4e00 && wc < 0x9fb0) - summary = &jisx0212_uni2indx_page4e[(wc>>4)-0x4e0]; - else if (wc >= 0xff00 && wc < 0xff60) - summary = &jisx0212_uni2indx_pageff[(wc>>4)-0xff0]; - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = jisx0212_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc >= 0x0000 && wc < 0x0460) + summary = &jisx0212_uni2indx_page00[(wc >> 4)]; + else if (wc >= 0x2100 && wc < 0x2130) + summary = &jisx0212_uni2indx_page21[(wc >> 4) - 0x210]; + else if (wc >= 0x4e00 && wc < 0x9fb0) + summary = &jisx0212_uni2indx_page4e[(wc >> 4) - 0x4e0]; + else if (wc >= 0xff00 && wc < 0xff60) + summary = &jisx0212_uni2indx_pageff[(wc >> 4) - 0xff0]; + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = jisx0212_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _JISX0212_H_ */ diff --git a/lib/jisx0213.h b/lib/converters/jisx0213.h similarity index 99% rename from lib/jisx0213.h rename to lib/converters/jisx0213.h index 64302cc6..4776d19d 100644 --- a/lib/jisx0213.h +++ b/lib/converters/jisx0213.h @@ -1,5 +1,10 @@ +/** + * @file jisx0213.h + * @brief JISX0213:2004 + * @copyright Copyright (C) 1999-2004, 2012 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2004, 2012 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,23 +18,21 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * JISX0213:2004 +/* JISX0213 plane 1 (= ISO-IR-233) characters are in the range + * 0x{21..7E}{21..7E}. + * JISX0213 plane 2 (= ISO-IR-229) characters are in the range + * 0x{21,23..25,28,2C..2F,6E..7E}{21..7E}. + * Together this makes 120 rows of 94 characters. */ -#ifndef _JISX0213_H -#define _JISX0213_H +#ifndef _JISX0213_H_ +#define _JISX0213_H_ -/* JISX0213 plane 1 (= ISO-IR-233) characters are in the range - 0x{21..7E}{21..7E}. - JISX0213 plane 2 (= ISO-IR-229) characters are in the range - 0x{21,23..25,28,2C..2F,6E..7E}{21..7E}. - Together this makes 120 rows of 94 characters. -*/ +#include "reiconv_defines.h" static const unsigned short jisx0213_to_ucs_combining[][2] = { { 0x304b, 0x309a }, @@ -5859,35 +5862,36 @@ __inline inline #endif #endif -static ucs4_t jisx0213_to_ucs4 (unsigned int row, unsigned int col) + static ucs4_t + jisx0213_to_ucs4(unsigned int row, unsigned int col) { - ucs4_t val; + ucs4_t val; - if (row >= 0x121 && row <= 0x17e) - row -= 289; - else if (row == 0x221) - row -= 451; - else if (row >= 0x223 && row <= 0x225) - row -= 452; - else if (row == 0x228) - row -= 454; - else if (row >= 0x22c && row <= 0x22f) - row -= 457; - else if (row >= 0x26e && row <= 0x27e) - row -= 519; - else - return 0x0000; + if (row >= 0x121 && row <= 0x17e) + row -= 289; + else if (row == 0x221) + row -= 451; + else if (row >= 0x223 && row <= 0x225) + row -= 452; + else if (row == 0x228) + row -= 454; + else if (row >= 0x22c && row <= 0x22f) + row -= 457; + else if (row >= 0x26e && row <= 0x27e) + row -= 519; + else + return 0x0000; - if (col >= 0x21 && col <= 0x7e) - col -= 0x21; - else - return 0x0000; + if (col >= 0x21 && col <= 0x7e) + col -= 0x21; + else + return 0x0000; - val = jisx0213_to_ucs_main[row * 94 + col]; - val = jisx0213_to_ucs_pagestart[val >> 8] + (val & 0xff); - if (val == 0xfffd) - val = 0x0000; - return val; + val = jisx0213_to_ucs_main[row * 94 + col]; + val = jisx0213_to_ucs_pagestart[val >> 8] + (val & 0xff); + if (val == 0xfffd) + val = 0x0000; + return val; } #ifdef __GNUC__ @@ -5897,27 +5901,31 @@ __inline inline #endif #endif -static unsigned short ucs4_to_jisx0213 (ucs4_t ucs) + static unsigned short + ucs4_to_jisx0213(ucs4_t ucs) { - if (ucs < (sizeof(jisx0213_from_ucs_level1)/sizeof(jisx0213_from_ucs_level1[0])) << 6) { - int index1 = jisx0213_from_ucs_level1[ucs >> 6]; - if (index1 >= 0) { - const Summary16 *summary = &jisx0213_from_ucs_level2_2indx[((index1 << 6) + (ucs & 0x3f)) >> 4]; - unsigned short used = summary->used; - unsigned int i = ucs & 0x0f; - if (used & ((unsigned short) 1 << i)) { - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - return jisx0213_from_ucs_level2_data[summary->indx + used]; - }; - }; - } - return 0x0000; + if (ucs < (sizeof(jisx0213_from_ucs_level1) / sizeof(jisx0213_from_ucs_level1[0])) << 6) + { + int index1 = jisx0213_from_ucs_level1[ucs >> 6]; + if (index1 >= 0) + { + const Summary16 *summary = &jisx0213_from_ucs_level2_2indx[((index1 << 6) + (ucs & 0x3f)) >> 4]; + unsigned short used = summary->used; + unsigned int i = ucs & 0x0f; + if (used & ((unsigned short)1 << i)) + { + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + return jisx0213_from_ucs_level2_data[summary->indx + used]; + }; + }; + } + return 0x0000; } -#endif /* _JISX0213_H */ +#endif /* _JISX0213_H_ */ diff --git a/lib/converters/johab.h b/lib/converters/johab.h new file mode 100644 index 00000000..a9089b08 --- /dev/null +++ b/lib/converters/johab.h @@ -0,0 +1,160 @@ +/** + * @file johab.h + * @brief JOHAB + * @copyright Copyright (C) 1999-2001, 2007, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _JOHAB_H_ +#define _JOHAB_H_ + +#include "converters/johab_hangul.h" +#include "converters/ksc5601.h" +#include "reiconv_defines.h" + +/* + Conversion between JOHAB codes (s1,s2) and KSX1001 codes (c1,c2): + Example. (s1,s2) = 0xD931, (c1,c2) = 0x2121. + (s1,s2) = 0xDEF1, (c1,c2) = 0x2C71. + (s1,s2) = 0xE031, (c1,c2) = 0x4A21. + (s1,s2) = 0xF9FE, (c1,c2) = 0x7D7E. + 0xD9 <= s1 <= 0xDE || 0xE0 <= s1 <= 0xF9, + 0x31 <= s2 <= 0x7E || 0x91 <= s2 <= 0xFE, + 0x21 <= c1 <= 0x2C || 0x4A <= c1 <= 0x7D, + 0x21 <= c2 <= 0x7E. + Invariant: + 94*(s1 < 0xE0 ? 2*s1-0x1B2 : 2*s1-0x197) + (s2 < 0x91 ? s2-0x31 : s2-0x43) + = 94*(c1-0x21)+(c2-0x21) + Conversion (s1,s2) -> (c1,c2): + t1 := (s1 < 0xE0 ? 2*s1-0x1B2 : 2*s1-0x197) + t2 := (s2 < 0x91 ? s2-0x31 : s2-0x43) + c1 := t1 + (t2 < 0x5E ? 0 : 1) + 0x21 + c2 := (t2 < 0x5E ? t2 : t2-0x5E) + 0x21 + Conversion (c1,c2) -> (s1,s2): + t := (c1 < 0x4A ? (c1-0x21+0x1B2) : (c1-0x21+0x197)) + s1 := t >> 1 + t2 := (t & 1) * 0x5E + (c2 - 0x21) + s2 := (t2 < 0x4E ? t2+0x31 : t2+0x43) + */ + +static int johab_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + if (c < 0x80) + { + if (c == 0x5c) + *pwc = (ucs4_t)0x20a9; + else + *pwc = (ucs4_t)c; + return 1; + } + else if (c < 0xd8) + { + return johab_hangul_mbtowc(conv, pwc, s, n); + } + else + { + unsigned char s1, s2; + s1 = c; + if ((s1 >= 0xd9 && s1 <= 0xde) || (s1 >= 0xe0 && s1 <= 0xf9)) + { + if (n < 2) + return RET_TOOFEW(0); + s2 = s[1]; + if ((s2 >= 0x31 && s2 <= 0x7e) || (s2 >= 0x91 && s2 <= 0xfe)) + { + /* In KSC 5601, now KS X 1001, the region s1 = 0xDA, 0xA1 <= s2 <= 0xD3 + contains the 51 Jamo (Hangul letters). But in the Johab encoding, + they have been moved to the Hangul section, see + johab_hangul_page31. */ + if (!(s1 == 0xda && (s2 >= 0xa1 && s2 <= 0xd3))) + { + unsigned char t1 = (s1 < 0xe0 ? 2 * (s1 - 0xd9) : 2 * s1 - 0x197); + unsigned char t2 = (s2 < 0x91 ? s2 - 0x31 : s2 - 0x43); + unsigned char buf[2]; + buf[0] = t1 + (t2 < 0x5e ? 0 : 1) + 0x21; + buf[1] = (t2 < 0x5e ? t2 : t2 - 0x5e) + 0x21; + return ksc5601_mbtowc(conv, pwc, buf, 2); + } + } + } + return RET_ILSEQ; + } +} + +static int johab_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[2]; + int ret; + + /* Try ASCII variation. */ + if (wc < 0x0080 && wc != 0x005c) + { + *r = wc; + return 1; + } + if (wc == 0x20a9) + { + *r = 0x5c; + return 1; + } + + /* Try JOHAB Hangul table before KSC5601 table, because the KSC5601 table + contains some (2350 out of 11172) Hangul syllables (rows 0x30XX..0x48XX), + and we want the search to return the JOHAB Hangul table entry. */ + + /* Try JOHAB Hangul. */ + ret = johab_hangul_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + r[0] = buf[0]; + r[1] = buf[1]; + return 2; + } + + /* Try KSC5601, now KS X 1001. */ + ret = ksc5601_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + unsigned char c1, c2; + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + c1 = buf[0]; + c2 = buf[1]; + if (((c1 >= 0x21 && c1 <= 0x2c) || (c1 >= 0x4a && c1 <= 0x7d)) && (c2 >= 0x21 && c2 <= 0x7e)) + { + unsigned int t = (c1 < 0x4A ? (c1 - 0x21 + 0x1B2) : (c1 - 0x21 + 0x197)); + unsigned char t2 = ((t & 1) ? 0x5e : 0) + (c2 - 0x21); + r[0] = t >> 1; + r[1] = (t2 < 0x4e ? t2 + 0x31 : t2 + 0x43); + return 2; + } + } + + return RET_ILUNI; +} + +#endif /* _JOHAB_H_ */ diff --git a/lib/johab_hangul.h b/lib/converters/johab_hangul.h similarity index 54% rename from lib/johab_hangul.h rename to lib/converters/johab_hangul.h index 2094b4b4..6dd23385 100644 --- a/lib/johab_hangul.h +++ b/lib/converters/johab_hangul.h @@ -1,5 +1,10 @@ +/** + * @file johab_hangul.h + * @brief JOHAB Hangul + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,12 +18,11 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ /* - * JOHAB Hangul * * Ken Lunde writes in his "CJKV Information Processing" book, p. 114: * "Hangul can be composed of two or three jamo (some jamo are considered @@ -47,6 +51,13 @@ * where the index tables are defined as below. */ +#ifndef _JOHAB_HANGUL_H_ +#define _JOHAB_HANGUL_H_ + +#include "reiconv_defines.h" + +#include + /* Tables mapping 5-bit groups to jamo letters. */ /* Note that Jamo XX = UHC 0xA4A0+XX = Unicode 0x3130+XX */ #define NONE 0xfd @@ -100,61 +111,76 @@ static const signed char jamo_final_index[32] = { 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, none, none, }; -static int -johab_hangul_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int johab_hangul_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x84 && c1 <= 0xd3)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x41 && c2 < 0x7f) || (c2 >= 0x81 && c2 < 0xff)) { - unsigned int johab = (c1 << 8) | c2; - unsigned int bitspart1 = (johab >> 10) & 31; - unsigned int bitspart2 = (johab >> 5) & 31; - unsigned int bitspart3 = johab & 31; - int index1 = jamo_initial_index[bitspart1]; - int index2 = jamo_medial_index[bitspart2]; - int index3 = jamo_final_index[bitspart3]; - /* Exclude "none" values. */ - if (index1 >= 0 && index2 >= 0 && index3 >= 0) { - /* Deal with "fill" values in initial or medial position. */ - if (index1 == fill) { - if (index2 == fill) { - unsigned char jamo3 = jamo_final_notinitial[bitspart3]; - if (jamo3 != NONE) { - *pwc = (ucs4_t) 0x3130 + jamo3; - return 2; - } - } else if (index3 == fill) { - unsigned char jamo2 = jamo_medial[bitspart2]; - if (jamo2 != NONE && jamo2 != FILL) { - *pwc = (ucs4_t) 0x3130 + jamo2; - return 2; - } - } - /* Syllables composed only of medial and final don't exist. */ - } else if (index2 == fill) { - if (index3 == fill) { - unsigned char jamo1 = jamo_initial[bitspart1]; - if (jamo1 != NONE && jamo1 != FILL) { - *pwc = (ucs4_t) 0x3130 + jamo1; - return 2; - } + unsigned char c1 = s[0]; + if ((c1 >= 0x84 && c1 <= 0xd3)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if ((c2 >= 0x41 && c2 < 0x7f) || (c2 >= 0x81 && c2 < 0xff)) + { + unsigned int johab = (c1 << 8) | c2; + unsigned int bitspart1 = (johab >> 10) & 31; + unsigned int bitspart2 = (johab >> 5) & 31; + unsigned int bitspart3 = johab & 31; + int index1 = jamo_initial_index[bitspart1]; + int index2 = jamo_medial_index[bitspart2]; + int index3 = jamo_final_index[bitspart3]; + /* Exclude "none" values. */ + if (index1 >= 0 && index2 >= 0 && index3 >= 0) + { + /* Deal with "fill" values in initial or medial position. */ + if (index1 == fill) + { + if (index2 == fill) + { + unsigned char jamo3 = jamo_final_notinitial[bitspart3]; + if (jamo3 != NONE) + { + *pwc = (ucs4_t)0x3130 + jamo3; + return 2; + } + } + else if (index3 == fill) + { + unsigned char jamo2 = jamo_medial[bitspart2]; + if (jamo2 != NONE && jamo2 != FILL) + { + *pwc = (ucs4_t)0x3130 + jamo2; + return 2; + } + } + /* Syllables composed only of medial and final don't exist. */ + } + else if (index2 == fill) + { + if (index3 == fill) + { + unsigned char jamo1 = jamo_initial[bitspart1]; + if (jamo1 != NONE && jamo1 != FILL) + { + *pwc = (ucs4_t)0x3130 + jamo1; + return 2; + } + } + /* Syllables composed only of initial and final don't exist. */ + } + else + { + /* index1 and index2 are not fill, but index3 may be fill. */ + /* Nothing more to exclude. All 11172 code points are valid. */ + *pwc = 0xac00 + ((index1 - 1) * 21 + (index2 - 1)) * 28 + index3; + return 2; + } + } } - /* Syllables composed only of initial and final don't exist. */ - } else { - /* index1 and index2 are not fill, but index3 may be fill. */ - /* Nothing more to exclude. All 11172 code points are valid. */ - *pwc = 0xac00 + ((index1 - 1) * 21 + (index2 - 1)) * 28 + index3; - return 2; - } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } /* 51 Jamo: 19 initial, 21 medial, 11 final not initial. */ @@ -193,33 +219,38 @@ static const char jamo_final_index_inverse[28] = { 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, }; -static int -johab_hangul_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int johab_hangul_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - if (wc >= 0x3131 && wc < 0x3164) { - unsigned short c = johab_hangul_page31[wc-0x3131]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } else if (wc >= 0xac00 && wc < 0xd7a4) { - unsigned int index1; - unsigned int index2; - unsigned int index3; - unsigned short c; - unsigned int tmp = wc - 0xac00; - index3 = tmp % 28; tmp = tmp / 28; - index2 = tmp % 21; tmp = tmp / 21; - index1 = tmp; - c = (((((1 << 5) - | jamo_initial_index_inverse[index1]) << 5) - | jamo_medial_index_inverse[index2]) << 5) - | jamo_final_index_inverse[index3]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; + if (n >= 2) + { + if (wc >= 0x3131 && wc < 0x3164) + { + unsigned short c = johab_hangul_page31[wc - 0x3131]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + else if (wc >= 0xac00 && wc < 0xd7a4) + { + unsigned int index1; + unsigned int index2; + unsigned int index3; + unsigned short c; + unsigned int tmp = wc - 0xac00; + index3 = tmp % 28; + tmp = tmp / 28; + index2 = tmp % 21; + tmp = tmp / 21; + index1 = tmp; + c = (((((1 << 5) | jamo_initial_index_inverse[index1]) << 5) | jamo_medial_index_inverse[index2]) << 5) | + jamo_final_index_inverse[index3]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } /* @@ -229,33 +260,38 @@ johab_hangul_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) /* Decompose wc into r[0..2], and return the number of resulting Jamo elements. Return RET_ILUNI if decomposition is not possible. */ -static int johab_hangul_decompose (conv_t conv, ucs4_t* r, ucs4_t wc) +static int johab_hangul_decompose(conv_t conv, ucs4_t *r, ucs4_t wc) { - unsigned char buf[2]; - int ret = johab_hangul_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - unsigned int hangul = (buf[0] << 8) | buf[1]; - unsigned char jamo1 = jamo_initial[(hangul >> 10) & 31]; - unsigned char jamo2 = jamo_medial[(hangul >> 5) & 31]; - unsigned char jamo3 = jamo_final[hangul & 31]; - if ((hangul >> 15) != 1) abort(); - if (jamo1 != NONE && jamo2 != NONE && jamo3 != NONE) { - /* They are not all three == FILL because that would correspond to - johab = 0x8441, which doesn't exist. */ - ucs4_t* p = r; - if (jamo1 != FILL) - *p++ = 0x3130 + jamo1; - if (jamo2 != FILL) - *p++ = 0x3130 + jamo2; - if (jamo3 != FILL) - *p++ = 0x3130 + jamo3; - return p-r; + unsigned char buf[2]; + int ret = johab_hangul_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + unsigned int hangul = (buf[0] << 8) | buf[1]; + unsigned char jamo1 = jamo_initial[(hangul >> 10) & 31]; + unsigned char jamo2 = jamo_medial[(hangul >> 5) & 31]; + unsigned char jamo3 = jamo_final[hangul & 31]; + if ((hangul >> 15) != 1) + abort(); + if (jamo1 != NONE && jamo2 != NONE && jamo3 != NONE) + { + /* They are not all three == FILL because that would correspond to + johab = 0x8441, which doesn't exist. */ + ucs4_t *p = r; + if (jamo1 != FILL) + *p++ = 0x3130 + jamo1; + if (jamo2 != FILL) + *p++ = 0x3130 + jamo2; + if (jamo3 != FILL) + *p++ = 0x3130 + jamo3; + return p - r; + } } - } - return RET_ILUNI; + return RET_ILUNI; } #undef fill #undef none #undef FILL #undef NONE + +#endif /* _JOHAB_HANGUL_H_ */ diff --git a/lib/koi8_r.h b/lib/converters/koi8_r.h similarity index 82% rename from lib/koi8_r.h rename to lib/converters/koi8_r.h index 855120b0..21088b3f 100644 --- a/lib/koi8_r.h +++ b/lib/converters/koi8_r.h @@ -1,5 +1,10 @@ +/** + * @file koi8_r.h + * @brief KOI8-R + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * KOI8-R - */ +#ifndef _KOI8_R_H_ +#define _KOI8_R_H_ + +#include "reiconv_defines.h" /* Specification: RFC 1489 */ @@ -50,15 +56,14 @@ static const unsigned short koi8_r_2uni[128] = { 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a, }; -static int -koi8_r_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int koi8_r_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) koi8_r_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)koi8_r_2uni[c - 0x80]; + return 1; } static const unsigned char koi8_r_page00[88] = { @@ -126,27 +131,30 @@ static const unsigned char koi8_r_page25[168] = { 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -koi8_r_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int koi8_r_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00f8) - c = koi8_r_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x0458) - c = koi8_r_page04[wc-0x0400]; - else if (wc >= 0x2218 && wc < 0x2268) - c = koi8_r_page22[wc-0x2218]; - else if (wc >= 0x2320 && wc < 0x2328) - c = koi8_r_page23[wc-0x2320]; - else if (wc >= 0x2500 && wc < 0x25a8) - c = koi8_r_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00f8) + c = koi8_r_page00[wc - 0x00a0]; + else if (wc >= 0x0400 && wc < 0x0458) + c = koi8_r_page04[wc - 0x0400]; + else if (wc >= 0x2218 && wc < 0x2268) + c = koi8_r_page22[wc - 0x2218]; + else if (wc >= 0x2320 && wc < 0x2328) + c = koi8_r_page23[wc - 0x2320]; + else if (wc >= 0x2500 && wc < 0x25a8) + c = koi8_r_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _KOI8_R_H_ */ diff --git a/lib/koi8_ru.h b/lib/converters/koi8_ru.h similarity index 83% rename from lib/koi8_ru.h rename to lib/converters/koi8_ru.h index 698d07a8..7c41ff09 100644 --- a/lib/koi8_ru.h +++ b/lib/converters/koi8_ru.h @@ -1,5 +1,10 @@ +/** + * @file koi8_ru.h + * @brief KOI8-RU + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * KOI8-RU - */ +#ifndef _KOI8_RU_H_ +#define _KOI8_RU_H_ + +#include "reiconv_defines.h" static const unsigned short koi8_ru_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short koi8_ru_2uni[128] = { 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a, }; -static int -koi8_ru_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int koi8_ru_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) koi8_ru_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)koi8_ru_2uni[c - 0x80]; + return 1; } static const unsigned char koi8_ru_page00[88] = { @@ -132,27 +137,30 @@ static const unsigned char koi8_ru_page25[168] = { 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -koi8_ru_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int koi8_ru_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00f8) - c = koi8_ru_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x0498) - c = koi8_ru_page04[wc-0x0400]; - else if (wc >= 0x2218 && wc < 0x2268) - c = koi8_ru_page22[wc-0x2218]; - else if (wc >= 0x2320 && wc < 0x2328) - c = koi8_ru_page23[wc-0x2320]; - else if (wc >= 0x2500 && wc < 0x25a8) - c = koi8_ru_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00f8) + c = koi8_ru_page00[wc - 0x00a0]; + else if (wc >= 0x0400 && wc < 0x0498) + c = koi8_ru_page04[wc - 0x0400]; + else if (wc >= 0x2218 && wc < 0x2268) + c = koi8_ru_page22[wc - 0x2218]; + else if (wc >= 0x2320 && wc < 0x2328) + c = koi8_ru_page23[wc - 0x2320]; + else if (wc >= 0x2500 && wc < 0x25a8) + c = koi8_ru_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _KOI8_RU_H_ */ diff --git a/lib/koi8_t.h b/lib/converters/koi8_t.h similarity index 79% rename from lib/koi8_t.h rename to lib/converters/koi8_t.h index eadf266f..f7f232f8 100644 --- a/lib/koi8_t.h +++ b/lib/converters/koi8_t.h @@ -1,5 +1,10 @@ +/** + * @file koi8_t.h + * @brief KOI8-T + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * KOI8-T - */ +#ifndef _KOI8_T_H_ +#define _KOI8_T_H_ + +#include "reiconv_defines.h" static const unsigned short koi8_t_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short koi8_t_2uni[128] = { 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a, }; -static int -koi8_t_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int koi8_t_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = koi8_t_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = koi8_t_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char koi8_t_page00[32] = { @@ -118,25 +126,28 @@ static const unsigned char koi8_t_page21[24] = { 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ }; -static int -koi8_t_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int koi8_t_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00c0) - c = koi8_t_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x04f0) - c = koi8_t_page04[wc-0x0400]; - else if (wc >= 0x2010 && wc < 0x2040) - c = koi8_t_page20[wc-0x2010]; - else if (wc >= 0x2110 && wc < 0x2128) - c = koi8_t_page21[wc-0x2110]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00c0) + c = koi8_t_page00[wc - 0x00a0]; + else if (wc >= 0x0400 && wc < 0x04f0) + c = koi8_t_page04[wc - 0x0400]; + else if (wc >= 0x2010 && wc < 0x2040) + c = koi8_t_page20[wc - 0x2010]; + else if (wc >= 0x2110 && wc < 0x2128) + c = koi8_t_page21[wc - 0x2110]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _KOI8_T_H_ */ diff --git a/lib/koi8_u.h b/lib/converters/koi8_u.h similarity index 84% rename from lib/koi8_u.h rename to lib/converters/koi8_u.h index 5d67b8ae..aff975c7 100644 --- a/lib/koi8_u.h +++ b/lib/converters/koi8_u.h @@ -1,5 +1,10 @@ +/** + * @file koi8_u.h + * @brief KOI8-U + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * KOI8-U - */ +#ifndef _KOI8_U_H_ +#define _KOI8_U_H_ + +#include "reiconv_defines.h" /* Specification: RFC 2319 */ @@ -50,15 +56,14 @@ static const unsigned short koi8_u_2uni[128] = { 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a, }; -static int -koi8_u_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int koi8_u_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) koi8_u_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)koi8_u_2uni[c - 0x80]; + return 1; } static const unsigned char koi8_u_page00[88] = { @@ -134,27 +139,30 @@ static const unsigned char koi8_u_page25[168] = { 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ }; -static int -koi8_u_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int koi8_u_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00f8) - c = koi8_u_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x0498) - c = koi8_u_page04[wc-0x0400]; - else if (wc >= 0x2218 && wc < 0x2268) - c = koi8_u_page22[wc-0x2218]; - else if (wc >= 0x2320 && wc < 0x2328) - c = koi8_u_page23[wc-0x2320]; - else if (wc >= 0x2500 && wc < 0x25a8) - c = koi8_u_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00f8) + c = koi8_u_page00[wc - 0x00a0]; + else if (wc >= 0x0400 && wc < 0x0498) + c = koi8_u_page04[wc - 0x0400]; + else if (wc >= 0x2218 && wc < 0x2268) + c = koi8_u_page22[wc - 0x2218]; + else if (wc >= 0x2320 && wc < 0x2328) + c = koi8_u_page23[wc - 0x2320]; + else if (wc >= 0x2500 && wc < 0x25a8) + c = koi8_u_page25[wc - 0x2500]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _KOI8_U_H_ */ diff --git a/lib/ksc5601.h b/lib/converters/ksc5601.h similarity index 98% rename from lib/ksc5601.h rename to lib/converters/ksc5601.h index de2ab0f9..67e5b84b 100644 --- a/lib/ksc5601.h +++ b/lib/converters/ksc5601.h @@ -1,5 +1,10 @@ +/** + * @file ksc5601.h + * @brief KSC5601.1987-0, now KS X 1001:2002 + * @copyright Copyright (C) 1999-2007, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2007, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * KSC5601.1987-0, now KS X 1001:2002 - */ +#ifndef _KSC5601_H_ +#define _KSC5601_H_ + +#include "reiconv_defines.h" static const unsigned short ksc5601_2uni_page21[1115] = { /* 0x21 */ @@ -1184,36 +1190,44 @@ static const unsigned short ksc5601_2uni_page4a[4888] = { 0x71ba, 0x72a7, 0x79a7, 0x7a00, 0x7fb2, 0x8a70, }; -static int -ksc5601_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int ksc5601_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x21 && c1 <= 0x2c) || (c1 >= 0x30 && c1 <= 0x48) || (c1 >= 0x4a && c1 <= 0x7d)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x21 && c2 < 0x7f) { - unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); - unsigned short wc = 0xfffd; - if (i < 1410) { - if (i < 1115) - wc = ksc5601_2uni_page21[i]; - } else if (i < 3854) { - if (i < 3760) - wc = ksc5601_2uni_page30[i-1410]; - } else { - if (i < 8742) - wc = ksc5601_2uni_page4a[i-3854]; + unsigned char c1 = s[0]; + if ((c1 >= 0x21 && c1 <= 0x2c) || (c1 >= 0x30 && c1 <= 0x48) || (c1 >= 0x4a && c1 <= 0x7d)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if (c2 >= 0x21 && c2 < 0x7f) + { + unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); + unsigned short wc = 0xfffd; + if (i < 1410) + { + if (i < 1115) + wc = ksc5601_2uni_page21[i]; + } + else if (i < 3854) + { + if (i < 3760) + wc = ksc5601_2uni_page30[i - 1410]; + } + else + { + if (i < 8742) + wc = ksc5601_2uni_page4a[i - 3854]; + } + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 2; + } + } + return RET_ILSEQ; } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; - } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned short ksc5601_2charset[8227] = { @@ -2979,43 +2993,48 @@ static const Summary16 ksc5601_uni2indx_pageff[15] = { { 8221, 0x0000 }, { 8221, 0x0000 }, { 8221, 0x006f }, }; -static int -ksc5601_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int ksc5601_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - const Summary16 *summary = NULL; - if (wc >= 0x0000 && wc < 0x0460) - summary = &ksc5601_uni2indx_page00[(wc>>4)]; - else if (wc >= 0x2000 && wc < 0x2670) - summary = &ksc5601_uni2indx_page20[(wc>>4)-0x200]; - else if (wc >= 0x3000 && wc < 0x33e0) - summary = &ksc5601_uni2indx_page30[(wc>>4)-0x300]; - else if (wc >= 0x4e00 && wc < 0x9fa0) - summary = &ksc5601_uni2indx_page4e[(wc>>4)-0x4e0]; - else if (wc >= 0xac00 && wc < 0xd7a0) - summary = &ksc5601_uni2indx_pageac[(wc>>4)-0xac0]; - else if (wc >= 0xf900 && wc < 0xfa10) - summary = &ksc5601_uni2indx_pagef9[(wc>>4)-0xf90]; - else if (wc >= 0xff00 && wc < 0xfff0) - summary = &ksc5601_uni2indx_pageff[(wc>>4)-0xff0]; - if (summary) { - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - c = ksc5601_2charset[summary->indx + used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + const Summary16 *summary = NULL; + if (wc >= 0x0000 && wc < 0x0460) + summary = &ksc5601_uni2indx_page00[(wc >> 4)]; + else if (wc >= 0x2000 && wc < 0x2670) + summary = &ksc5601_uni2indx_page20[(wc >> 4) - 0x200]; + else if (wc >= 0x3000 && wc < 0x33e0) + summary = &ksc5601_uni2indx_page30[(wc >> 4) - 0x300]; + else if (wc >= 0x4e00 && wc < 0x9fa0) + summary = &ksc5601_uni2indx_page4e[(wc >> 4) - 0x4e0]; + else if (wc >= 0xac00 && wc < 0xd7a0) + summary = &ksc5601_uni2indx_pageac[(wc >> 4) - 0xac0]; + else if (wc >= 0xf900 && wc < 0xfa10) + summary = &ksc5601_uni2indx_pagef9[(wc >> 4) - 0xf90]; + else if (wc >= 0xff00 && wc < 0xfff0) + summary = &ksc5601_uni2indx_pageff[(wc >> 4) - 0xff0]; + if (summary) + { + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + c = ksc5601_2charset[summary->indx + used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _KSC5601_H_ */ diff --git a/lib/mac_arabic.h b/lib/converters/mac_arabic.h similarity index 79% rename from lib/mac_arabic.h rename to lib/converters/mac_arabic.h index 5b96f25e..156fbcce 100644 --- a/lib/mac_arabic.h +++ b/lib/converters/mac_arabic.h @@ -1,5 +1,10 @@ +/** + * @file mac_arabic.h + * @brief MacArabic + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * MacArabic - */ +#ifndef _MAC_ARABIC_H_ +#define _MAC_ARABIC_H_ + +#include "reiconv_defines.h" static const unsigned short mac_arabic_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short mac_arabic_2uni[128] = { 0x06af, 0x0688, 0x0691, 0xfffd, 0xfffd, 0xfffd, 0x0698, 0x06d2, }; -static int -mac_arabic_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int mac_arabic_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = mac_arabic_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = mac_arabic_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char mac_arabic_page00[96] = { @@ -109,23 +117,26 @@ static const unsigned char mac_arabic_page06[208] = { 0x00, 0x00, 0xff, 0x00, 0x00, 0xf6, 0x00, 0x00, /* 0xd0-0xd7 */ }; -static int -mac_arabic_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int mac_arabic_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = mac_arabic_page00[wc-0x00a0]; - else if (wc >= 0x0608 && wc < 0x06d8) - c = mac_arabic_page06[wc-0x0608]; - else if (wc == 0x2026) - c = 0x93; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = mac_arabic_page00[wc - 0x00a0]; + else if (wc >= 0x0608 && wc < 0x06d8) + c = mac_arabic_page06[wc - 0x0608]; + else if (wc == 0x2026) + c = 0x93; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _MAC_ARABIC_H_ */ diff --git a/lib/mac_centraleurope.h b/lib/converters/mac_centraleurope.h similarity index 77% rename from lib/mac_centraleurope.h rename to lib/converters/mac_centraleurope.h index 46ee9fbe..86872398 100644 --- a/lib/mac_centraleurope.h +++ b/lib/converters/mac_centraleurope.h @@ -1,5 +1,10 @@ +/** + * @file mac_centraleurope.h + * @brief MacCentralEurope + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * MacCentralEurope - */ +#ifndef _MAC_CENTRALEUROPE_H_ +#define _MAC_CENTRALEUROPE_H_ + +#include "reiconv_defines.h" static const unsigned short mac_centraleurope_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short mac_centraleurope_2uni[128] = { 0x00dd, 0x00fd, 0x0137, 0x017b, 0x0141, 0x017c, 0x0122, 0x02c7, }; -static int -mac_centraleurope_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int mac_centraleurope_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else - *pwc = (ucs4_t) mac_centraleurope_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else + *pwc = (ucs4_t)mac_centraleurope_2uni[c - 0x80]; + return 1; } static const unsigned char mac_centraleurope_page00[224] = { @@ -108,31 +113,34 @@ static const unsigned char mac_centraleurope_page22_1[8] = { 0xad, 0x00, 0x00, 0x00, 0xb2, 0xb3, 0x00, 0x00, /* 0x60-0x67 */ }; -static int -mac_centraleurope_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int mac_centraleurope_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0180) - c = mac_centraleurope_page00[wc-0x00a0]; - else if (wc == 0x02c7) - c = 0xff; - else if (wc >= 0x2010 && wc < 0x2040) - c = mac_centraleurope_page20[wc-0x2010]; - else if (wc == 0x2122) - c = 0xaa; - else if (wc >= 0x2200 && wc < 0x2220) - c = mac_centraleurope_page22[wc-0x2200]; - else if (wc >= 0x2260 && wc < 0x2268) - c = mac_centraleurope_page22_1[wc-0x2260]; - else if (wc == 0x25ca) - c = 0xd7; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0180) + c = mac_centraleurope_page00[wc - 0x00a0]; + else if (wc == 0x02c7) + c = 0xff; + else if (wc >= 0x2010 && wc < 0x2040) + c = mac_centraleurope_page20[wc - 0x2010]; + else if (wc == 0x2122) + c = 0xaa; + else if (wc >= 0x2200 && wc < 0x2220) + c = mac_centraleurope_page22[wc - 0x2200]; + else if (wc >= 0x2260 && wc < 0x2268) + c = mac_centraleurope_page22_1[wc - 0x2260]; + else if (wc == 0x25ca) + c = 0xd7; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _MAC_CENTRALEUROPE_H_ */ diff --git a/lib/mac_croatian.h b/lib/converters/mac_croatian.h similarity index 79% rename from lib/mac_croatian.h rename to lib/converters/mac_croatian.h index 60c0d35b..0b9352a1 100644 --- a/lib/mac_croatian.h +++ b/lib/converters/mac_croatian.h @@ -1,5 +1,10 @@ +/** + * @file mac_croatian.h + * @brief MacCroatian + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * MacCroatian - */ +#ifndef _MAC_CROATIAN_H_ +#define _MAC_CROATIAN_H_ + +#include "reiconv_defines.h" static const unsigned short mac_croatian_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short mac_croatian_2uni[128] = { 0x00af, 0x03c0, 0x00cb, 0x02da, 0x00b8, 0x00ca, 0x00e6, 0x02c7, }; -static int -mac_croatian_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int mac_croatian_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = mac_croatian_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = mac_croatian_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char mac_croatian_page00[248] = { @@ -134,31 +142,34 @@ static const unsigned char mac_croatian_page22[104] = { 0xad, 0x00, 0x00, 0x00, 0xb2, 0xb3, 0x00, 0x00, /* 0x60-0x67 */ }; -static int -mac_croatian_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int mac_croatian_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0198) - c = mac_croatian_page00[wc-0x00a0]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = mac_croatian_page02[wc-0x02c0]; - else if (wc == 0x03c0) - c = 0xf9; - else if (wc >= 0x2010 && wc < 0x2048) - c = mac_croatian_page20[wc-0x2010]; - else if (wc >= 0x2120 && wc < 0x2128) - c = mac_croatian_page21[wc-0x2120]; - else if (wc >= 0x2200 && wc < 0x2268) - c = mac_croatian_page22[wc-0x2200]; - else if (wc == 0x25ca) - c = 0xd7; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0198) + c = mac_croatian_page00[wc - 0x00a0]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = mac_croatian_page02[wc - 0x02c0]; + else if (wc == 0x03c0) + c = 0xf9; + else if (wc >= 0x2010 && wc < 0x2048) + c = mac_croatian_page20[wc - 0x2010]; + else if (wc >= 0x2120 && wc < 0x2128) + c = mac_croatian_page21[wc - 0x2120]; + else if (wc >= 0x2200 && wc < 0x2268) + c = mac_croatian_page22[wc - 0x2200]; + else if (wc == 0x25ca) + c = 0xd7; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _MAC_CROATIAN_H_ */ diff --git a/lib/mac_cyrillic.h b/lib/converters/mac_cyrillic.h similarity index 80% rename from lib/mac_cyrillic.h rename to lib/converters/mac_cyrillic.h index c178ee0f..c89be043 100644 --- a/lib/mac_cyrillic.h +++ b/lib/converters/mac_cyrillic.h @@ -1,5 +1,10 @@ +/** + * @file mac_cyrillic.h + * @brief MacCyrillic + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * MacCyrillic - */ +#ifndef _MAC_CYRILLIC_H_ +#define _MAC_CYRILLIC_H_ + +#include "reiconv_defines.h" static const unsigned short mac_cyrillic_2uni[128] = { /* 0x80 */ @@ -105,31 +111,34 @@ static const unsigned char mac_cyrillic_page22[104] = { 0xad, 0x00, 0x00, 0x00, 0xb2, 0xb3, 0x00, 0x00, /* 0x60-0x67 */ }; -static int -mac_cyrillic_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int mac_cyrillic_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00c0) - c = mac_cyrillic_page00[wc-0x00a0]; - else if (wc == 0x00f7) - c = 0xd6; - else if (wc == 0x0192) - c = 0xc4; - else if (wc >= 0x0400 && wc < 0x0460) - c = mac_cyrillic_page04[wc-0x0400]; - else if (wc >= 0x2010 && wc < 0x2028) - c = mac_cyrillic_page20[wc-0x2010]; - else if (wc >= 0x2110 && wc < 0x2128) - c = mac_cyrillic_page21[wc-0x2110]; - else if (wc >= 0x2200 && wc < 0x2268) - c = mac_cyrillic_page22[wc-0x2200]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00c0) + c = mac_cyrillic_page00[wc - 0x00a0]; + else if (wc == 0x00f7) + c = 0xd6; + else if (wc == 0x0192) + c = 0xc4; + else if (wc >= 0x0400 && wc < 0x0460) + c = mac_cyrillic_page04[wc - 0x0400]; + else if (wc >= 0x2010 && wc < 0x2028) + c = mac_cyrillic_page20[wc - 0x2010]; + else if (wc >= 0x2110 && wc < 0x2128) + c = mac_cyrillic_page21[wc - 0x2110]; + else if (wc >= 0x2200 && wc < 0x2268) + c = mac_cyrillic_page22[wc - 0x2200]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _MAC_CYRILLIC_H_ */ diff --git a/lib/mac_greek.h b/lib/converters/mac_greek.h similarity index 74% rename from lib/mac_greek.h rename to lib/converters/mac_greek.h index a29ed7f3..4fda554b 100644 --- a/lib/mac_greek.h +++ b/lib/converters/mac_greek.h @@ -1,5 +1,10 @@ +/** + * @file mac_greek.h + * @brief MacGreek + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * MacGreek - */ +#ifndef _MAC_GREEK_H_ +#define _MAC_GREEK_H_ + +#include "reiconv_defines.h" static const unsigned short mac_greek_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short mac_greek_2uni[128] = { 0x03c7, 0x03c5, 0x03b6, 0x03ca, 0x03cb, 0x0390, 0x03b0, 0xfffd, }; -static int -mac_greek_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int mac_greek_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = mac_greek_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = mac_greek_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char mac_greek_page00[96] = { @@ -106,29 +114,32 @@ static const unsigned char mac_greek_page22[32] = { 0xad, 0x00, 0x00, 0x00, 0xb2, 0xb3, 0x00, 0x00, /* 0x60-0x67 */ }; -static int -mac_greek_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int mac_greek_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = mac_greek_page00[wc-0x00a0]; - else if (wc == 0x0153) - c = 0xcf; - else if (wc >= 0x0380 && wc < 0x03d0) - c = mac_greek_page03[wc-0x0380]; - else if (wc >= 0x2010 && wc < 0x2038) - c = mac_greek_page20[wc-0x2010]; - else if (wc == 0x2122) - c = 0x93; - else if (wc >= 0x2248 && wc < 0x2268) - c = mac_greek_page22[wc-0x2248]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = mac_greek_page00[wc - 0x00a0]; + else if (wc == 0x0153) + c = 0xcf; + else if (wc >= 0x0380 && wc < 0x03d0) + c = mac_greek_page03[wc - 0x0380]; + else if (wc >= 0x2010 && wc < 0x2038) + c = mac_greek_page20[wc - 0x2010]; + else if (wc == 0x2122) + c = 0x93; + else if (wc >= 0x2248 && wc < 0x2268) + c = mac_greek_page22[wc - 0x2248]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _MAC_GREEK_H_ */ diff --git a/lib/mac_hebrew.h b/lib/converters/mac_hebrew.h similarity index 74% rename from lib/mac_hebrew.h rename to lib/converters/mac_hebrew.h index 22ef485e..4c7bb077 100644 --- a/lib/mac_hebrew.h +++ b/lib/converters/mac_hebrew.h @@ -1,5 +1,10 @@ +/** + * @file mac_hebrew.h + * @brief MacHebrew + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * MacHebrew - */ +#ifndef _MAC_HEBREW_H_ +#define _MAC_HEBREW_H_ + +#include "reiconv_defines.h" static const unsigned short mac_hebrew_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short mac_hebrew_2uni[128] = { 0x05e8, 0x05e9, 0x05ea, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, }; -static int -mac_hebrew_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int mac_hebrew_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else if (c >= 0x80) { - unsigned short wc = mac_hebrew_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else if (c >= 0x80) + { + unsigned short wc = mac_hebrew_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char mac_hebrew_page00[96] = { @@ -105,27 +113,30 @@ static const unsigned char mac_hebrew_pagefb[56] = { 0x00, 0x00, 0x00, 0xc7, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ }; -static int -mac_hebrew_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int mac_hebrew_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = mac_hebrew_page00[wc-0x00a0]; - else if (wc >= 0x05b0 && wc < 0x05f0) - c = mac_hebrew_page05[wc-0x05b0]; - else if (wc >= 0x2010 && wc < 0x2028) - c = mac_hebrew_page20[wc-0x2010]; - else if (wc == 0x20aa) - c = 0xa6; - else if (wc >= 0xfb18 && wc < 0xfb50) - c = mac_hebrew_pagefb[wc-0xfb18]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = mac_hebrew_page00[wc - 0x00a0]; + else if (wc >= 0x05b0 && wc < 0x05f0) + c = mac_hebrew_page05[wc - 0x05b0]; + else if (wc >= 0x2010 && wc < 0x2028) + c = mac_hebrew_page20[wc - 0x2010]; + else if (wc == 0x20aa) + c = 0xa6; + else if (wc >= 0xfb18 && wc < 0xfb50) + c = mac_hebrew_pagefb[wc - 0xfb18]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _MAC_HEBREW_H_ */ diff --git a/lib/mac_iceland.h b/lib/converters/mac_iceland.h similarity index 77% rename from lib/mac_iceland.h rename to lib/converters/mac_iceland.h index f0a92bc9..29fb34fa 100644 --- a/lib/mac_iceland.h +++ b/lib/converters/mac_iceland.h @@ -1,5 +1,10 @@ +/** + * @file mac_iceland.h + * @brief MacIceland + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * MacIceland - */ +#ifndef _MAC_ICELAND_H_ +#define _MAC_ICELAND_H_ + +#include "reiconv_defines.h" static const unsigned short mac_iceland_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short mac_iceland_2uni[128] = { 0x00af, 0x02d8, 0x02d9, 0x02da, 0x00b8, 0x02dd, 0x02db, 0x02c7, }; -static int -mac_iceland_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int mac_iceland_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = mac_iceland_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = mac_iceland_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char mac_iceland_page00[96] = { @@ -129,33 +137,36 @@ static const unsigned char mac_iceland_page22[104] = { 0xad, 0x00, 0x00, 0x00, 0xb2, 0xb3, 0x00, 0x00, /* 0x60-0x67 */ }; -static int -mac_iceland_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int mac_iceland_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = mac_iceland_page00[wc-0x00a0]; - else if (wc >= 0x0130 && wc < 0x0198) - c = mac_iceland_page01[wc-0x0130]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = mac_iceland_page02[wc-0x02c0]; - else if (wc == 0x03c0) - c = 0xb9; - else if (wc >= 0x2010 && wc < 0x2048) - c = mac_iceland_page20[wc-0x2010]; - else if (wc >= 0x2120 && wc < 0x2128) - c = mac_iceland_page21[wc-0x2120]; - else if (wc >= 0x2200 && wc < 0x2268) - c = mac_iceland_page22[wc-0x2200]; - else if (wc == 0x25ca) - c = 0xd7; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = mac_iceland_page00[wc - 0x00a0]; + else if (wc >= 0x0130 && wc < 0x0198) + c = mac_iceland_page01[wc - 0x0130]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = mac_iceland_page02[wc - 0x02c0]; + else if (wc == 0x03c0) + c = 0xb9; + else if (wc >= 0x2010 && wc < 0x2048) + c = mac_iceland_page20[wc - 0x2010]; + else if (wc >= 0x2120 && wc < 0x2128) + c = mac_iceland_page21[wc - 0x2120]; + else if (wc >= 0x2200 && wc < 0x2268) + c = mac_iceland_page22[wc - 0x2200]; + else if (wc == 0x25ca) + c = 0xd7; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _MAC_ICELAND_H_ */ diff --git a/lib/mac_roman.h b/lib/converters/mac_roman.h similarity index 77% rename from lib/mac_roman.h rename to lib/converters/mac_roman.h index 368fa68a..39c21307 100644 --- a/lib/mac_roman.h +++ b/lib/converters/mac_roman.h @@ -1,5 +1,10 @@ +/** + * @file mac_roman.h + * @brief MacRoman + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * MacRoman - */ +#ifndef _MAC_ROMAN_H_ +#define _MAC_ROMAN_H_ + +#include "reiconv_defines.h" static const unsigned short mac_roman_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short mac_roman_2uni[128] = { 0x00af, 0x02d8, 0x02d9, 0x02da, 0x00b8, 0x02dd, 0x02db, 0x02c7, }; -static int -mac_roman_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int mac_roman_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = mac_roman_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = mac_roman_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char mac_roman_page00[96] = { @@ -132,35 +140,38 @@ static const unsigned char mac_roman_pagefb[8] = { 0x00, 0xde, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ }; -static int -mac_roman_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int mac_roman_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = mac_roman_page00[wc-0x00a0]; - else if (wc >= 0x0130 && wc < 0x0198) - c = mac_roman_page01[wc-0x0130]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = mac_roman_page02[wc-0x02c0]; - else if (wc == 0x03c0) - c = 0xb9; - else if (wc >= 0x2010 && wc < 0x2048) - c = mac_roman_page20[wc-0x2010]; - else if (wc >= 0x2120 && wc < 0x2128) - c = mac_roman_page21[wc-0x2120]; - else if (wc >= 0x2200 && wc < 0x2268) - c = mac_roman_page22[wc-0x2200]; - else if (wc == 0x25ca) - c = 0xd7; - else if (wc >= 0xfb00 && wc < 0xfb08) - c = mac_roman_pagefb[wc-0xfb00]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = mac_roman_page00[wc - 0x00a0]; + else if (wc >= 0x0130 && wc < 0x0198) + c = mac_roman_page01[wc - 0x0130]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = mac_roman_page02[wc - 0x02c0]; + else if (wc == 0x03c0) + c = 0xb9; + else if (wc >= 0x2010 && wc < 0x2048) + c = mac_roman_page20[wc - 0x2010]; + else if (wc >= 0x2120 && wc < 0x2128) + c = mac_roman_page21[wc - 0x2120]; + else if (wc >= 0x2200 && wc < 0x2268) + c = mac_roman_page22[wc - 0x2200]; + else if (wc == 0x25ca) + c = 0xd7; + else if (wc >= 0xfb00 && wc < 0xfb08) + c = mac_roman_pagefb[wc - 0xfb00]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _MAC_ROMAN_H_ */ diff --git a/lib/mac_romania.h b/lib/converters/mac_romania.h similarity index 79% rename from lib/mac_romania.h rename to lib/converters/mac_romania.h index cd4c857d..0fe8f073 100644 --- a/lib/mac_romania.h +++ b/lib/converters/mac_romania.h @@ -1,5 +1,10 @@ +/** + * @file mac_romania.h + * @brief MacRomania + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * MacRomania - */ +#ifndef _MAC_ROMANIA_H_ +#define _MAC_ROMANIA_H_ + +#include "reiconv_defines.h" static const unsigned short mac_romania_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short mac_romania_2uni[128] = { 0x00af, 0x02d8, 0x02d9, 0x02da, 0x00b8, 0x02dd, 0x02db, 0x02c7, }; -static int -mac_romania_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int mac_romania_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = mac_romania_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = mac_romania_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char mac_romania_page00[248] = { @@ -134,31 +142,34 @@ static const unsigned char mac_romania_page22[104] = { 0xad, 0x00, 0x00, 0x00, 0xb2, 0xb3, 0x00, 0x00, /* 0x60-0x67 */ }; -static int -mac_romania_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int mac_romania_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0198) - c = mac_romania_page00[wc-0x00a0]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = mac_romania_page02[wc-0x02c0]; - else if (wc == 0x03c0) - c = 0xb9; - else if (wc >= 0x2010 && wc < 0x2048) - c = mac_romania_page20[wc-0x2010]; - else if (wc >= 0x2120 && wc < 0x2128) - c = mac_romania_page21[wc-0x2120]; - else if (wc >= 0x2200 && wc < 0x2268) - c = mac_romania_page22[wc-0x2200]; - else if (wc == 0x25ca) - c = 0xd7; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0198) + c = mac_romania_page00[wc - 0x00a0]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = mac_romania_page02[wc - 0x02c0]; + else if (wc == 0x03c0) + c = 0xb9; + else if (wc >= 0x2010 && wc < 0x2048) + c = mac_romania_page20[wc - 0x2010]; + else if (wc >= 0x2120 && wc < 0x2128) + c = mac_romania_page21[wc - 0x2120]; + else if (wc >= 0x2200 && wc < 0x2268) + c = mac_romania_page22[wc - 0x2200]; + else if (wc == 0x25ca) + c = 0xd7; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _MAC_ROMANIA_H_ */ diff --git a/lib/mac_thai.h b/lib/converters/mac_thai.h similarity index 72% rename from lib/mac_thai.h rename to lib/converters/mac_thai.h index 42f451e1..17e88ab8 100644 --- a/lib/mac_thai.h +++ b/lib/converters/mac_thai.h @@ -1,5 +1,10 @@ +/** + * @file mac_thai.h + * @brief MacThai + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * MacThai - */ +#ifndef _MAC_THAI_H_ +#define _MAC_THAI_H_ + +#include "reiconv_defines.h" static const unsigned short mac_thai_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short mac_thai_2uni[128] = { 0x0e58, 0x0e59, 0x00ae, 0x00a9, 0xfffd, 0xfffd, 0xfffd, 0xfffd, }; -static int -mac_thai_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int mac_thai_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = mac_thai_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = mac_thai_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char mac_thai_page00[32] = { @@ -99,29 +107,32 @@ static const unsigned char mac_thai_pagef8[32] = { 0x87, 0x8f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ }; -static int -mac_thai_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int mac_thai_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00c0) - c = mac_thai_page00[wc-0x00a0]; - else if (wc >= 0x0e00 && wc < 0x0e60) - c = mac_thai_page0e[wc-0x0e00]; - else if (wc >= 0x2008 && wc < 0x2028) - c = mac_thai_page20[wc-0x2008]; - else if (wc == 0x2122) - c = 0xee; - else if (wc >= 0xf880 && wc < 0xf8a0) - c = mac_thai_pagef8[wc-0xf880]; - else if (wc == 0xfeff) - c = 0xdb; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00c0) + c = mac_thai_page00[wc - 0x00a0]; + else if (wc >= 0x0e00 && wc < 0x0e60) + c = mac_thai_page0e[wc - 0x0e00]; + else if (wc >= 0x2008 && wc < 0x2028) + c = mac_thai_page20[wc - 0x2008]; + else if (wc == 0x2122) + c = 0xee; + else if (wc >= 0xf880 && wc < 0xf8a0) + c = mac_thai_pagef8[wc - 0xf880]; + else if (wc == 0xfeff) + c = 0xdb; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _MAC_THAI_H_ */ diff --git a/lib/mac_turkish.h b/lib/converters/mac_turkish.h similarity index 77% rename from lib/mac_turkish.h rename to lib/converters/mac_turkish.h index 196c51b4..34113d35 100644 --- a/lib/mac_turkish.h +++ b/lib/converters/mac_turkish.h @@ -1,5 +1,10 @@ +/** + * @file mac_turkish.h + * @brief MacTurkish + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * MacTurkish - */ +#ifndef _MAC_TURKISH_H_ +#define _MAC_TURKISH_H_ + +#include "reiconv_defines.h" static const unsigned short mac_turkish_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short mac_turkish_2uni[128] = { 0x00af, 0x02d8, 0x02d9, 0x02da, 0x00b8, 0x02dd, 0x02db, 0x02c7, }; -static int -mac_turkish_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int mac_turkish_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = mac_turkish_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = mac_turkish_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char mac_turkish_page00[96] = { @@ -130,33 +138,36 @@ static const unsigned char mac_turkish_page22[104] = { 0xad, 0x00, 0x00, 0x00, 0xb2, 0xb3, 0x00, 0x00, /* 0x60-0x67 */ }; -static int -mac_turkish_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int mac_turkish_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = mac_turkish_page00[wc-0x00a0]; - else if (wc >= 0x0118 && wc < 0x0198) - c = mac_turkish_page01[wc-0x0118]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = mac_turkish_page02[wc-0x02c0]; - else if (wc == 0x03c0) - c = 0xb9; - else if (wc >= 0x2010 && wc < 0x2038) - c = mac_turkish_page20[wc-0x2010]; - else if (wc >= 0x2120 && wc < 0x2128) - c = mac_turkish_page21[wc-0x2120]; - else if (wc >= 0x2200 && wc < 0x2268) - c = mac_turkish_page22[wc-0x2200]; - else if (wc == 0x25ca) - c = 0xd7; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = mac_turkish_page00[wc - 0x00a0]; + else if (wc >= 0x0118 && wc < 0x0198) + c = mac_turkish_page01[wc - 0x0118]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = mac_turkish_page02[wc - 0x02c0]; + else if (wc == 0x03c0) + c = 0xb9; + else if (wc >= 0x2010 && wc < 0x2038) + c = mac_turkish_page20[wc - 0x2010]; + else if (wc >= 0x2120 && wc < 0x2128) + c = mac_turkish_page21[wc - 0x2120]; + else if (wc >= 0x2200 && wc < 0x2268) + c = mac_turkish_page22[wc - 0x2200]; + else if (wc == 0x25ca) + c = 0xd7; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _MAC_TURKISH_H_ */ diff --git a/lib/mac_ukraine.h b/lib/converters/mac_ukraine.h similarity index 78% rename from lib/mac_ukraine.h rename to lib/converters/mac_ukraine.h index d9c4e349..9b2521f3 100644 --- a/lib/mac_ukraine.h +++ b/lib/converters/mac_ukraine.h @@ -1,5 +1,10 @@ +/** + * @file mac_ukraine.h + * @brief MacUkraine + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * MacUkraine - */ +#ifndef _MAC_UKRAINE_H_ +#define _MAC_UKRAINE_H_ + +#include "reiconv_defines.h" static const unsigned short mac_ukraine_2uni[128] = { /* 0x80 */ @@ -48,15 +54,14 @@ static const unsigned short mac_ukraine_2uni[128] = { 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x00a4, }; -static int -mac_ukraine_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int mac_ukraine_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c >= 0x80) - *pwc = (ucs4_t) mac_ukraine_2uni[c-0x80]; - else - *pwc = (ucs4_t) c; - return 1; + unsigned char c = *s; + if (c >= 0x80) + *pwc = (ucs4_t)mac_ukraine_2uni[c - 0x80]; + else + *pwc = (ucs4_t)c; + return 1; } static const unsigned char mac_ukraine_page00[32] = { @@ -112,31 +117,34 @@ static const unsigned char mac_ukraine_page22[104] = { 0xad, 0x00, 0x00, 0x00, 0xb2, 0xb3, 0x00, 0x00, /* 0x60-0x67 */ }; -static int -mac_ukraine_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int mac_ukraine_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00c0) - c = mac_ukraine_page00[wc-0x00a0]; - else if (wc == 0x00f7) - c = 0xd6; - else if (wc == 0x0192) - c = 0xc4; - else if (wc >= 0x0400 && wc < 0x0498) - c = mac_ukraine_page04[wc-0x0400]; - else if (wc >= 0x2010 && wc < 0x2028) - c = mac_ukraine_page20[wc-0x2010]; - else if (wc >= 0x2110 && wc < 0x2128) - c = mac_ukraine_page21[wc-0x2110]; - else if (wc >= 0x2200 && wc < 0x2268) - c = mac_ukraine_page22[wc-0x2200]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00c0) + c = mac_ukraine_page00[wc - 0x00a0]; + else if (wc == 0x00f7) + c = 0xd6; + else if (wc == 0x0192) + c = 0xc4; + else if (wc >= 0x0400 && wc < 0x0498) + c = mac_ukraine_page04[wc - 0x0400]; + else if (wc >= 0x2010 && wc < 0x2028) + c = mac_ukraine_page20[wc - 0x2010]; + else if (wc >= 0x2110 && wc < 0x2128) + c = mac_ukraine_page21[wc - 0x2110]; + else if (wc >= 0x2200 && wc < 0x2268) + c = mac_ukraine_page22[wc - 0x2200]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _MAC_UKRAINE_H_ */ diff --git a/lib/mulelao.h b/lib/converters/mulelao.h similarity index 69% rename from lib/mulelao.h rename to lib/converters/mulelao.h index 4538b6a7..505bca44 100644 --- a/lib/mulelao.h +++ b/lib/converters/mulelao.h @@ -1,5 +1,10 @@ +/** + * @file mulelao.h + * @brief MULELAO-1 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * MULELAO-1 - */ +#ifndef _MULELAO_H_ +#define _MULELAO_H_ + +#include "reiconv_defines.h" static const unsigned short mulelao_2uni[96] = { /* 0xa0 */ @@ -42,22 +48,24 @@ static const unsigned short mulelao_2uni[96] = { 0x0ed8, 0x0ed9, 0xfffd, 0xfffd, 0x0edc, 0x0edd, 0xfffd, 0xfffd, }; -static int -mulelao_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int mulelao_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0xa0) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = mulelao_2uni[c-0xa0]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0xa0) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = mulelao_2uni[c - 0xa0]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char mulelao_page0e[96] = { @@ -75,21 +83,24 @@ static const unsigned char mulelao_page0e[96] = { 0xf8, 0xf9, 0x00, 0x00, 0xfc, 0xfd, 0x00, 0x00, /* 0xd8-0xdf */ }; -static int -mulelao_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int mulelao_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x00a0) { - *r = wc; - return 1; - } - else if (wc == 0x00a0) - c = 0xa0; - else if (wc >= 0x0e80 && wc < 0x0ee0) - c = mulelao_page0e[wc-0x0e80]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x00a0) + { + *r = wc; + return 1; + } + else if (wc == 0x00a0) + c = 0xa0; + else if (wc >= 0x0e80 && wc < 0x0ee0) + c = mulelao_page0e[wc - 0x0e80]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _MULELAO_H_ */ diff --git a/lib/nextstep.h b/lib/converters/nextstep.h similarity index 77% rename from lib/nextstep.h rename to lib/converters/nextstep.h index 8c75b57e..db98f519 100644 --- a/lib/nextstep.h +++ b/lib/converters/nextstep.h @@ -1,5 +1,10 @@ +/** + * @file nextstep.h + * @brief NEXTSTEP + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * NEXTSTEP - */ +#ifndef _NEXTSTEP_H_ +#define _NEXTSTEP_H_ + +#include "reiconv_defines.h" static const unsigned short nextstep_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short nextstep_2uni[128] = { 0x0142, 0x00f8, 0x0153, 0x00df, 0x00fe, 0x00ff, 0xfffd, 0xfffd, }; -static int -nextstep_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int nextstep_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = nextstep_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = nextstep_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char nextstep_page00[96] = { @@ -114,27 +122,30 @@ static const unsigned char nextstep_pagefb[8] = { 0x00, 0xae, 0xaf, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ }; -static int -nextstep_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int nextstep_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = nextstep_page00[wc-0x00a0]; - else if (wc >= 0x0130 && wc < 0x0198) - c = nextstep_page01[wc-0x0130]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = nextstep_page02[wc-0x02c0]; - else if (wc >= 0x2010 && wc < 0x2048) - c = nextstep_page20[wc-0x2010]; - else if (wc >= 0xfb00 && wc < 0xfb08) - c = nextstep_pagefb[wc-0xfb00]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x0100) + c = nextstep_page00[wc - 0x00a0]; + else if (wc >= 0x0130 && wc < 0x0198) + c = nextstep_page01[wc - 0x0130]; + else if (wc >= 0x02c0 && wc < 0x02e0) + c = nextstep_page02[wc - 0x02c0]; + else if (wc >= 0x2010 && wc < 0x2048) + c = nextstep_page20[wc - 0x2010]; + else if (wc >= 0xfb00 && wc < 0xfb08) + c = nextstep_pagefb[wc - 0xfb00]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _NEXTSTEP_H_ */ diff --git a/lib/pt154.h b/lib/converters/pt154.h similarity index 77% rename from lib/pt154.h rename to lib/converters/pt154.h index b68cbb35..1a8789f8 100644 --- a/lib/pt154.h +++ b/lib/converters/pt154.h @@ -1,5 +1,10 @@ +/** + * @file pt154.h + * @brief PT154 + * @copyright Copyright (C) 1999-2005, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2005, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * PT154 - */ +#ifndef _PT154_H_ +#define _PT154_H_ + +#include "reiconv_defines.h" static const unsigned short pt154_2uni[64] = { /* 0x80 */ @@ -36,17 +42,16 @@ static const unsigned short pt154_2uni[64] = { 0x0451, 0x2116, 0x04d9, 0x00bb, 0x0458, 0x04aa, 0x04ab, 0x049d, }; -static int -pt154_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int pt154_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else if (c >= 0xc0) - *pwc = (ucs4_t) c + 0x0350; - else - *pwc = (ucs4_t) pt154_2uni[c-0x80]; - return 1; + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t)c; + else if (c >= 0xc0) + *pwc = (ucs4_t)c + 0x0350; + else + *pwc = (ucs4_t)pt154_2uni[c - 0x80]; + return 1; } static const unsigned char pt154_page00[32] = { @@ -93,25 +98,28 @@ static const unsigned char pt154_page20[24] = { 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */ }; -static int -pt154_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int pt154_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00c0) - c = pt154_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x04f0) - c = pt154_page04[wc-0x0400]; - else if (wc >= 0x2010 && wc < 0x2028) - c = pt154_page20[wc-0x2010]; - else if (wc == 0x2116) - c = 0xb9; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00c0) + c = pt154_page00[wc - 0x00a0]; + else if (wc >= 0x0400 && wc < 0x04f0) + c = pt154_page04[wc - 0x0400]; + else if (wc >= 0x2010 && wc < 0x2028) + c = pt154_page20[wc - 0x2010]; + else if (wc == 0x2116) + c = 0xb9; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _PT154_H_ */ diff --git a/lib/riscos1.h b/lib/converters/riscos1.h similarity index 62% rename from lib/riscos1.h rename to lib/converters/riscos1.h index eccfdda2..527e757b 100644 --- a/lib/riscos1.h +++ b/lib/converters/riscos1.h @@ -1,5 +1,10 @@ +/** + * @file riscos1.h + * @brief RISCOS-LATIN1 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * RISCOS-LATIN1 - */ +#ifndef _RISCOS1_H_ +#define _RISCOS1_H_ + +#include "reiconv_defines.h" static const unsigned short riscos1_2uni[32] = { /* 0x80 */ @@ -30,15 +36,14 @@ static const unsigned short riscos1_2uni[32] = { 0x2014, 0x2212, 0x0152, 0x0153, 0x2020, 0x2021, 0xfb01, 0xfb02, }; -static int -riscos1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int riscos1_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c >= 0x80 && c < 0xa0) - *pwc = (ucs4_t) riscos1_2uni[c-0x80]; - else - *pwc = (ucs4_t) c; - return 1; + unsigned char c = *s; + if (c >= 0x80 && c < 0xa0) + *pwc = (ucs4_t)riscos1_2uni[c - 0x80]; + else + *pwc = (ucs4_t)c; + return 1; } static const unsigned char riscos1_page01[40] = { @@ -65,31 +70,34 @@ static const unsigned char riscos1_page22[16] = { 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ }; -static int -riscos1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int riscos1_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080 || wc == 0x0083 || wc == 0x0087 || (wc >= 0x00a0 && wc < 0x0100)) { - *r = wc; - return 1; - } - else if (wc >= 0x0150 && wc < 0x0178) - c = riscos1_page01[wc-0x0150]; - else if (wc >= 0x2010 && wc < 0x2040) - c = riscos1_page20[wc-0x2010]; - else if (wc == 0x2122) - c = 0x8d; - else if (wc >= 0x21e0 && wc < 0x21f0) - c = riscos1_page21[wc-0x21e0]; - else if (wc >= 0x2210 && wc < 0x2220) - c = riscos1_page22[wc-0x2210]; - else if (wc == 0x2573) - c = 0x84; - else if (wc >= 0xfb01 && wc < 0xfb03) - c = wc-0xfa63; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080 || wc == 0x0083 || wc == 0x0087 || (wc >= 0x00a0 && wc < 0x0100)) + { + *r = wc; + return 1; + } + else if (wc >= 0x0150 && wc < 0x0178) + c = riscos1_page01[wc - 0x0150]; + else if (wc >= 0x2010 && wc < 0x2040) + c = riscos1_page20[wc - 0x2010]; + else if (wc == 0x2122) + c = 0x8d; + else if (wc >= 0x21e0 && wc < 0x21f0) + c = riscos1_page21[wc - 0x21e0]; + else if (wc >= 0x2210 && wc < 0x2220) + c = riscos1_page22[wc - 0x2210]; + else if (wc == 0x2573) + c = 0x84; + else if (wc >= 0xfb01 && wc < 0xfb03) + c = wc - 0xfa63; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _RISCOS1_H_ */ diff --git a/lib/rk1048.h b/lib/converters/rk1048.h similarity index 78% rename from lib/rk1048.h rename to lib/converters/rk1048.h index 58a68ae4..ef71058e 100644 --- a/lib/rk1048.h +++ b/lib/converters/rk1048.h @@ -1,5 +1,10 @@ +/** + * @file rk1048.h + * @brief RK1048 + * @copyright Copyright (C) 1999-2007, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2007, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * RK1048 - */ +#ifndef _RK1048_H_ +#define _RK1048_H_ + +#include "reiconv_defines.h" static const unsigned short rk1048_2uni[128] = { /* 0x80 */ @@ -48,22 +54,24 @@ static const unsigned short rk1048_2uni[128] = { 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, }; -static int -rk1048_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int rk1048_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = rk1048_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; } - } - return RET_ILSEQ; + else + { + unsigned short wc = rk1048_2uni[c - 0x80]; + if (wc != 0xfffd) + { + *pwc = (ucs4_t)wc; + return 1; + } + } + return RET_ILSEQ; } static const unsigned char rk1048_page00[32] = { @@ -118,27 +126,30 @@ static const unsigned char rk1048_page21[24] = { 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ }; -static int -rk1048_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int rk1048_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00c0) - c = rk1048_page00[wc-0x00a0]; - else if (wc >= 0x0400 && wc < 0x04f0) - c = rk1048_page04[wc-0x0400]; - else if (wc >= 0x2010 && wc < 0x2040) - c = rk1048_page20[wc-0x2010]; - else if (wc == 0x20ac) - c = 0x88; - else if (wc >= 0x2110 && wc < 0x2128) - c = rk1048_page21[wc-0x2110]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; + unsigned char c = 0; + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00c0) + c = rk1048_page00[wc - 0x00a0]; + else if (wc >= 0x0400 && wc < 0x04f0) + c = rk1048_page04[wc - 0x0400]; + else if (wc >= 0x2010 && wc < 0x2040) + c = rk1048_page20[wc - 0x2010]; + else if (wc == 0x20ac) + c = 0x88; + else if (wc >= 0x2110 && wc < 0x2128) + c = rk1048_page21[wc - 0x2110]; + if (c != 0) + { + *r = c; + return 1; + } + return RET_ILUNI; } + +#endif /* _RK1048_H_ */ diff --git a/lib/converters/shift_jisx0213.h b/lib/converters/shift_jisx0213.h new file mode 100644 index 00000000..f1bb7c93 --- /dev/null +++ b/lib/converters/shift_jisx0213.h @@ -0,0 +1,360 @@ +/** + * @file shift_jisx0213.h + * @brief SHIFT_JISX0213 + * @copyright Copyright (C) 1999-2002 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* The structure of Shift_JISX0213 is as follows: + * + * 0x00..0x7F: ISO646-JP, an ASCII variant + * + * 0x{A1..DF}: JISX0201 Katakana. + * + * 0x{81..9F,E0..EF}{40..7E,80..FC}: JISX0213 plane 1. + * + * 0x{F0..FC}{40..7E,80..FC}: JISX0213 plane 2, with irregular row mapping. + * + * Note that some JISX0213 characters are not contained in Unicode 3.2 + * and are therefore best represented as sequences of Unicode characters. + */ + +#ifndef _SHIFT_JISX0213_H_ +#define _SHIFT_JISX0213_H_ + +#include "reiconv_defines.h" + +#include "flushwc.h" // IWYU pragma: keep +#include "jisx0213.h" + +#include + +static int shift_jisx0213_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + ucs4_t last_wc = conv->istate; + if (last_wc) + { + /* Output the buffered character. */ + conv->istate = 0; + *pwc = last_wc; + return 0; /* Don't advance the input pointer. */ + } + else + { + unsigned char c = *s; + if (c < 0x80) + { + /* Plain ISO646-JP character. */ + if (c == 0x5c) + *pwc = (ucs4_t)0x00a5; + else if (c == 0x7e) + *pwc = (ucs4_t)0x203e; + else + *pwc = (ucs4_t)c; + return 1; + } + else if (c >= 0xa1 && c <= 0xdf) + { + *pwc = c + 0xfec0; + return 1; + } + else + { + if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc)) + { + /* Two byte character. */ + if (n >= 2) + { + unsigned char c2 = s[1]; + if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfc)) + { + unsigned int c1; + ucs4_t wc; + /* Convert to row and column. */ + if (c < 0xe0) + c -= 0x81; + else + c -= 0xc1; + if (c2 < 0x80) + c2 -= 0x40; + else + c2 -= 0x41; + /* Now 0 <= c <= 0x3b, 0 <= c2 <= 0xbb. */ + c1 = 2 * c; + if (c2 >= 0x5e) + c2 -= 0x5e, c1++; + c2 += 0x21; + if (c1 >= 0x5e) + { + /* Handling of JISX 0213 plane 2 rows. */ + if (c1 >= 0x67) + c1 += 230; + else if (c1 >= 0x63 || c1 == 0x5f) + c1 += 168; + else + c1 += 162; + } + wc = jisx0213_to_ucs4(0x121 + c1, c2); + if (wc) + { + if (wc < 0x80) + { + /* It's a combining character. */ + ucs4_t wc1 = jisx0213_to_ucs_combining[wc - 1][0]; + ucs4_t wc2 = jisx0213_to_ucs_combining[wc - 1][1]; + /* We cannot output two Unicode characters at once. So, + output the first character and buffer the second one. */ + *pwc = wc1; + conv->istate = wc2; + } + else + *pwc = wc; + return 2; + } + } + } + else + return RET_TOOFEW(0); + } + return RET_ILSEQ; + } + } +} + +#define shift_jisx0213_flushwc normal_flushwc + +/* Composition tables for each of the relevant combining characters. */ +static const struct +{ + unsigned short base; + unsigned short composed; +} shift_jisx0213_comp_table_data[] = { +#define shift_jisx0213_comp_table02e5_idx 0 +#define shift_jisx0213_comp_table02e5_len 1 + {0x8684, 0x8685}, /* 0x12B65 = 0x12B64 U+02E5 */ +#define shift_jisx0213_comp_table02e9_idx (shift_jisx0213_comp_table02e5_idx + shift_jisx0213_comp_table02e5_len) +#define shift_jisx0213_comp_table02e9_len 1 + {0x8680, 0x8686}, /* 0x12B66 = 0x12B60 U+02E9 */ +#define shift_jisx0213_comp_table0300_idx (shift_jisx0213_comp_table02e9_idx + shift_jisx0213_comp_table02e9_len) +#define shift_jisx0213_comp_table0300_len 5 + {0x857b, 0x8663}, /* 0x12B44 = 0x1295C U+0300 */ + {0x8657, 0x8667}, /* 0x12B48 = 0x12B38 U+0300 */ + {0x8656, 0x8669}, /* 0x12B4A = 0x12B37 U+0300 */ + {0x864f, 0x866b}, /* 0x12B4C = 0x12B30 U+0300 */ + {0x8662, 0x866d}, /* 0x12B4E = 0x12B43 U+0300 */ +#define shift_jisx0213_comp_table0301_idx (shift_jisx0213_comp_table0300_idx + shift_jisx0213_comp_table0300_len) +#define shift_jisx0213_comp_table0301_len 4 + {0x8657, 0x8668}, /* 0x12B49 = 0x12B38 U+0301 */ + {0x8656, 0x866a}, /* 0x12B4B = 0x12B37 U+0301 */ + {0x864f, 0x866c}, /* 0x12B4D = 0x12B30 U+0301 */ + {0x8662, 0x866e}, /* 0x12B4F = 0x12B43 U+0301 */ +#define shift_jisx0213_comp_table309a_idx (shift_jisx0213_comp_table0301_idx + shift_jisx0213_comp_table0301_len) +#define shift_jisx0213_comp_table309a_len 14 + {0x82a9, 0x82f5}, /* 0x12477 = 0x1242B U+309A */ + {0x82ab, 0x82f6}, /* 0x12478 = 0x1242D U+309A */ + {0x82ad, 0x82f7}, /* 0x12479 = 0x1242F U+309A */ + {0x82af, 0x82f8}, /* 0x1247A = 0x12431 U+309A */ + {0x82b1, 0x82f9}, /* 0x1247B = 0x12433 U+309A */ + {0x834a, 0x8397}, /* 0x12577 = 0x1252B U+309A */ + {0x834c, 0x8398}, /* 0x12578 = 0x1252D U+309A */ + {0x834e, 0x8399}, /* 0x12579 = 0x1252F U+309A */ + {0x8350, 0x839a}, /* 0x1257A = 0x12531 U+309A */ + {0x8352, 0x839b}, /* 0x1257B = 0x12533 U+309A */ + {0x835a, 0x839c}, /* 0x1257C = 0x1253B U+309A */ + {0x8363, 0x839d}, /* 0x1257D = 0x12544 U+309A */ + {0x8367, 0x839e}, /* 0x1257E = 0x12548 U+309A */ + {0x83f3, 0x83f6}, /* 0x12678 = 0x12675 U+309A */ +}; + +static int shift_jisx0213_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + int count = 0; + unsigned short lasttwo = conv->ostate; + + if (lasttwo) + { + /* Attempt to combine the last character with this one. */ + unsigned int idx; + unsigned int len; + + if (wc == 0x02e5) + idx = shift_jisx0213_comp_table02e5_idx, len = shift_jisx0213_comp_table02e5_len; + else if (wc == 0x02e9) + idx = shift_jisx0213_comp_table02e9_idx, len = shift_jisx0213_comp_table02e9_len; + else if (wc == 0x0300) + idx = shift_jisx0213_comp_table0300_idx, len = shift_jisx0213_comp_table0300_len; + else if (wc == 0x0301) + idx = shift_jisx0213_comp_table0301_idx, len = shift_jisx0213_comp_table0301_len; + else if (wc == 0x309a) + idx = shift_jisx0213_comp_table309a_idx, len = shift_jisx0213_comp_table309a_len; + else + goto not_combining; + + do + if (shift_jisx0213_comp_table_data[idx].base == lasttwo) + break; + while (++idx, --len > 0); + + if (len > 0) + { + /* Output the combined character. */ + if (n >= 2) + { + lasttwo = shift_jisx0213_comp_table_data[idx].composed; + r[0] = (lasttwo >> 8) & 0xff; + r[1] = lasttwo & 0xff; + conv->ostate = 0; + return 2; + } + else + return RET_TOOSMALL; + } + + not_combining: + /* Output the buffered character. */ + if (n < 2) + return RET_TOOSMALL; + r[0] = (lasttwo >> 8) & 0xff; + r[1] = lasttwo & 0xff; + r += 2; + count = 2; + } + + if (wc < 0x80 && wc != 0x5c && wc != 0x7e) + { + /* Plain ISO646-JP character. */ + if (n > count) + { + r[0] = (unsigned char)wc; + conv->ostate = 0; + return count + 1; + } + else + return RET_TOOSMALL; + } + else if (wc == 0x00a5) + { + if (n > count) + { + r[0] = 0x5c; + conv->ostate = 0; + return count + 1; + } + else + return RET_TOOSMALL; + } + else if (wc == 0x203e) + { + if (n > count) + { + r[0] = 0x7e; + conv->ostate = 0; + return count + 1; + } + else + return RET_TOOSMALL; + } + else if (wc >= 0xff61 && wc <= 0xff9f) + { + /* Half-width katakana. */ + if (n > count) + { + r[0] = wc - 0xfec0; + conv->ostate = 0; + return count + 1; + } + else + return RET_TOOSMALL; + } + else + { + unsigned int s1, s2; + unsigned short jch = ucs4_to_jisx0213(wc); + if (jch != 0) + { + /* Convert it to shifted representation. */ + s1 = jch >> 8; + s2 = jch & 0x7f; + s1 -= 0x21; + s2 -= 0x21; + if (s1 >= 0x5e) + { + /* Handling of JISX 0213 plane 2 rows. */ + if (s1 >= 0xcd) /* rows 0x26E..0x27E */ + s1 -= 102; + else if (s1 >= 0x8b || s1 == 0x87) /* rows 0x228, 0x22C..0x22F */ + s1 -= 40; + else /* rows 0x221, 0x223..0x225 */ + s1 -= 34; + /* Now 0x5e <= s1 <= 0x77. */ + } + if (s1 & 1) + s2 += 0x5e; + s1 = s1 >> 1; + if (s1 < 0x1f) + s1 += 0x81; + else + s1 += 0xc1; + if (s2 < 0x3f) + s2 += 0x40; + else + s2 += 0x41; + if (jch & 0x0080) + { + /* A possible match in comp_table_data. We have to buffer it. */ + /* We know it's a JISX 0213 plane 1 character. */ + if (jch & 0x8000) + abort(); + conv->ostate = (s1 << 8) | s2; + return count + 0; + } + /* Output the shifted representation. */ + if (n >= count + 2) + { + r[0] = s1; + r[1] = s2; + conv->ostate = 0; + return count + 2; + } + else + return RET_TOOSMALL; + } + return RET_ILUNI; + } +} + +static int shift_jisx0213_reset(conv_t conv, unsigned char *r, size_t n) +{ + state_t lasttwo = conv->ostate; + + if (lasttwo) + { + if (n < 2) + return RET_TOOSMALL; + r[0] = (lasttwo >> 8) & 0xff; + r[1] = lasttwo & 0xff; + /* conv->ostate = 0; will be done by the caller */ + return 2; + } + else + return 0; +} + +#endif /* _SHIFT_JISX0213_H_ */ diff --git a/lib/converters/sjis.h b/lib/converters/sjis.h new file mode 100644 index 00000000..00eac87f --- /dev/null +++ b/lib/converters/sjis.h @@ -0,0 +1,154 @@ +/** + * @file sjis.h + * @brief SHIFT_JIS + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _SJIS_H_ +#define _SJIS_H_ + +#include "converters/jisx0201.h" +#include "converters/jisx0208.h" +#include "reiconv_defines.h" + +#include + +/* + Conversion between SJIS codes (s1,s2) and JISX0208 codes (c1,c2): + Example. (s1,s2) = 0x8140, (c1,c2) = 0x2121. + 0x81 <= s1 <= 0x9F || 0xE0 <= s1 <= 0xEA, + 0x40 <= s2 <= 0x7E || 0x80 <= s2 <= 0xFC, + 0x21 <= c1 <= 0x74, 0x21 <= c2 <= 0x7E. + Invariant: + 94*2*(s1 < 0xE0 ? s1-0x81 : s1-0xC1) + (s2 < 0x80 ? s2-0x40 : s2-0x41) + = 94*(c1-0x21)+(c2-0x21) + Conversion (s1,s2) -> (c1,c2): + t1 := (s1 < 0xE0 ? s1-0x81 : s1-0xC1) + t2 := (s2 < 0x80 ? s2-0x40 : s2-0x41) + c1 := 2*t1 + (t2 < 0x5E ? 0 : 1) + 0x21 + c2 := (t2 < 0x5E ? t2 : t2-0x5E) + 0x21 + Conversion (c1,c2) -> (s1,s2): + t1 := (c1 - 0x21) >> 1 + t2 := ((c1 - 0x21) & 1) * 0x5E + (c2 - 0x21) + s1 := (t1 < 0x1F ? t1+0x81 : t1+0xC1) + s2 := (t2 < 0x3F ? t2+0x40 : t2+0x41) + */ + +static int sjis_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + if (c < 0x80 || (c >= 0xa1 && c <= 0xdf)) + return jisx0201_mbtowc(conv, pwc, s, n); + else + { + unsigned char s1, s2; + s1 = c; + if ((s1 >= 0x81 && s1 <= 0x9f) || (s1 >= 0xe0 && s1 <= 0xea)) + { + if (n < 2) + return RET_TOOFEW(0); + s2 = s[1]; + if ((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0x80 && s2 <= 0xfc)) + { + unsigned char t1 = (s1 < 0xe0 ? s1 - 0x81 : s1 - 0xc1); + unsigned char t2 = (s2 < 0x80 ? s2 - 0x40 : s2 - 0x41); + unsigned char buf[2]; + buf[0] = 2 * t1 + (t2 < 0x5e ? 0 : 1) + 0x21; + buf[1] = (t2 < 0x5e ? t2 : t2 - 0x5e) + 0x21; + return jisx0208_mbtowc(conv, pwc, buf, 2); + } + } + else if (s1 >= 0xf0 && s1 <= 0xf9) + { + /* User-defined range. See + * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ + if (n < 2) + return RET_TOOFEW(0); + s2 = s[1]; + if ((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0x80 && s2 <= 0xfc)) + { + *pwc = 0xe000 + 188 * (s1 - 0xf0) + (s2 < 0x80 ? s2 - 0x40 : s2 - 0x41); + return 2; + } + } + return RET_ILSEQ; + } +} + +static int sjis_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + unsigned char buf[2]; + int ret; + + /* Try JIS X 0201-1976. */ + ret = jisx0201_wctomb(conv, buf, wc, 1); + if (ret != RET_ILUNI) + { + unsigned char c; + if (ret != 1) + abort(); + c = buf[0]; + if (c < 0x80 || (c >= 0xa1 && c <= 0xdf)) + { + r[0] = c; + return 1; + } + } + + /* Try JIS X 0208-1990. */ + ret = jisx0208_wctomb(conv, buf, wc, 2); + if (ret != RET_ILUNI) + { + unsigned char c1, c2; + if (ret != 2) + abort(); + if (n < 2) + return RET_TOOSMALL; + c1 = buf[0]; + c2 = buf[1]; + if ((c1 >= 0x21 && c1 <= 0x74) && (c2 >= 0x21 && c2 <= 0x7e)) + { + unsigned char t1 = (c1 - 0x21) >> 1; + unsigned char t2 = (((c1 - 0x21) & 1) ? 0x5e : 0) + (c2 - 0x21); + r[0] = (t1 < 0x1f ? t1 + 0x81 : t1 + 0xc1); + r[1] = (t2 < 0x3f ? t2 + 0x40 : t2 + 0x41); + return 2; + } + } + + /* User-defined range. See + * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ + if (wc >= 0xe000 && wc < 0xe758) + { + unsigned char c1, c2; + if (n < 2) + return RET_TOOSMALL; + c1 = (unsigned int)(wc - 0xe000) / 188; + c2 = (unsigned int)(wc - 0xe000) % 188; + r[0] = c1 + 0xf0; + r[1] = (c2 < 0x3f ? c2 + 0x40 : c2 + 0x41); + return 2; + } + + return RET_ILUNI; +} + +#endif /* _SJIS_H_ */ diff --git a/lib/tcvn.h b/lib/converters/tcvn.h similarity index 96% rename from lib/tcvn.h rename to lib/converters/tcvn.h index 80e35086..4ced8411 100644 --- a/lib/tcvn.h +++ b/lib/converters/tcvn.h @@ -1,5 +1,10 @@ +/** + * @file tcvn.h + * @brief TCVN-5712 + * @copyright Copyright (C) 1999-2002, 2004, 2016, 2019 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2004, 2016, 2019 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,17 +18,20 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * TCVN-5712 - */ +#ifndef _TCVN_H_ +#define _TCVN_H_ -#include "flushwc.h" +#include "reiconv_defines.h" + +//#include "flushwc.h" #include "vietcomb.h" +#include + static const unsigned char tcvn_comb_table[] = { 0xb0, 0xb3, 0xb2, 0xb1, 0xb4, }; @@ -288,3 +296,5 @@ tcvn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) } return RET_ILUNI; } + +#endif /* _TCVN_H_ */ diff --git a/lib/tds565.h b/lib/converters/tds565.h similarity index 92% rename from lib/tds565.h rename to lib/converters/tds565.h index 8382389a..11a7bd90 100644 --- a/lib/tds565.h +++ b/lib/converters/tds565.h @@ -1,5 +1,10 @@ +/** + * @file tds565.h + * @brief TDS565 + * @copyright Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * TDS565 - */ +#ifndef _TDS565_H_ +#define _TDS565_H_ + +#include "reiconv_defines.h" static const unsigned short tds565_2uni[64] = { /* 0x40 */ @@ -104,3 +110,5 @@ tds565_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) } return RET_ILUNI; } + +#endif /* _TDS565_H_ */ diff --git a/lib/converters/tis620.h b/lib/converters/tis620.h new file mode 100644 index 00000000..8bb93ffe --- /dev/null +++ b/lib/converters/tis620.h @@ -0,0 +1,61 @@ +/** + * @file tis620.h + * @brief TIS620.2533-1 + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _TIS620_H_ +#define _TIS620_H_ + +#include "reiconv_defines.h" + +static int tis620_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + unsigned char c = *s; + if (c < 0x80) + { + *pwc = (ucs4_t)c; + return 1; + } + else if (c >= 0xa1 && c <= 0xfb && !(c >= 0xdb && c <= 0xde)) + { + *pwc = (ucs4_t)(c + 0x0d60); + return 1; + } + return RET_ILSEQ; +} + +static int tis620_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0x0080) + { + *r = wc; + return 1; + } + else if (wc >= 0x0e01 && wc <= 0x0e5b && !(wc >= 0x0e3b && wc <= 0x0e3e)) + { + *r = wc - 0x0d60; + return 1; + } + return RET_ILUNI; +} + +#endif /* _TIS620_H_ */ diff --git a/lib/converters/ucs2.h b/lib/converters/ucs2.h new file mode 100644 index 00000000..b70c9b9d --- /dev/null +++ b/lib/converters/ucs2.h @@ -0,0 +1,89 @@ +/** + * @file ucs2.h + * @brief UCS-2 + * @copyright Copyright (C) 1999-2024 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UCS2_H_ +#define _UCS2_H_ + +#include "reiconv_defines.h" + +#include + +/* Here we accept FFFE/FEFF marks as endianness indicators everywhere + in the stream, not just at the beginning. The default is big-endian. */ +/* The state is 0 if big-endian, 1 if little-endian. */ +static int ucs2_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + state_t state = conv->ibyteorder; + int count = 0; + for (; n >= 2 && count <= RET_COUNT_MAX && count <= INT_MAX - 2;) + { + ucs4_t wc = (state ? s[0] + (s[1] << 8) : (s[0] << 8) + s[1]); + if (wc == 0xfeff) + { + } + else if (wc == 0xfffe) + { + state ^= 1; + } + else if (wc >= 0xd800 && wc < 0xe000) + { + conv->ibyteorder = state; + return RET_SHIFT_ILSEQ(count); + } + else + { + *pwc = wc; + conv->ibyteorder = state; + return count + 2; + } + s += 2; + n -= 2; + count += 2; + } + conv->ibyteorder = state; + return RET_TOOFEW(count); +} + +/* But we output UCS-2 in big-endian order, without byte-order mark. */ +/* RFC 2152 says: + "ISO/IEC 10646-1:1993(E) specifies that when characters the UCS-2 form are + serialized as octets, that the most significant octet appear first." */ +static int ucs2_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0x10000 && wc != 0xfffe && !(wc >= 0xd800 && wc < 0xe000)) + { + if (n >= 2) + { + r[0] = (unsigned char)(wc >> 8); + r[1] = (unsigned char)wc; + return 2; + } + else + return RET_TOOSMALL; + } + else + return RET_ILUNI; +} + +#endif /* _UCS2_H_ */ diff --git a/lib/converters/ucs2be.h b/lib/converters/ucs2be.h new file mode 100644 index 00000000..91e0e49f --- /dev/null +++ b/lib/converters/ucs2be.h @@ -0,0 +1,63 @@ +/** + * @file ucs2be.h + * @brief UCS-2BE = UCS-2 big endian + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UCS2BE_H_ +#define _UCS2BE_H_ + +#include "reiconv_defines.h" + +static int ucs2be_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + if (n >= 2) + { + if (s[0] >= 0xd8 && s[0] < 0xe0) + { + return RET_ILSEQ; + } + else + { + *pwc = (s[0] << 8) + s[1]; + return 2; + } + } + return RET_TOOFEW(0); +} + +static int ucs2be_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0x10000 && !(wc >= 0xd800 && wc < 0xe000)) + { + if (n >= 2) + { + r[0] = (unsigned char)(wc >> 8); + r[1] = (unsigned char)wc; + return 2; + } + else + return RET_TOOSMALL; + } + return RET_ILUNI; +} + +#endif /* _UCS2BE_H_ */ diff --git a/lib/converters/ucs2internal.h b/lib/converters/ucs2internal.h new file mode 100644 index 00000000..1a44ee0d --- /dev/null +++ b/lib/converters/ucs2internal.h @@ -0,0 +1,64 @@ +/** + * @file ucs2internal.h + * @brief UCS-2-INTERNAL = UCS-2 with machine dependent endianness and alignment + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UCS2INTERNAL_H_ +#define _UCS2INTERNAL_H_ + +#include "reiconv_defines.h" + +static int ucs2internal_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + if (n >= 2) + { + unsigned short x = *(const unsigned short *)s; + if (x >= 0xd800 && x < 0xe000) + { + return RET_ILSEQ; + } + else + { + *pwc = x; + return 2; + } + } + return RET_TOOFEW(0); +} + +static int ucs2internal_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0x10000 && !(wc >= 0xd800 && wc < 0xe000)) + { + if (n >= 2) + { + *(unsigned short *)r = wc; + return 2; + } + else + return RET_TOOSMALL; + } + else + return RET_ILUNI; +} + +#endif /* _UCS2INTERNAL_H_ */ diff --git a/lib/converters/ucs2le.h b/lib/converters/ucs2le.h new file mode 100644 index 00000000..ec18cbd6 --- /dev/null +++ b/lib/converters/ucs2le.h @@ -0,0 +1,63 @@ +/** + * @file ucs2le.h + * @brief UCS-2LE = UCS-2 little endian + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UCS2LE_H_ +#define _UCS2LE_H_ + +#include "reiconv_defines.h" + +static int ucs2le_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + if (n >= 2) + { + if (s[1] >= 0xd8 && s[1] < 0xe0) + { + return RET_ILSEQ; + } + else + { + *pwc = s[0] + (s[1] << 8); + return 2; + } + } + return RET_TOOFEW(0); +} + +static int ucs2le_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0x10000 && !(wc >= 0xd800 && wc < 0xe000)) + { + if (n >= 2) + { + r[0] = (unsigned char)wc; + r[1] = (unsigned char)(wc >> 8); + return 2; + } + else + return RET_TOOSMALL; + } + return RET_ILUNI; +} + +#endif /* _UCS2LE_H_ */ diff --git a/lib/converters/ucs2swapped.h b/lib/converters/ucs2swapped.h new file mode 100644 index 00000000..ec47f32f --- /dev/null +++ b/lib/converters/ucs2swapped.h @@ -0,0 +1,77 @@ +/** + * @file ucs2swapped.h + * @brief UCS-2-SWAPPED = UCS-2-INTERNAL with inverted endianness + * @copyright Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UCS2SWAPPED_H_ +#define _UCS2SWAPPED_H_ + +#include "reiconv_defines.h" + +#include + +static int ucs2swapped_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + /* This function assumes that 'unsigned short' has exactly 16 bits. */ + if (sizeof(unsigned short) != 2) + abort(); + + if (n >= 2) + { + unsigned short x = *(const unsigned short *)s; + x = (x >> 8) | (x << 8); + if (x >= 0xd800 && x < 0xe000) + { + return RET_ILSEQ; + } + else + { + *pwc = x; + return 2; + } + } + return RET_TOOFEW(0); +} + +static int ucs2swapped_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + /* This function assumes that 'unsigned short' has exactly 16 bits. */ + if (sizeof(unsigned short) != 2) + abort(); + + if (wc < 0x10000 && !(wc >= 0xd800 && wc < 0xe000)) + { + if (n >= 2) + { + unsigned short x = wc; + x = (x >> 8) | (x << 8); + *(unsigned short *)r = x; + return 2; + } + else + return RET_TOOSMALL; + } + else + return RET_ILUNI; +} + +#endif /* _UCS2SWAPPED_H_ */ diff --git a/lib/converters/ucs4.h b/lib/converters/ucs4.h new file mode 100644 index 00000000..d50f903a --- /dev/null +++ b/lib/converters/ucs4.h @@ -0,0 +1,89 @@ +/** + * @file ucs4.h + * @brief UCS-4 + * @copyright Copyright (C) 1999-2024 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UCS4_H_ +#define _UCS4_H_ + +#include "reiconv_defines.h" + +#include + +/* Here we accept FFFE0000/0000FEFF marks as endianness indicators everywhere + in the stream, not just at the beginning. The default is big-endian. */ +/* The state is 0 if big-endian, 1 if little-endian. */ +static int ucs4_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + state_t state = conv->ibyteorder; + int count = 0; + for (; n >= 4 && count <= RET_COUNT_MAX && count <= INT_MAX - 4;) + { + ucs4_t wc = (state ? (ucs4_t)s[0] + ((ucs4_t)s[1] << 8) + ((ucs4_t)s[2] << 16) + ((ucs4_t)s[3] << 24) + : ((ucs4_t)s[0] << 24) + ((ucs4_t)s[1] << 16) + ((ucs4_t)s[2] << 8) + (ucs4_t)s[3]); + if (wc == 0x0000feff) + { + } + else if (wc == 0xfffe0000u) + { + state ^= 1; + } + else if (wc <= 0x7fffffff) + { + *pwc = wc; + conv->ibyteorder = state; + return count + 4; + } + else + { + conv->ibyteorder = state; + return RET_SHIFT_ILSEQ(count); + } + s += 4; + n -= 4; + count += 4; + } + conv->ibyteorder = state; + return RET_TOOFEW(count); +} + +/* But we output UCS-4 in big-endian order, without byte-order mark. */ +static int ucs4_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc <= 0x7fffffff) + { + if (n >= 4) + { + r[0] = (unsigned char)(wc >> 24); + r[1] = (unsigned char)(wc >> 16); + r[2] = (unsigned char)(wc >> 8); + r[3] = (unsigned char)wc; + return 4; + } + else + return RET_TOOSMALL; + } + else + return RET_ILUNI; +} + +#endif /* _UCS4_H_ */ diff --git a/lib/converters/ucs4be.h b/lib/converters/ucs4be.h new file mode 100644 index 00000000..821e2838 --- /dev/null +++ b/lib/converters/ucs4be.h @@ -0,0 +1,54 @@ +/** + * @file ucs4be.h + * @brief UCS-4BE = UCS-4 big endian + * @copyright Copyright (C) 1999-2000, 2016, 2024 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UCS4BE_H_ +#define _UCS4BE_H_ + +#include "reiconv_defines.h" + +static int ucs4be_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + if (n >= 4) + { + *pwc = ((ucs4_t)s[0] << 24) + ((ucs4_t)s[1] << 16) + ((ucs4_t)s[2] << 8) + (ucs4_t)s[3]; + return 4; + } + return RET_TOOFEW(0); +} + +static int ucs4be_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (n >= 4) + { + r[0] = (unsigned char)(wc >> 24); + r[1] = (unsigned char)(wc >> 16); + r[2] = (unsigned char)(wc >> 8); + r[3] = (unsigned char)wc; + return 4; + } + else + return RET_TOOSMALL; +} + +#endif /* _UCS4BE_H_ */ diff --git a/lib/converters/ucs4internal.h b/lib/converters/ucs4internal.h new file mode 100644 index 00000000..17992129 --- /dev/null +++ b/lib/converters/ucs4internal.h @@ -0,0 +1,51 @@ +/** + * @file ucs4internal.h + * @brief UCS-4-INTERNAL = UCS-4 with machine dependent endianness and alignment + * @copyright Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UCS4INTERNAL_H_ +#define _UCS4INTERNAL_H_ + +#include "reiconv_defines.h" + +static int ucs4internal_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + if (n >= 4) + { + *pwc = *(const unsigned int *)s; + return 4; + } + return RET_TOOFEW(0); +} + +static int ucs4internal_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (n >= 4) + { + *(unsigned int *)r = wc; + return 4; + } + else + return RET_TOOSMALL; +} + +#endif /* _UCS4INTERNAL_H_ */ diff --git a/lib/converters/ucs4le.h b/lib/converters/ucs4le.h new file mode 100644 index 00000000..fa972228 --- /dev/null +++ b/lib/converters/ucs4le.h @@ -0,0 +1,54 @@ +/** + * @file ucs4le.h + * @brief UCS-4LE = UCS-4 little endian + * @copyright Copyright (C) 1999-2000, 2016, 2024 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UCS4LE_H_ +#define _UCS4LE_H_ + +#include "reiconv_defines.h" + +static int ucs4le_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + if (n >= 4) + { + *pwc = (ucs4_t)s[0] + ((ucs4_t)s[1] << 8) + ((ucs4_t)s[2] << 16) + ((ucs4_t)s[3] << 24); + return 4; + } + return RET_TOOFEW(0); +} + +static int ucs4le_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (n >= 4) + { + r[0] = (unsigned char)wc; + r[1] = (unsigned char)(wc >> 8); + r[2] = (unsigned char)(wc >> 16); + r[3] = (unsigned char)(wc >> 24); + return 4; + } + else + return RET_TOOSMALL; +} + +#endif /* _UCS4LE_H_ */ diff --git a/lib/converters/ucs4swapped.h b/lib/converters/ucs4swapped.h new file mode 100644 index 00000000..e18fa410 --- /dev/null +++ b/lib/converters/ucs4swapped.h @@ -0,0 +1,65 @@ +/** + * @file ucs4swapped.h + * @brief UCS-4-SWAPPED = UCS-4-INTERNAL with inverted endianness + * @copyright Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UCS4SWAPPED_H_ +#define _UCS4SWAPPED_H_ + +#include "reiconv_defines.h" + +#include + +static int ucs4swapped_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + /* This function assumes that 'unsigned int' has exactly 32 bits. */ + if (sizeof(unsigned int) != 4) + abort(); + + if (n >= 4) + { + unsigned int x = *(const unsigned int *)s; + x = (x >> 24) | ((x >> 8) & 0xff00) | ((x & 0xff00) << 8) | (x << 24); + *pwc = x; + return 4; + } + return RET_TOOFEW(0); +} + +static int ucs4swapped_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + /* This function assumes that 'unsigned int' has exactly 32 bits. */ + if (sizeof(unsigned int) != 4) + abort(); + + if (n >= 4) + { + unsigned int x = wc; + x = (x >> 24) | ((x >> 8) & 0xff00) | ((x & 0xff00) << 8) | (x << 24); + *(unsigned int *)r = x; + return 4; + } + else + return RET_TOOSMALL; +} + +#endif /* _UCS4SWAPPED_H_ */ diff --git a/lib/uhc_1.h b/lib/converters/uhc_1.h similarity index 97% rename from lib/uhc_1.h rename to lib/converters/uhc_1.h index 781cb860..fb10f970 100644 --- a/lib/uhc_1.h +++ b/lib/converters/uhc_1.h @@ -1,5 +1,10 @@ +/** + * @file uhc_1.h + * @brief Unified Hangul Code part 1 + * @copyright Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * Unified Hangul Code part 1 - */ +#ifndef _UHC_1_H_ +#define _UHC_1_H_ + +#include "reiconv_defines.h" static const unsigned short uhc_1_2uni_main_page81[64] = { 0xac02, 0xac8d, 0xad14, 0xad91, 0xadfa, 0xae7a, 0xaee6, 0xaf57, @@ -802,27 +808,30 @@ static const unsigned char uhc_1_2uni_page81[5696] = { 0x71, 0x72, }; -static int -uhc_1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int uhc_1_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0x81 && c1 <= 0xa0)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x41 && c2 < 0x5b) || (c2 >= 0x61 && c2 < 0x7b) || (c2 >= 0x81 && c2 < 0xff)) { - unsigned int row = c1 - 0x81; - unsigned int col = c2 - (c2 >= 0x81 ? 0x4d : c2 >= 0x61 ? 0x47 : 0x41); - unsigned int i = 178 * row + col; - if (i < 5696) { - *pwc = (ucs4_t) (uhc_1_2uni_main_page81[2*row+(col>=89?1:0)] + uhc_1_2uni_page81[i]); - return 2; + unsigned char c1 = s[0]; + if ((c1 >= 0x81 && c1 <= 0xa0)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if ((c2 >= 0x41 && c2 < 0x5b) || (c2 >= 0x61 && c2 < 0x7b) || (c2 >= 0x81 && c2 < 0xff)) + { + unsigned int row = c1 - 0x81; + unsigned int col = c2 - (c2 >= 0x81 ? 0x4d : c2 >= 0x61 ? 0x47 : 0x41); + unsigned int i = 178 * row + col; + if (i < 5696) + { + *pwc = (ucs4_t)(uhc_1_2uni_main_page81[2 * row + (col >= 89 ? 1 : 0)] + uhc_1_2uni_page81[i]); + return 2; + } + } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned short uhc_1_2charset_main[45] = { @@ -1695,30 +1704,35 @@ static const Summary16 uhc_1_uni2indx_pageac[459] = { { 5672, 0xc714 }, { 5679, 0x5fef }, { 5692, 0x001d }, }; -static int -uhc_1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int uhc_1_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - if (wc >= 0xac00 && wc < 0xc8b0) { - const Summary16 *summary = &uhc_1_uni2indx_pageac[(wc>>4)-0xac0]; - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - used += summary->indx; - c = uhc_1_2charset_main[used>>7] + uhc_1_2charset[used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + if (wc >= 0xac00 && wc < 0xc8b0) + { + const Summary16 *summary = &uhc_1_uni2indx_pageac[(wc >> 4) - 0xac0]; + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + used += summary->indx; + c = uhc_1_2charset_main[used >> 7] + uhc_1_2charset[used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _UHC_1_H_ */ diff --git a/lib/uhc_2.h b/lib/converters/uhc_2.h similarity index 95% rename from lib/uhc_2.h rename to lib/converters/uhc_2.h index c0eb9977..75012be2 100644 --- a/lib/uhc_2.h +++ b/lib/converters/uhc_2.h @@ -1,5 +1,10 @@ +/** + * @file uhc_2.h + * @brief Unified Hangul Code part 2 + * @copyright Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2012, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * Unified Hangul Code part 2 - */ +#ifndef _UHC_2_H_ +#define _UHC_2_H_ + +#include "reiconv_defines.h" static const unsigned short uhc_2_2uni_main_pagea1[76] = { 0xc8a5, 0xc8d8, 0xc910, 0xc93e, 0xc971, 0xc9a5, 0xc9de, 0xca1c, @@ -484,27 +490,30 @@ static const unsigned char uhc_2_2uni_pagea1[3126] = { 0x15, 0x16, }; -static int -uhc_2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +static int uhc_2_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { - unsigned char c1 = s[0]; - if ((c1 >= 0xa1 && c1 <= 0xc6)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x41 && c2 < 0x5b) || (c2 >= 0x61 && c2 < 0x7b) || (c2 >= 0x81 && c2 < 0xa1)) { - unsigned int row = c1 - 0xa1; - unsigned int col = c2 - (c2 >= 0x81 ? 0x4d : c2 >= 0x61 ? 0x47 : 0x41); - unsigned int i = 84 * row + col; - if (i < 3126) { - *pwc = (ucs4_t) (uhc_2_2uni_main_pagea1[2*row+(col>=42?1:0)] + uhc_2_2uni_pagea1[i]); - return 2; + unsigned char c1 = s[0]; + if ((c1 >= 0xa1 && c1 <= 0xc6)) + { + if (n >= 2) + { + unsigned char c2 = s[1]; + if ((c2 >= 0x41 && c2 < 0x5b) || (c2 >= 0x61 && c2 < 0x7b) || (c2 >= 0x81 && c2 < 0xa1)) + { + unsigned int row = c1 - 0xa1; + unsigned int col = c2 - (c2 >= 0x81 ? 0x4d : c2 >= 0x61 ? 0x47 : 0x41); + unsigned int i = 84 * row + col; + if (i < 3126) + { + *pwc = (ucs4_t)(uhc_2_2uni_main_pagea1[2 * row + (col >= 42 ? 1 : 0)] + uhc_2_2uni_pagea1[i]); + return 2; + } + } + return RET_ILSEQ; } - } - return RET_ILSEQ; + return RET_TOOFEW(0); } - return RET_TOOFEW(0); - } - return RET_ILSEQ; + return RET_ILSEQ; } static const unsigned short uhc_2_2charset_main[49] = { @@ -992,30 +1001,35 @@ static const Summary16 uhc_2_uni2indx_pagec8[251] = { { 3099, 0xecfd }, { 3111, 0xd4fe }, { 3122, 0x000f }, }; -static int -uhc_2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +static int uhc_2_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) { - if (n >= 2) { - if (wc >= 0xc800 && wc < 0xd7b0) { - const Summary16 *summary = &uhc_2_uni2indx_pagec8[(wc>>4)-0xc80]; - unsigned short used = summary->used; - unsigned int i = wc & 0x0f; - if (used & ((unsigned short) 1 << i)) { - unsigned short c; - /* Keep in 'used' only the bits 0..i-1. */ - used &= ((unsigned short) 1 << i) - 1; - /* Add 'summary->indx' and the number of bits set in 'used'. */ - used = (used & 0x5555) + ((used & 0xaaaa) >> 1); - used = (used & 0x3333) + ((used & 0xcccc) >> 2); - used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); - used = (used & 0x00ff) + (used >> 8); - used += summary->indx; - c = uhc_2_2charset_main[used>>6] + uhc_2_2charset[used]; - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } + if (n >= 2) + { + if (wc >= 0xc800 && wc < 0xd7b0) + { + const Summary16 *summary = &uhc_2_uni2indx_pagec8[(wc >> 4) - 0xc80]; + unsigned short used = summary->used; + unsigned int i = wc & 0x0f; + if (used & ((unsigned short)1 << i)) + { + unsigned short c; + /* Keep in 'used' only the bits 0..i-1. */ + used &= ((unsigned short)1 << i) - 1; + /* Add 'summary->indx' and the number of bits set in 'used'. */ + used = (used & 0x5555) + ((used & 0xaaaa) >> 1); + used = (used & 0x3333) + ((used & 0xcccc) >> 2); + used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); + used = (used & 0x00ff) + (used >> 8); + used += summary->indx; + c = uhc_2_2charset_main[used >> 6] + uhc_2_2charset[used]; + r[0] = (c >> 8); + r[1] = (c & 0xff); + return 2; + } + } + return RET_ILUNI; } - return RET_ILUNI; - } - return RET_TOOSMALL; + return RET_TOOSMALL; } + +#endif /* _UHC_2_H_ */ diff --git a/lib/converters/utf16.h b/lib/converters/utf16.h new file mode 100644 index 00000000..63fbb93f --- /dev/null +++ b/lib/converters/utf16.h @@ -0,0 +1,146 @@ +/** + * @file utf16.h + * @brief UTF-16 + * @copyright Copyright (C) 1999-2024 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UTF16_H_ +#define _UTF16_H_ + +#include "reiconv_defines.h" + +#include + +/* Specification: RFC 2781 */ + +/* Here we accept FFFE/FEFF marks as endianness indicators everywhere + in the stream, not just at the beginning. (This is contrary to what + RFC 2781 section 3.2 specifies, but it allows concatenation of byte + sequences to work flawlessly, while disagreeing with the RFC behaviour + only for strings containing U+FEFF characters, which is quite rare.) + The default is big-endian. */ +/* The state is 0 if big-endian, 1 if little-endian. */ +static int utf16_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + state_t state = conv->ibyteorder; + int count = 0; + for (; n >= 2 && count <= RET_COUNT_MAX && count <= INT_MAX - 2;) + { + ucs4_t wc = (state ? s[0] + (s[1] << 8) : (s[0] << 8) + s[1]); + if (wc == 0xfeff) + { + } + else if (wc == 0xfffe) + { + state ^= 1; + } + else if (wc >= 0xd800 && wc < 0xdc00) + { + if (n >= 4) + { + ucs4_t wc2 = (state ? s[2] + (s[3] << 8) : (s[2] << 8) + s[3]); + if (!(wc2 >= 0xdc00 && wc2 < 0xe000)) + goto ilseq; + *pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00); + conv->ibyteorder = state; + return count + 4; + } + else + break; + } + else if (wc >= 0xdc00 && wc < 0xe000) + { + goto ilseq; + } + else + { + *pwc = wc; + conv->ibyteorder = state; + return count + 2; + } + s += 2; + n -= 2; + count += 2; + } + conv->ibyteorder = state; + return RET_TOOFEW(count); + +ilseq: + conv->ibyteorder = state; + return RET_SHIFT_ILSEQ(count); +} + +/* We output UTF-16 in big-endian order, with byte-order mark. + See RFC 2781 section 3.3 for a rationale: Some document formats + mandate a BOM; the file concatenation issue is not so severe as + long as the above utf16_mbtowc function is used. */ +/* The state is 0 at the beginning, 1 after the BOM has been written. */ +static int utf16_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc != 0xfffe && !(wc >= 0xd800 && wc < 0xe000)) + { + int count = 0; + if (!conv->ostate) + { + if (n >= 2) + { + r[0] = 0xFE; + r[1] = 0xFF; + r += 2; + n -= 2; + count += 2; + } + else + return RET_TOOSMALL; + } + if (wc < 0x10000) + { + if (n >= 2) + { + r[0] = (unsigned char)(wc >> 8); + r[1] = (unsigned char)wc; + conv->ostate = 1; + return count + 2; + } + else + return RET_TOOSMALL; + } + else if (wc < 0x110000) + { + if (n >= 4) + { + ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10); + ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff); + r[0] = (unsigned char)(wc1 >> 8); + r[1] = (unsigned char)wc1; + r[2] = (unsigned char)(wc2 >> 8); + r[3] = (unsigned char)wc2; + conv->ostate = 1; + return count + 4; + } + else + return RET_TOOSMALL; + } + } + return RET_ILUNI; +} + +#endif /* _UTF16_H_ */ diff --git a/lib/converters/utf16be.h b/lib/converters/utf16be.h new file mode 100644 index 00000000..c4ce4873 --- /dev/null +++ b/lib/converters/utf16be.h @@ -0,0 +1,99 @@ +/** + * @file utf16be.h + * @brief UTF-16BE + * @copyright Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UTF16BE_H_ +#define _UTF16BE_H_ + +#include "reiconv_defines.h" + +/* Specification: RFC 2781 */ + +static int utf16be_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + int count = 0; + if (n >= 2) + { + ucs4_t wc = (s[0] << 8) + s[1]; + if (wc >= 0xd800 && wc < 0xdc00) + { + if (n >= 4) + { + ucs4_t wc2 = (s[2] << 8) + s[3]; + if (!(wc2 >= 0xdc00 && wc2 < 0xe000)) + goto ilseq; + *pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00); + return count + 4; + } + } + else if (wc >= 0xdc00 && wc < 0xe000) + { + goto ilseq; + } + else + { + *pwc = wc; + return count + 2; + } + } + return RET_TOOFEW(count); + +ilseq: + return RET_SHIFT_ILSEQ(count); +} + +static int utf16be_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (!(wc >= 0xd800 && wc < 0xe000)) + { + if (wc < 0x10000) + { + if (n >= 2) + { + r[0] = (unsigned char)(wc >> 8); + r[1] = (unsigned char)wc; + return 2; + } + else + return RET_TOOSMALL; + } + else if (wc < 0x110000) + { + if (n >= 4) + { + ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10); + ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff); + r[0] = (unsigned char)(wc1 >> 8); + r[1] = (unsigned char)wc1; + r[2] = (unsigned char)(wc2 >> 8); + r[3] = (unsigned char)wc2; + return 4; + } + else + return RET_TOOSMALL; + } + } + return RET_ILUNI; +} + +#endif /* _UTF16BE_H_ */ diff --git a/lib/converters/utf16le.h b/lib/converters/utf16le.h new file mode 100644 index 00000000..6809a5fb --- /dev/null +++ b/lib/converters/utf16le.h @@ -0,0 +1,99 @@ +/** + * @file utf16le.h + * @brief UTF-16LE + * @copyright Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UTF16LE_H_ +#define _UTF16LE_H_ + +#include "reiconv_defines.h" + +/* Specification: RFC 2781 */ + +static int utf16le_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + int count = 0; + if (n >= 2) + { + ucs4_t wc = s[0] + (s[1] << 8); + if (wc >= 0xd800 && wc < 0xdc00) + { + if (n >= 4) + { + ucs4_t wc2 = s[2] + (s[3] << 8); + if (!(wc2 >= 0xdc00 && wc2 < 0xe000)) + goto ilseq; + *pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00); + return count + 4; + } + } + else if (wc >= 0xdc00 && wc < 0xe000) + { + goto ilseq; + } + else + { + *pwc = wc; + return count + 2; + } + } + return RET_TOOFEW(count); + +ilseq: + return RET_SHIFT_ILSEQ(count); +} + +static int utf16le_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (!(wc >= 0xd800 && wc < 0xe000)) + { + if (wc < 0x10000) + { + if (n >= 2) + { + r[0] = (unsigned char)wc; + r[1] = (unsigned char)(wc >> 8); + return 2; + } + else + return RET_TOOSMALL; + } + else if (wc < 0x110000) + { + if (n >= 4) + { + ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10); + ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff); + r[0] = (unsigned char)wc1; + r[1] = (unsigned char)(wc1 >> 8); + r[2] = (unsigned char)wc2; + r[3] = (unsigned char)(wc2 >> 8); + return 4; + } + else + return RET_TOOSMALL; + } + } + return RET_ILUNI; +} + +#endif /* _UTF16LE_H_ */ diff --git a/lib/converters/utf32.h b/lib/converters/utf32.h new file mode 100644 index 00000000..80b04dd4 --- /dev/null +++ b/lib/converters/utf32.h @@ -0,0 +1,118 @@ +/** + * @file utf32.h + * @brief UTF-32 + * @copyright Copyright (C) 1999-2024 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UTF32_H_ +#define _UTF32_H_ + +#include "reiconv_defines.h" + +#include + +/* Specification: Unicode 3.1 Standard Annex #19 */ + +/* Here we accept FFFE0000/0000FEFF marks as endianness indicators + everywhere in the stream, not just at the beginning. (This is contrary + to what #19 D36c specifies, but it allows concatenation of byte + sequences to work flawlessly, while disagreeing with #19 behaviour + only for strings containing U+FEFF characters, which is quite rare.) + The default is big-endian. */ +/* The state is 0 if big-endian, 1 if little-endian. */ +static int utf32_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + state_t state = conv->ibyteorder; + int count = 0; + for (; n >= 4 && count <= RET_COUNT_MAX && count <= INT_MAX - 4;) + { + ucs4_t wc = (state ? (ucs4_t)s[0] + ((ucs4_t)s[1] << 8) + ((ucs4_t)s[2] << 16) + ((ucs4_t)s[3] << 24) + : ((ucs4_t)s[0] << 24) + ((ucs4_t)s[1] << 16) + ((ucs4_t)s[2] << 8) + (ucs4_t)s[3]); + if (wc == 0x0000feff) + { + } + else if (wc == 0xfffe0000u) + { + state ^= 1; + } + else + { + if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) + { + *pwc = wc; + conv->ibyteorder = state; + return count + 4; + } + else + { + conv->ibyteorder = state; + return RET_SHIFT_ILSEQ(count); + } + } + s += 4; + n -= 4; + count += 4; + } + conv->ibyteorder = state; + return RET_TOOFEW(count); +} + +/* We output UTF-32 in big-endian order, with byte-order mark. */ +/* The state is 0 at the beginning, 1 after the BOM has been written. */ +static int utf32_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) + { + int count = 0; + if (!conv->ostate) + { + if (n >= 4) + { + r[0] = 0x00; + r[1] = 0x00; + r[2] = 0xFE; + r[3] = 0xFF; + r += 4; + n -= 4; + count += 4; + } + else + return RET_TOOSMALL; + } + if (wc < 0x110000) + { + if (n >= 4) + { + r[0] = 0; + r[1] = (unsigned char)(wc >> 16); + r[2] = (unsigned char)(wc >> 8); + r[3] = (unsigned char)wc; + conv->ostate = 1; + return count + 4; + } + else + return RET_TOOSMALL; + } + } + return RET_ILUNI; +} + +#endif /* _UTF32_H_ */ diff --git a/lib/converters/utf32be.h b/lib/converters/utf32be.h new file mode 100644 index 00000000..4542a51d --- /dev/null +++ b/lib/converters/utf32be.h @@ -0,0 +1,70 @@ +/** + * @file utf32be.h + * @brief UTF-32BE + * @copyright Copyright (C) 1999-2001, 2016, 2024 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _UTF32BE_H_ +#define _UTF32BE_H_ + +#include "reiconv_defines.h" + +// Specification: Unicode 3.1 Standard Annex #19 + +static int utf32be_mbtowc(conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) +{ + if (n >= 4) + { + ucs4_t wc = ((ucs4_t)s[0] << 24) + ((ucs4_t)s[1] << 16) + ((ucs4_t)s[2] << 8) + (ucs4_t)s[3]; + if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) + { + *pwc = wc; + return 4; + } + else + { + return RET_ILSEQ; + } + } + return RET_TOOFEW(0); +} + +static int utf32be_wctomb(conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +{ + if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) + { + if (n >= 4) + { + r[0] = 0; + r[1] = (unsigned char)(wc >> 16); + r[2] = (unsigned char)(wc >> 8); + r[3] = (unsigned char)wc; + return 4; + } + else + { + return RET_TOOSMALL; + } + } + return RET_ILUNI; +} + +#endif /* _UTF32BE_H_ */ diff --git a/lib/utf32le.h b/lib/converters/utf32le.h similarity index 73% rename from lib/utf32le.h rename to lib/converters/utf32le.h index 8bc4a310..fc0b7fe6 100644 --- a/lib/utf32le.h +++ b/lib/converters/utf32le.h @@ -1,5 +1,10 @@ +/** + * @file utf32le.h + * @brief UTF-32LE + * @copyright Copyright (C) 1999-2001, 2016, 2024 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * UTF-32LE - */ +#ifndef _UTF32LE_H_ +#define _UTF32LE_H_ + +#include "reiconv_defines.h" /* Specification: Unicode 3.1 Standard Annex #19 */ @@ -27,7 +33,10 @@ static int utf32le_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) { if (n >= 4) { - ucs4_t wc = s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24); + ucs4_t wc = (ucs4_t) s[0] + + ((ucs4_t) s[1] << 8) + + ((ucs4_t) s[2] << 16) + + ((ucs4_t) s[3] << 24); if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) { *pwc = wc; return 4; @@ -52,3 +61,5 @@ utf32le_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) } return RET_ILUNI; } + +#endif /* _UTF32LE_H_ */ diff --git a/lib/utf7.h b/lib/converters/utf7.h similarity index 96% rename from lib/utf7.h rename to lib/converters/utf7.h index a8201fce..3335a58e 100644 --- a/lib/utf7.h +++ b/lib/converters/utf7.h @@ -1,5 +1,10 @@ +/** + * @file utf7.h + * @brief UTF-7 + * @copyright Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,16 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * UTF-7 - */ +#ifndef _UTF7_H_ +#define _UTF7_H_ + +#include "reiconv_defines.h" + +#include /* Specification: RFC 2152 (and old RFC 1641, RFC 1642) */ /* The original Base64 encoding is defined in RFC 2045. */ @@ -352,3 +360,5 @@ utf7_reset (conv_t conv, unsigned char *r, size_t n) } else return 0; } + +#endif /* _UTF7_H_ */ diff --git a/lib/utf8.h b/lib/converters/utf8.h similarity index 89% rename from lib/utf8.h rename to lib/converters/utf8.h index 0c2c834a..94381938 100644 --- a/lib/utf8.h +++ b/lib/converters/utf8.h @@ -1,5 +1,10 @@ +/** + * @file utf8.h + * @brief UTF-8 + * @copyright Copyright (C) 1999-2001, 2004, 2016 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2004, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * UTF-8 - */ +#ifndef _UTF8_H_ +#define _UTF8_H_ + +#include "reiconv_defines.h" /* Specification: RFC 3629 */ @@ -96,3 +102,5 @@ utf8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) /* n == 0 is ac } return count; } + +#endif /* _UTF8_H_ */ diff --git a/lib/vietcomb.h b/lib/converters/vietcomb.h similarity index 97% rename from lib/vietcomb.h rename to lib/converters/vietcomb.h index b1096894..654c5d71 100644 --- a/lib/vietcomb.h +++ b/lib/converters/vietcomb.h @@ -1,5 +1,10 @@ +/** + * @file vietcomb.h + * @brief mbining characters used in Vietnamese encodings CP1258, TCVN. + * @copyright Copyright (C) 2001, 2004, 2011 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 2001, 2004, 2011 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,14 +18,12 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* Combining characters used in Vietnamese encodings CP1258, TCVN. */ - -#ifndef _VIETCOMB_H -#define _VIETCOMB_H +#ifndef _VIETCOMB_H_ +#define _VIETCOMB_H_ /* Relevant combining characters: 0x0300, 0x0301, 0x0303, 0x0309, 0x0323. */ @@ -462,4 +465,4 @@ static const struct viet_decomp viet_decomp_table[] = { { 0x1FEE, 0x00A8, 1 }, /* U+1FEE => U+0385 => U+00A8 U+0301 */ }; -#endif /* _VIETCOMB_H */ +#endif /* _VIETCOMB_H_ */ diff --git a/lib/viscii.h b/lib/converters/viscii.h similarity index 94% rename from lib/viscii.h rename to lib/converters/viscii.h index ac2392ce..459850b3 100644 --- a/lib/viscii.h +++ b/lib/converters/viscii.h @@ -1,5 +1,10 @@ +/** + * @file viscii.h + * @brief VISCII1.1-1 + * @copyright Copyright (C) 1999-2001, 2016, 2019 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016, 2019 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,13 +18,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * VISCII1.1-1 - */ +#ifndef _VISCII_H_ +#define _VISCII_H_ + +#include "reiconv_defines.h" /* Specification: RFC 1456 */ @@ -138,3 +144,5 @@ viscii_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) } return RET_ILUNI; } + +#endif /* _VISCII_H_ */ diff --git a/lib/cp1162.h b/lib/cp1162.h deleted file mode 100644 index be7fb433..00000000 --- a/lib/cp1162.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * CP1162 - */ - -static int -cp1162_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else { - unsigned short wc = cp874_2uni[c-0x80]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 1; - } - if (c < 0xa0) { - *pwc = (ucs4_t) c; - return 1; - } - } - return RET_ILSEQ; -} - -static int -cp1162_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x0080 && wc < 0x00a0 && cp874_2uni[wc-0x0080] == 0xfffd) - c = wc; - else if (wc == 0x00a0) - c = 0xa0; - else if (wc >= 0x0e00 && wc < 0x0e60) - c = cp874_page0e[wc-0x0e00]; - else if (wc >= 0x2010 && wc < 0x2028) - c = cp874_page20[wc-0x2010]; - else if (wc == 0x20ac) - c = 0x80; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; -} diff --git a/lib/cp1163.h b/lib/cp1163.h deleted file mode 100644 index aafb5a17..00000000 --- a/lib/cp1163.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * CP1163 - */ - -static int -cp1163_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - if (c < 0xa0) - *pwc = (ucs4_t) c; - else if (c == 0xa4) - *pwc = 0x20ac; - else - *pwc = (ucs4_t) cp1129_2uni[c-0xa0]; - return 1; -} - -static const unsigned char cp1163_page20[8] = { - 0x00, 0x00, 0x00, 0xfe, 0xa4, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ -}; - -static int -cp1163_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char c = 0; - if (wc < 0x00a0 || (wc < 0x00a8 && wc != 0x00a4) || wc == 0x00d0) { - *r = wc; - return 1; - } - else if (wc >= 0x00a8 && wc < 0x01b8) - c = cp1129_page00[wc-0x00a8]; - else if (wc >= 0x0300 && wc < 0x0328) - c = cp1129_page03[wc-0x0300]; - else if (wc == 0x203e) - c = 0xaf; - else if (wc >= 0x20a8 && wc < 0x20b0) - c = cp1163_page20[wc-0x20a8]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; -} diff --git a/lib/cp1255.h b/lib/cp1255.h deleted file mode 100644 index 6d71a971..00000000 --- a/lib/cp1255.h +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2004, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * CP1255 - */ - -#include "flushwc.h" - -/* Combining characters used in Hebrew encoding CP1255. */ - -/* Relevant combining characters: - 0x05b4, 0x05b7, 0x05b8, 0x05b9, 0x05bc, 0x05bf, 0x05c1, 0x05c2. */ - -/* Composition tables for each of the relevant combining characters. */ -static const struct { unsigned short base; unsigned short composed; } cp1255_comp_table_data[] = { -#define cp1255_comp_table05b4_idx 0 -#define cp1255_comp_table05b4_len 1 - { 0x05D9, 0xFB1D }, -#define cp1255_comp_table05b7_idx (cp1255_comp_table05b4_idx+cp1255_comp_table05b4_len) -#define cp1255_comp_table05b7_len 2 - { 0x05D0, 0xFB2E }, - { 0x05F2, 0xFB1F }, -#define cp1255_comp_table05b8_idx (cp1255_comp_table05b7_idx+cp1255_comp_table05b7_len) -#define cp1255_comp_table05b8_len 1 - { 0x05D0, 0xFB2F }, -#define cp1255_comp_table05b9_idx (cp1255_comp_table05b8_idx+cp1255_comp_table05b8_len) -#define cp1255_comp_table05b9_len 1 - { 0x05D5, 0xFB4B }, -#define cp1255_comp_table05bc_idx (cp1255_comp_table05b9_idx+cp1255_comp_table05b9_len) -#define cp1255_comp_table05bc_len 24 - { 0x05D0, 0xFB30 }, - { 0x05D1, 0xFB31 }, - { 0x05D2, 0xFB32 }, - { 0x05D3, 0xFB33 }, - { 0x05D4, 0xFB34 }, - { 0x05D5, 0xFB35 }, - { 0x05D6, 0xFB36 }, - { 0x05D8, 0xFB38 }, - { 0x05D9, 0xFB39 }, - { 0x05DA, 0xFB3A }, - { 0x05DB, 0xFB3B }, - { 0x05DC, 0xFB3C }, - { 0x05DE, 0xFB3E }, - { 0x05E0, 0xFB40 }, - { 0x05E1, 0xFB41 }, - { 0x05E3, 0xFB43 }, - { 0x05E4, 0xFB44 }, - { 0x05E6, 0xFB46 }, - { 0x05E7, 0xFB47 }, - { 0x05E8, 0xFB48 }, - { 0x05E9, 0xFB49 }, - { 0x05EA, 0xFB4A }, - { 0xFB2A, 0xFB2C }, - { 0xFB2B, 0xFB2D }, -#define cp1255_comp_table05bf_idx (cp1255_comp_table05bc_idx+cp1255_comp_table05bc_len) -#define cp1255_comp_table05bf_len 3 - { 0x05D1, 0xFB4C }, - { 0x05DB, 0xFB4D }, - { 0x05E4, 0xFB4E }, -#define cp1255_comp_table05c1_idx (cp1255_comp_table05bf_idx+cp1255_comp_table05bf_len) -#define cp1255_comp_table05c1_len 2 - { 0x05E9, 0xFB2A }, - { 0xFB49, 0xFB2C }, -#define cp1255_comp_table05c2_idx (cp1255_comp_table05c1_idx+cp1255_comp_table05c1_len) -#define cp1255_comp_table05c2_len 2 - { 0x05E9, 0xFB2B }, - { 0xFB49, 0xFB2D }, -}; -static const struct { unsigned int len; unsigned int idx; } cp1255_comp_table[] = { - { cp1255_comp_table05b4_len, cp1255_comp_table05b4_idx }, - { cp1255_comp_table05b7_len, cp1255_comp_table05b7_idx }, - { cp1255_comp_table05b8_len, cp1255_comp_table05b8_idx }, - { cp1255_comp_table05b9_len, cp1255_comp_table05b9_idx }, - { cp1255_comp_table05bc_len, cp1255_comp_table05bc_idx }, - { cp1255_comp_table05bf_len, cp1255_comp_table05bf_idx }, - { cp1255_comp_table05c1_len, cp1255_comp_table05c1_idx }, - { cp1255_comp_table05c2_len, cp1255_comp_table05c2_idx }, -}; - -/* Decomposition table for the relevant Unicode characters. */ -struct cp1255_decomp { unsigned short composed; unsigned short base; int comb1 : 8; signed int comb2 : 8; }; -static const struct cp1255_decomp cp1255_decomp_table[] = { - { 0xFB1D, 0x05D9, 0, -1 }, - { 0xFB1F, 0x05F2, 1, -1 }, - { 0xFB2A, 0x05E9, 6, -1 }, - { 0xFB2B, 0x05E9, 7, -1 }, - { 0xFB2C, 0x05E9, 4, 6 }, - { 0xFB2D, 0x05E9, 4, 7 }, - { 0xFB2E, 0x05D0, 1, -1 }, - { 0xFB2F, 0x05D0, 2, -1 }, - { 0xFB30, 0x05D0, 4, -1 }, - { 0xFB31, 0x05D1, 4, -1 }, - { 0xFB32, 0x05D2, 4, -1 }, - { 0xFB33, 0x05D3, 4, -1 }, - { 0xFB34, 0x05D4, 4, -1 }, - { 0xFB35, 0x05D5, 4, -1 }, - { 0xFB36, 0x05D6, 4, -1 }, - { 0xFB38, 0x05D8, 4, -1 }, - { 0xFB39, 0x05D9, 4, -1 }, - { 0xFB3A, 0x05DA, 4, -1 }, - { 0xFB3B, 0x05DB, 4, -1 }, - { 0xFB3C, 0x05DC, 4, -1 }, - { 0xFB3E, 0x05DE, 4, -1 }, - { 0xFB40, 0x05E0, 4, -1 }, - { 0xFB41, 0x05E1, 4, -1 }, - { 0xFB43, 0x05E3, 4, -1 }, - { 0xFB44, 0x05E4, 4, -1 }, - { 0xFB46, 0x05E6, 4, -1 }, - { 0xFB47, 0x05E7, 4, -1 }, - { 0xFB48, 0x05E8, 4, -1 }, - { 0xFB49, 0x05E9, 4, -1 }, - { 0xFB4A, 0x05EA, 4, -1 }, - { 0xFB4B, 0x05D5, 3, -1 }, - { 0xFB4C, 0x05D1, 5, -1 }, - { 0xFB4D, 0x05DB, 5, -1 }, - { 0xFB4E, 0x05E4, 5, -1 }, -}; - -static const unsigned char cp1255_comb_table[] = { - 0xc4, 0xc7, 0xc8, 0xc9, 0xcc, 0xcf, 0xd1, 0xd2, -}; - -static const unsigned short cp1255_2uni[128] = { - /* 0x80 */ - 0x20ac, 0xfffd, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, - 0x02c6, 0x2030, 0xfffd, 0x2039, 0xfffd, 0xfffd, 0xfffd, 0xfffd, - /* 0x90 */ - 0xfffd, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, - 0x02dc, 0x2122, 0xfffd, 0x203a, 0xfffd, 0xfffd, 0xfffd, 0xfffd, - /* 0xa0 */ - 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20aa, 0x00a5, 0x00a6, 0x00a7, - 0x00a8, 0x00a9, 0x00d7, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, - /* 0xb0 */ - 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, - 0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, - /* 0xc0 */ - 0x05b0, 0x05b1, 0x05b2, 0x05b3, 0x05b4, 0x05b5, 0x05b6, 0x05b7, - 0x05b8, 0x05b9, 0x05ba, 0x05bb, 0x05bc, 0x05bd, 0x05be, 0x05bf, - /* 0xd0 */ - 0x05c0, 0x05c1, 0x05c2, 0x05c3, 0x05f0, 0x05f1, 0x05f2, 0x05f3, - 0x05f4, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, - /* 0xe0 */ - 0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7, - 0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df, - /* 0xf0 */ - 0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7, - 0x05e8, 0x05e9, 0x05ea, 0xfffd, 0xfffd, 0x200e, 0x200f, 0xfffd, -}; - -/* In the CP1255 to Unicode direction, the state contains a buffered - character, or 0 if none. */ - -static int -cp1255_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - unsigned short wc; - unsigned short last_wc; - if (c < 0x80) { - wc = c; - } else { - wc = cp1255_2uni[c-0x80]; - if (wc == 0xfffd) - return RET_ILSEQ; - } - last_wc = conv->istate; - if (last_wc) { - if (wc >= 0x05b0 && wc < 0x05c5) { - /* See whether last_wc and wc can be combined. */ - unsigned int k; - unsigned int i1, i2; - switch (wc) { - case 0x05b4: k = 0; break; - case 0x05b7: k = 1; break; - case 0x05b8: k = 2; break; - case 0x05b9: k = 3; break; - case 0x05bc: k = 4; break; - case 0x05bf: k = 5; break; - case 0x05c1: k = 6; break; - case 0x05c2: k = 7; break; - default: goto not_combining; - } - i1 = cp1255_comp_table[k].idx; - i2 = i1 + cp1255_comp_table[k].len-1; - if (last_wc >= cp1255_comp_table_data[i1].base - && last_wc <= cp1255_comp_table_data[i2].base) { - unsigned int i; - for (;;) { - i = (i1+i2)>>1; - if (last_wc == cp1255_comp_table_data[i].base) - break; - if (last_wc < cp1255_comp_table_data[i].base) { - if (i1 == i) - goto not_combining; - i2 = i; - } else { - if (i1 != i) - i1 = i; - else { - i = i2; - if (last_wc == cp1255_comp_table_data[i].base) - break; - goto not_combining; - } - } - } - last_wc = cp1255_comp_table_data[i].composed; - if (last_wc == 0xfb2a || last_wc == 0xfb2b || last_wc == 0xfb49) { - /* Buffer the combined character. */ - conv->istate = last_wc; - return RET_TOOFEW(1); - } else { - /* Output the combined character. */ - conv->istate = 0; - *pwc = (ucs4_t) last_wc; - return 1; - } - } - } - not_combining: - /* Output the buffered character. */ - conv->istate = 0; - *pwc = (ucs4_t) last_wc; - return 0; /* Don't advance the input pointer. */ - } - if ((wc >= 0x05d0 && wc <= 0x05ea && ((0x07db5f7f >> (wc - 0x05d0)) & 1)) - || wc == 0x05f2) { - /* wc is a possible match in cp1255_comp_table_data. Buffer it. */ - conv->istate = wc; - return RET_TOOFEW(1); - } else { - /* Output wc immediately. */ - *pwc = (ucs4_t) wc; - return 1; - } -} - -#define cp1255_flushwc normal_flushwc - -static const unsigned char cp1255_page00[88] = { - 0xa0, 0xa1, 0xa2, 0xa3, 0x00, 0xa5, 0xa6, 0xa7, /* 0xa0-0xa7 */ - 0xa8, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */ - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */ - 0xb8, 0xb9, 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* 0xb8-0xbf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, /* 0xd0-0xd7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, /* 0xf0-0xf7 */ -}; -static const unsigned char cp1255_page02[32] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, /* 0xc0-0xc7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ - 0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ -}; -static const unsigned char cp1255_page05[72] = { - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xb0-0xb7 */ - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xb8-0xbf */ - 0xd0, 0xd1, 0xd2, 0xd3, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xd0-0xd7 */ - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xd8-0xdf */ - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xe0-0xe7 */ - 0xf8, 0xf9, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */ - 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */ -}; -static const unsigned char cp1255_page20[56] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, 0xfe, /* 0x08-0x0f */ - 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */ - 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */ - 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ - 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ - 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ -}; - -static int -cp1255_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00f8) - c = cp1255_page00[wc-0x00a0]; - else if (wc == 0x0192) - c = 0x83; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = cp1255_page02[wc-0x02c0]; - else if (wc >= 0x05b0 && wc < 0x05f8) - c = cp1255_page05[wc-0x05b0]; - else if (wc >= 0x2008 && wc < 0x2040) - c = cp1255_page20[wc-0x2008]; - else if (wc == 0x20aa) - c = 0xa4; - else if (wc == 0x20ac) - c = 0x80; - else if (wc == 0x2122) - c = 0x99; - if (c != 0) { - *r = c; - return 1; - } - /* Try canonical decomposition. */ - { - /* Binary search through cp1255_decomp_table. */ - unsigned int i1 = 0; - unsigned int i2 = sizeof(cp1255_decomp_table)/sizeof(cp1255_decomp_table[0])-1; - if (wc >= cp1255_decomp_table[i1].composed - && wc <= cp1255_decomp_table[i2].composed) { - unsigned int i; - for (;;) { - /* Here i2 - i1 > 0. */ - i = (i1+i2)>>1; - if (wc == cp1255_decomp_table[i].composed) - break; - if (wc < cp1255_decomp_table[i].composed) { - if (i1 == i) - return RET_ILUNI; - /* Here i1 < i < i2. */ - i2 = i; - } else { - /* Here i1 <= i < i2. */ - if (i1 != i) - i1 = i; - else { - /* Here i2 - i1 = 1. */ - i = i2; - if (wc == cp1255_decomp_table[i].composed) - break; - else - return RET_ILUNI; - } - } - } - /* Found a canonical decomposition. */ - wc = cp1255_decomp_table[i].base; - /* wc is one of 0x05d0..0x05d6, 0x05d8..0x05dc, 0x05de, 0x05e0..0x05e1, - 0x05e3..0x05e4, 0x05e6..0x05ea, 0x05f2. */ - c = cp1255_page05[wc-0x05b0]; - if (cp1255_decomp_table[i].comb2 < 0) { - if (n < 2) - return RET_TOOSMALL; - r[0] = c; - r[1] = cp1255_comb_table[cp1255_decomp_table[i].comb1]; - return 2; - } else { - if (n < 3) - return RET_TOOSMALL; - r[0] = c; - r[1] = cp1255_comb_table[cp1255_decomp_table[i].comb1]; - r[2] = cp1255_comb_table[cp1255_decomp_table[i].comb2]; - return 3; - } - } - } - return RET_ILUNI; -} diff --git a/lib/cp1258.h b/lib/cp1258.h deleted file mode 100644 index ae804cce..00000000 --- a/lib/cp1258.h +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2004, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * CP1258 - */ - -#include "flushwc.h" -#include "vietcomb.h" - -static const unsigned char cp1258_comb_table[] = { - 0xcc, 0xec, 0xde, 0xd2, 0xf2, -}; - -/* The possible bases in viet_comp_table_data: - 0x0041..0x0045, 0x0047..0x0049, 0x004B..0x0050, 0x0052..0x0057, - 0x0059..0x005A, 0x0061..0x0065, 0x0067..0x0069, 0x006B..0x0070, - 0x0072..0x0077, 0x0079..0x007A, 0x00A5, 0x00A8, 0x00C2, 0x00C5..0x00C7, - 0x00CA, 0x00CF, 0x00D3..0x00D4, 0x00D6, 0x00D8, 0x00DA, 0x00DC, 0x00E2, - 0x00E5..0x00E7, 0x00EA, 0x00EF, 0x00F3..0x00F4, 0x00F6, 0x00F8, 0x00FA, - 0x00FC, 0x0102..0x0103, 0x01A0..0x01A1, 0x01AF..0x01B0. */ -static const unsigned int cp1258_comp_bases[] = { - 0x06fdfbbe, 0x06fdfbbe, 0x00000000, 0x00000120, 0x155884e4, 0x155884e4, - 0x0000000c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00018003 -}; - -static const unsigned short cp1258_2uni[128] = { - /* 0x80 */ - 0x20ac, 0xfffd, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, - 0x02c6, 0x2030, 0xfffd, 0x2039, 0x0152, 0xfffd, 0xfffd, 0xfffd, - /* 0x90 */ - 0xfffd, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, - 0x02dc, 0x2122, 0xfffd, 0x203a, 0x0153, 0xfffd, 0xfffd, 0x0178, - /* 0xa0 */ - 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, - 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, - /* 0xb0 */ - 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, - 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, - /* 0xc0 */ - 0x00c0, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x00c5, 0x00c6, 0x00c7, - 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x0300, 0x00cd, 0x00ce, 0x00cf, - /* 0xd0 */ - 0x0110, 0x00d1, 0x0309, 0x00d3, 0x00d4, 0x01a0, 0x00d6, 0x00d7, - 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x01af, 0x0303, 0x00df, - /* 0xe0 */ - 0x00e0, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x00e5, 0x00e6, 0x00e7, - 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x0301, 0x00ed, 0x00ee, 0x00ef, - /* 0xf0 */ - 0x0111, 0x00f1, 0x0323, 0x00f3, 0x00f4, 0x01a1, 0x00f6, 0x00f7, - 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x01b0, 0x20ab, 0x00ff, -}; - -/* In the CP1258 to Unicode direction, the state contains a buffered - character, or 0 if none. */ - -static int -cp1258_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - unsigned short wc; - unsigned short last_wc; - if (c < 0x80) { - wc = c; - } else { - wc = cp1258_2uni[c-0x80]; - if (wc == 0xfffd) - return RET_ILSEQ; - } - last_wc = conv->istate; - if (last_wc) { - if (wc >= 0x0300 && wc < 0x0340) { - /* See whether last_wc and wc can be combined. */ - unsigned int k; - unsigned int i1, i2; - switch (wc) { - case 0x0300: k = 0; break; - case 0x0301: k = 1; break; - case 0x0303: k = 2; break; - case 0x0309: k = 3; break; - case 0x0323: k = 4; break; - default: abort(); - } - i1 = viet_comp_table[k].idx; - i2 = i1 + viet_comp_table[k].len-1; - if (last_wc >= viet_comp_table_data[i1].base - && last_wc <= viet_comp_table_data[i2].base) { - unsigned int i; - for (;;) { - i = (i1+i2)>>1; - if (last_wc == viet_comp_table_data[i].base) - break; - if (last_wc < viet_comp_table_data[i].base) { - if (i1 == i) - goto not_combining; - i2 = i; - } else { - if (i1 != i) - i1 = i; - else { - i = i2; - if (last_wc == viet_comp_table_data[i].base) - break; - goto not_combining; - } - } - } - last_wc = viet_comp_table_data[i].composed; - /* Output the combined character. */ - conv->istate = 0; - *pwc = (ucs4_t) last_wc; - return 1; - } - } - not_combining: - /* Output the buffered character. */ - conv->istate = 0; - *pwc = (ucs4_t) last_wc; - return 0; /* Don't advance the input pointer. */ - } - if (wc >= 0x0041 && wc <= 0x01b0 - && ((cp1258_comp_bases[(wc - 0x0040) >> 5] >> (wc & 0x1f)) & 1)) { - /* wc is a possible match in viet_comp_table_data. Buffer it. */ - conv->istate = wc; - return RET_TOOFEW(1); - } else { - /* Output wc immediately. */ - *pwc = (ucs4_t) wc; - return 1; - } -} - -#define cp1258_flushwc normal_flushwc - -static const unsigned char cp1258_page00[88] = { - 0xc0, 0xc1, 0xc2, 0x00, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0-0xc7 */ - 0xc8, 0xc9, 0xca, 0xcb, 0x00, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */ - 0x00, 0xd1, 0x00, 0xd3, 0xd4, 0x00, 0xd6, 0xd7, /* 0xd0-0xd7 */ - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0x00, 0x00, 0xdf, /* 0xd8-0xdf */ - 0xe0, 0xe1, 0xe2, 0x00, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0-0xe7 */ - 0xe8, 0xe9, 0xea, 0xeb, 0x00, 0xed, 0xee, 0xef, /* 0xe8-0xef */ - 0x00, 0xf1, 0x00, 0xf3, 0xf4, 0x00, 0xf6, 0xf7, /* 0xf0-0xf7 */ - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0x00, 0xff, /* 0xf8-0xff */ - /* 0x0100 */ - 0x00, 0x00, 0xc3, 0xe3, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ - 0xd0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ -}; -static const unsigned char cp1258_page01[104] = { - 0x00, 0x00, 0x8c, 0x9c, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ - 0x9f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ - 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ - 0xd5, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdd, /* 0xa8-0xaf */ - 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ -}; -static const unsigned char cp1258_page02[32] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, /* 0xc0-0xc7 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ - 0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ -}; -static const unsigned char cp1258_page03[40] = { - 0xcc, 0xec, 0x00, 0xde, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ - 0x00, 0xd2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ - 0x00, 0x00, 0x00, 0xf2, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ -}; -static const unsigned char cp1258_page20[48] = { - 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */ - 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */ - 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ - 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ - 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ -}; - -static int -cp1258_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x00c0) - c = wc; - else if (wc >= 0x00c0 && wc < 0x0118) - c = cp1258_page00[wc-0x00c0]; - else if (wc >= 0x0150 && wc < 0x01b8) - c = cp1258_page01[wc-0x0150]; - else if (wc >= 0x02c0 && wc < 0x02e0) - c = cp1258_page02[wc-0x02c0]; - else if (wc >= 0x0300 && wc < 0x0328) - c = cp1258_page03[wc-0x0300]; - else if (wc >= 0x0340 && wc < 0x0342) /* deprecated Vietnamese tone marks */ - c = cp1258_page03[wc-0x0340]; - else if (wc >= 0x2010 && wc < 0x2040) - c = cp1258_page20[wc-0x2010]; - else if (wc == 0x20ab) - c = 0xfe; - else if (wc == 0x20ac) - c = 0x80; - else if (wc == 0x2122) - c = 0x99; - if (c != 0) { - *r = c; - return 1; - } - /* Try canonical decomposition. */ - { - /* Binary search through viet_decomp_table. */ - unsigned int i1 = 0; - unsigned int i2 = sizeof(viet_decomp_table)/sizeof(viet_decomp_table[0])-1; - if (wc >= viet_decomp_table[i1].composed - && wc <= viet_decomp_table[i2].composed) { - unsigned int i; - for (;;) { - /* Here i2 - i1 > 0. */ - i = (i1+i2)>>1; - if (wc == viet_decomp_table[i].composed) - break; - if (wc < viet_decomp_table[i].composed) { - if (i1 == i) - return RET_ILUNI; - /* Here i1 < i < i2. */ - i2 = i; - } else { - /* Here i1 <= i < i2. */ - if (i1 != i) - i1 = i; - else { - /* Here i2 - i1 = 1. */ - i = i2; - if (wc == viet_decomp_table[i].composed) - break; - else - return RET_ILUNI; - } - } - } - /* Found a canonical decomposition. */ - wc = viet_decomp_table[i].base; - /* wc is one of 0x0020, 0x0041..0x005a, 0x0061..0x007a, 0x00a5, 0x00a8, - 0x00c2, 0x00c5..0x00c7, 0x00ca, 0x00cf, 0x00d3, 0x00d4, 0x00d6, - 0x00d8, 0x00da, 0x00dc, 0x00e2, 0x00e5..0x00e7, 0x00ea, 0x00ef, - 0x00f3, 0x00f4, 0x00f6, 0x00f8, 0x00fc, 0x0102, 0x0103, 0x01a0, - 0x01a1, 0x01af, 0x01b0. */ - if (wc < 0x0100) - c = wc; - else if (wc < 0x0118) - c = cp1258_page00[wc-0x00c0]; - else - c = cp1258_page01[wc-0x0150]; - if (n < 2) - return RET_TOOSMALL; - r[0] = c; - r[1] = cp1258_comb_table[viet_decomp_table[i].comb1]; - return 2; - } - } - return RET_ILUNI; -} diff --git a/lib/cp858.h b/lib/cp858.h deleted file mode 100644 index e3bb488c..00000000 --- a/lib/cp858.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * CP858 - */ - -static int -cp858_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - if (c < 0x80) - *pwc = (ucs4_t) c; - else if (c == 0xd5) - *pwc = 0x20ac; - else - *pwc = (ucs4_t) cp850_2uni[c-0x80]; - return 1; -} - -static int -cp858_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char c = 0; - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x00a0 && wc < 0x0100) - c = cp850_page00[wc-0x00a0]; - else if (wc == 0x0192) - c = 0x9f; - else if (wc == 0x2017) - c = 0xf2; - else if (wc == 0x20ac) - c = 0xd5; - else if (wc >= 0x2500 && wc < 0x25a8) - c = cp850_page25[wc-0x2500]; - if (c != 0) { - *r = c; - return 1; - } - return RET_ILUNI; -} diff --git a/lib/cp932.h b/lib/cp932.h deleted file mode 100644 index de59fa78..00000000 --- a/lib/cp932.h +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (C) 1999-2002, 2005, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * CP932 - */ - -/* - * Microsoft CP932 is a slightly extended version of SHIFT_JIS. - * The differences between the EASTASIA/JIS/SHIFTJIS.TXT and the - * VENDORS/MICSFT/WINDOWS/CP932.TXT tables found on ftp.unicode.org are - * as follows: - * - * 1. CP932 uses ASCII, not JISX0201 Roman. - * - * 2. Some characters in the JISX0208 range are defined differently: - * - * code SHIFTJIS.TXT CP932.TXT - * 0x815F 0x005C # REVERSE SOLIDUS 0xFF3C # FULLWIDTH REVERSE SOLIDUS - * 0x8160 0x301C # WAVE DASH 0xFF5E # FULLWIDTH TILDE - * 0x8161 0x2016 # DOUBLE VERTICAL LINE 0x2225 # PARALLEL TO - * 0x817C 0x2212 # MINUS SIGN 0xFF0D # FULLWIDTH HYPHEN-MINUS - * 0x8191 0x00A2 # CENT SIGN 0xFFE0 # FULLWIDTH CENT SIGN - * 0x8192 0x00A3 # POUND SIGN 0xFFE1 # FULLWIDTH POUND SIGN - * 0x81CA 0x00AC # NOT SIGN 0xFFE2 # FULLWIDTH NOT SIGN - * - * We don't implement the latter 6 of these changes, only the first one. - * SHIFTJIS.TXT makes more sense. However, as a compromise with user - * expectation, we implement the middle 5 of these changes in the - * Unicode to CP932 direction. We don't implement the last one at all, - * because it would collide with the mapping of 0xFA54. - * - * 3. A few new rows. See cp932ext.h. - * - * Many variants of CP932 (in GNU libc, JDK, OSF/1, Windows-2000, ICU) also - * add: - * - * 4. Private area mappings: - * - * code Unicode - * 0x{F0..F9}{40..7E,80..FC} U+E000..U+E757 - * - * We add them too because, although there are backward compatibility problems - * when a character from a private area is moved to an official Unicode code - * point, they are useful for some people in practice. - */ - -#include "cp932ext.h" - -/* - Conversion between SJIS codes (s1,s2) and JISX0208 codes (c1,c2): - Example. (s1,s2) = 0x8140, (c1,c2) = 0x2121. - 0x81 <= s1 <= 0x9F || 0xE0 <= s1 <= 0xEA, - 0x40 <= s2 <= 0x7E || 0x80 <= s2 <= 0xFC, - 0x21 <= c1 <= 0x74, 0x21 <= c2 <= 0x7E. - Invariant: - 94*2*(s1 < 0xE0 ? s1-0x81 : s1-0xC1) + (s2 < 0x80 ? s2-0x40 : s2-0x41) - = 94*(c1-0x21)+(c2-0x21) - Conversion (s1,s2) -> (c1,c2): - t1 := (s1 < 0xE0 ? s1-0x81 : s1-0xC1) - t2 := (s2 < 0x80 ? s2-0x40 : s2-0x41) - c1 := 2*t1 + (t2 < 0x5E ? 0 : 1) + 0x21 - c2 := (t2 < 0x5E ? t2 : t2-0x5E) + 0x21 - Conversion (c1,c2) -> (s1,s2): - t1 := (c1 - 0x21) >> 1 - t2 := ((c1 - 0x21) & 1) * 0x5E + (c2 - 0x21) - s1 := (t1 < 0x1F ? t1+0x81 : t1+0xC1) - s2 := (t2 < 0x3F ? t2+0x40 : t2+0x41) - */ - -static int -cp932_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - else if (c >= 0xa1 && c <= 0xdf) - return jisx0201_mbtowc(conv,pwc,s,n); - else { - unsigned char s1, s2; - s1 = c; - if ((s1 >= 0x81 && s1 <= 0x9f && s1 != 0x87) || (s1 >= 0xe0 && s1 <= 0xea)) { - if (n < 2) - return RET_TOOFEW(0); - s2 = s[1]; - if ((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0x80 && s2 <= 0xfc)) { - unsigned char t1 = (s1 < 0xe0 ? s1-0x81 : s1-0xc1); - unsigned char t2 = (s2 < 0x80 ? s2-0x40 : s2-0x41); - unsigned char buf[2]; - buf[0] = 2*t1 + (t2 < 0x5e ? 0 : 1) + 0x21; - buf[1] = (t2 < 0x5e ? t2 : t2-0x5e) + 0x21; - return jisx0208_mbtowc(conv,pwc,buf,2); - } - } else if ((s1 == 0x87) || (s1 >= 0xed && s1 <= 0xee) || (s1 >= 0xfa)) { - if (n < 2) - return RET_TOOFEW(0); - return cp932ext_mbtowc(conv,pwc,s,2); - } else if (s1 >= 0xf0 && s1 <= 0xf9) { - /* User-defined range. See - * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ - if (n < 2) - return RET_TOOFEW(0); - s2 = s[1]; - if ((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0x80 && s2 <= 0xfc)) { - *pwc = 0xe000 + 188*(s1 - 0xf0) + (s2 < 0x80 ? s2-0x40 : s2-0x41); - return 2; - } - } - return RET_ILSEQ; - } -} - -static int -cp932_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[2]; - int ret; - - /* Try ASCII. */ - ret = ascii_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - unsigned char c; - if (ret != 1) abort(); - c = buf[0]; - if (c < 0x80) { - r[0] = c; - return 1; - } - } - - /* Try JIS X 0201-1976 Katakana. */ - ret = jisx0201_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - unsigned char c; - if (ret != 1) abort(); - c = buf[0]; - if (c >= 0xa1 && c <= 0xdf) { - r[0] = c; - return 1; - } - } - - /* Try JIS X 0208-1990. */ - ret = jisx0208_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - unsigned char c1, c2; - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - c1 = buf[0]; - c2 = buf[1]; - if ((c1 >= 0x21 && c1 <= 0x74) && (c2 >= 0x21 && c2 <= 0x7e)) { - unsigned char t1 = (c1 - 0x21) >> 1; - unsigned char t2 = (((c1 - 0x21) & 1) ? 0x5e : 0) + (c2 - 0x21); - r[0] = (t1 < 0x1f ? t1+0x81 : t1+0xc1); - r[1] = (t2 < 0x3f ? t2+0x40 : t2+0x41); - return 2; - } - } - - /* Try CP932 extensions. */ - ret = cp932ext_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]; - r[1] = buf[1]; - return 2; - } - - /* User-defined range. See - * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ - if (wc >= 0xe000 && wc < 0xe758) { - unsigned char c1, c2; - if (n < 2) - return RET_TOOSMALL; - c1 = (unsigned int) (wc - 0xe000) / 188; - c2 = (unsigned int) (wc - 0xe000) % 188; - r[0] = c1+0xf0; - r[1] = (c2 < 0x3f ? c2+0x40 : c2+0x41); - return 2; - } - - /* Irreversible mappings. */ - if (wc == 0xff5e) { - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x81; - r[1] = 0x60; - return 2; - } - if (wc == 0x2225) { - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x81; - r[1] = 0x61; - return 2; - } - if (wc == 0xff0d) { - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x81; - r[1] = 0x7c; - return 2; - } - if (wc == 0xffe0) { - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x81; - r[1] = 0x91; - return 2; - } - if (wc == 0xffe1) { - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x81; - r[1] = 0x92; - return 2; - } - - return RET_ILUNI; -} diff --git a/lib/cp936.h b/lib/cp936.h deleted file mode 100644 index a4501b40..00000000 --- a/lib/cp936.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2005, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * CP936 - */ - -/* - * The IANA has CP936 as an alias of GBK. But GBK is an official Chinese - * specification, whereas CP936 is de-facto maintained by Microsoft. And, - * of course, Microsoft modified CP936 since 1999. - * - * The differences from GBK are: - * - * 1. A single character: - * - * code CP936.TXT - * 0x80 0x20AC # EURO SIGN - * - * Some variants of CP936 (in JDK, Windows-2000, ICU) also add: - * - * 2. Private area mappings: - * - * code Unicode - * 0x{A1..A2}{40..7E,80..A0} U+E4C6..U+E585 - * 0x{AA..AF,F8..FE}{A1..FE} U+E000..U+E4C5 - * - * We add them too because, although there are backward compatibility problems - * when a character from a private area is moved to an official Unicode code - * point, they are useful for some people in practice. - */ - -static int -cp936_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - /* Try GBK first. */ - { - int ret = ces_gbk_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - } - /* Then handle the additional mappings. */ - { - unsigned char c = *s; - if (c == 0x80) { - *pwc = 0x20ac; - return 1; - } - /* User-defined characters */ - if (c >= 0xa1 && c <= 0xa2) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xa1)) { - *pwc = 0xe4c6 + 96 * (c - 0xa1) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); - return 2; - } - } - } else if ((c >= 0xaa && c < 0xb0) || (c >= 0xf8 && c < 0xff)) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 < 0xff) { - *pwc = 0xe000 + 94 * (c - (c >= 0xf8 ? 0xf2 : 0xaa)) + (c2 - 0xa1); - return 2; - } - } - } - } - return RET_ILSEQ; -} - -static int -cp936_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - /* Try GBK first. */ - { - int ret = ces_gbk_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - } - /* Then handle the additional mappings. */ - if (wc >= 0xe000 && wc < 0xe586) { - /* User-defined characters */ - if (n < 2) - return RET_TOOFEW(0); - if (wc < 0xe4c6) { - unsigned int i = wc - 0xe000; - unsigned int c1 = i / 94; - unsigned int c2 = i % 94; - r[0] = c1 + (c1 < 6 ? 0xaa : 0xf2); - r[1] = c2 + 0xa1; - return 2; - } else { - unsigned int i = wc - 0xe4c6; - unsigned int c1 = i / 96; - unsigned int c2 = i % 96; - r[0] = c1 + 0xa1; - r[1] = c2 + (c2 < 0x3f ? 0x40 : 0x41); - return 2; - } - } else if (wc == 0x20ac) { - r[0] = 0x80; - return 1; - } - return RET_ILUNI; -} diff --git a/lib/cp949.h b/lib/cp949.h deleted file mode 100644 index 5e7cdd12..00000000 --- a/lib/cp949.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2005, 2007, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * CP949 is EUC-KR, extended with UHC (Unified Hangul Code). - * - * Some variants of CP949 (in JDK, Windows-2000, ICU) also add: - * - * 2. Private area mappings: - * - * code Unicode - * 0xC9{A1..FE} U+E000..U+E05D - * 0xFE{A1..FE} U+E05E..U+E0BB - * - * We add them too because, although there are backward compatibility problems - * when a character from a private area is moved to an official Unicode code - * point, they are useful for some people in practice. - */ - -#include "uhc_1.h" -#include "uhc_2.h" - -static int -cp949_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - /* Code set 0 (ASCII) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* UHC part 1 */ - if (c >= 0x81 && c <= 0xa0) - return uhc_1_mbtowc(conv,pwc,s,n); - if (c >= 0xa1 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c2 < 0xa1) - /* UHC part 2 */ - return uhc_2_mbtowc(conv,pwc,s,n); - else if (c2 < 0xff && !(c == 0xa2 && c2 == 0xe8)) { - /* Code set 1 (KS C 5601-1992, now KS X 1001:1998) */ - unsigned char buf[2]; - int ret; - buf[0] = c-0x80; buf[1] = c2-0x80; - ret = ksc5601_mbtowc(conv,pwc,buf,2); - if (ret != RET_ILSEQ) - return ret; - /* User-defined characters */ - if (c == 0xc9) { - *pwc = 0xe000 + (c2 - 0xa1); - return 2; - } - if (c == 0xfe) { - *pwc = 0xe05e + (c2 - 0xa1); - return 2; - } - } - } - } - return RET_ILSEQ; -} - -static int -cp949_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[2]; - int ret; - - /* Code set 0 (ASCII) */ - ret = ascii_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - /* Code set 1 (KS C 5601-1992, now KS X 1001:1998) */ - if (wc != 0x327e) { - ret = ksc5601_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]+0x80; - r[1] = buf[1]+0x80; - return 2; - } - } - - /* UHC */ - if (wc >= 0xac00 && wc < 0xd7a4) { - if (wc < 0xc8a5) - return uhc_1_wctomb(conv,r,wc,n); - else - return uhc_2_wctomb(conv,r,wc,n); - } - - /* User-defined characters */ - if (wc >= 0xe000 && wc < 0xe0bc) { - if (n < 2) - return RET_TOOSMALL; - if (wc < 0xe05e) { - r[0] = 0xc9; - r[1] = wc - 0xe000 + 0xa1; - } else { - r[0] = 0xfe; - r[1] = wc - 0xe05e + 0xa1; - } - return 2; - } - - return RET_ILUNI; -} diff --git a/lib/cp950.h b/lib/cp950.h deleted file mode 100644 index 6c007023..00000000 --- a/lib/cp950.h +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2005, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * CP950 - */ - -/* - * Microsoft CP950 is a slightly extended and slightly modified version of - * BIG5. The differences between the EASTASIA/OTHER/BIG5.TXT and - * VENDORS/MICSFT/WINDOWS/CP950.TXT tables found on ftp.unicode.org are - * as follows: - * - * 1. Some characters in the BIG5 range are defined differently: - * - * code BIG5.TXT CP950.TXT - * 0xA145 0x2022 # BULLET 0x2027 # HYPHENATION POINT - * 0xA14E 0xFF64 # HALFWIDTH IDEOGRAPHIC COMMA - * 0xFE51 # SMALL IDEOGRAPHIC COMMA - * 0xA15A --- 0x2574 # BOX DRAWINGS LIGHT LEFT - * 0xA1C2 0x203E # OVERLINE 0x00AF # MACRON - * 0xA1C3 --- 0xFFE3 # FULLWIDTH MACRON - * 0xA1C5 --- 0x02CD # MODIFIER LETTER LOW MACRON - * 0xA1E3 0x223C # TILDE OPERATOR 0xFF5E # FULLWIDTH TILDE - * 0xA1F2 0x2641 # EARTH 0x2295 # CIRCLED PLUS - * 0xA1F3 0x2609 # SUN 0x2299 # CIRCLED DOT OPERATOR - * 0xA1FE --- 0xFF0F # FULLWIDTH SOLIDUS - * 0xA240 --- 0xFF3C # FULLWIDTH REVERSE SOLIDUS - * 0xA241 0xFF0F # FULLWIDTH SOLIDUS 0x2215 # DIVISION SLASH - * 0xA242 0xFF3C # FULLWIDTH REVERSE SOLIDUS - * 0xFE68 # SMALL REVERSE SOLIDUS - * 0xA244 0x00A5 # YEN SIGN 0xFFE5 # FULLWIDTH YEN SIGN - * 0xA246 0x00A2 # CENT SIGN 0xFFE0 # FULLWIDTH CENT SIGN - * 0xA247 0x00A3 # POUND SIGN 0xFFE1 # FULLWIDTH POUND SIGN - * 0xA2CC --- 0x5341 - * 0xA2CE --- 0x5345 - * - * 2. A small new row. See cp950ext.h. - * - * 3. CP950.TXT is lacking the range 0xC6A1..0xC7FC (Hiragana, Katakana, - * Cyrillic, circled digits, parenthesized digits). - * - * We implement this omission, because said range is marked "uncertain" - * in the unicode.org BIG5 table. - * - * The table found on Microsoft's website furthermore adds: - * - * 4. A single character: - * - * code CP950.TXT - * 0xA3E1 0x20AC # EURO SIGN - * - * Many variants of BIG5 or CP950 (in JDK, Solaris, OSF/1, Windows-2000, ICU, - * as well as our BIG5-2003 converter) also add: - * - * 5. Private area mappings: - * - * code Unicode - * 0x{81..8D}{40..7E,A1..FE} U+EEB8..U+F6B0 - * 0x{8E..A0}{40..7E,A1..FE} U+E311..U+EEB7 - * 0x{FA..FE}{40..7E,A1..FE} U+E000..U+E310 - * - * We add them too because, although there are backward compatibility problems - * when a character from a private area is moved to an official Unicode code - * point, they are useful for some people in practice. - */ - -static const unsigned short cp950_2uni_pagea1[314] = { - /* 0xa1 */ - 0x3000, 0xff0c, 0x3001, 0x3002, 0xff0e, 0x2027, 0xff1b, 0xff1a, - 0xff1f, 0xff01, 0xfe30, 0x2026, 0x2025, 0xfe50, 0xfe51, 0xfe52, - 0x00b7, 0xfe54, 0xfe55, 0xfe56, 0xfe57, 0xff5c, 0x2013, 0xfe31, - 0x2014, 0xfe33, 0x2574, 0xfe34, 0xfe4f, 0xff08, 0xff09, 0xfe35, - 0xfe36, 0xff5b, 0xff5d, 0xfe37, 0xfe38, 0x3014, 0x3015, 0xfe39, - 0xfe3a, 0x3010, 0x3011, 0xfe3b, 0xfe3c, 0x300a, 0x300b, 0xfe3d, - 0xfe3e, 0x3008, 0x3009, 0xfe3f, 0xfe40, 0x300c, 0x300d, 0xfe41, - 0xfe42, 0x300e, 0x300f, 0xfe43, 0xfe44, 0xfe59, 0xfe5a, 0xfe5b, - 0xfe5c, 0xfe5d, 0xfe5e, 0x2018, 0x2019, 0x201c, 0x201d, 0x301d, - 0x301e, 0x2035, 0x2032, 0xff03, 0xff06, 0xff0a, 0x203b, 0x00a7, - 0x3003, 0x25cb, 0x25cf, 0x25b3, 0x25b2, 0x25ce, 0x2606, 0x2605, - 0x25c7, 0x25c6, 0x25a1, 0x25a0, 0x25bd, 0x25bc, 0x32a3, 0x2105, - 0x00af, 0xffe3, 0xff3f, 0x02cd, 0xfe49, 0xfe4a, 0xfe4d, 0xfe4e, - 0xfe4b, 0xfe4c, 0xfe5f, 0xfe60, 0xfe61, 0xff0b, 0xff0d, 0x00d7, - 0x00f7, 0x00b1, 0x221a, 0xff1c, 0xff1e, 0xff1d, 0x2266, 0x2267, - 0x2260, 0x221e, 0x2252, 0x2261, 0xfe62, 0xfe63, 0xfe64, 0xfe65, - 0xfe66, 0xff5e, 0x2229, 0x222a, 0x22a5, 0x2220, 0x221f, 0x22bf, - 0x33d2, 0x33d1, 0x222b, 0x222e, 0x2235, 0x2234, 0x2640, 0x2642, - 0x2295, 0x2299, 0x2191, 0x2193, 0x2190, 0x2192, 0x2196, 0x2197, - 0x2199, 0x2198, 0x2225, 0x2223, 0xff0f, - /* 0xa2 */ - 0xff3c, 0x2215, 0xfe68, 0xff04, 0xffe5, 0x3012, 0xffe0, 0xffe1, - 0xff05, 0xff20, 0x2103, 0x2109, 0xfe69, 0xfe6a, 0xfe6b, 0x33d5, - 0x339c, 0x339d, 0x339e, 0x33ce, 0x33a1, 0x338e, 0x338f, 0x33c4, - 0x00b0, 0x5159, 0x515b, 0x515e, 0x515d, 0x5161, 0x5163, 0x55e7, - 0x74e9, 0x7cce, 0x2581, 0x2582, 0x2583, 0x2584, 0x2585, 0x2586, - 0x2587, 0x2588, 0x258f, 0x258e, 0x258d, 0x258c, 0x258b, 0x258a, - 0x2589, 0x253c, 0x2534, 0x252c, 0x2524, 0x251c, 0x2594, 0x2500, - 0x2502, 0x2595, 0x250c, 0x2510, 0x2514, 0x2518, 0x256d, 0x256e, - 0x2570, 0x256f, 0x2550, 0x255e, 0x256a, 0x2561, 0x25e2, 0x25e3, - 0x25e5, 0x25e4, 0x2571, 0x2572, 0x2573, 0xff10, 0xff11, 0xff12, - 0xff13, 0xff14, 0xff15, 0xff16, 0xff17, 0xff18, 0xff19, 0x2160, - 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, - 0x2169, 0x3021, 0x3022, 0x3023, 0x3024, 0x3025, 0x3026, 0x3027, - 0x3028, 0x3029, 0x5341, 0x5344, 0x5345, 0xff21, 0xff22, 0xff23, - 0xff24, 0xff25, 0xff26, 0xff27, 0xff28, 0xff29, 0xff2a, 0xff2b, - 0xff2c, 0xff2d, 0xff2e, 0xff2f, 0xff30, 0xff31, 0xff32, 0xff33, - 0xff34, 0xff35, 0xff36, 0xff37, 0xff38, 0xff39, 0xff3a, 0xff41, - 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48, 0xff49, - 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50, 0xff51, - 0xff52, 0xff53, 0xff54, 0xff55, 0xff56, -}; - -#include "cp950ext.h" - -static int -cp950_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - /* Code set 0 (ASCII) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (BIG5 extended) */ - if (c >= 0x81 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) { - if (c >= 0xa1) { - if (c < 0xa3) { - unsigned int i = 157 * (c - 0xa1) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); - unsigned short wc = cp950_2uni_pagea1[i]; - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; - } - } - if (!((c == 0xc6 && c2 >= 0xa1) || c == 0xc7)) { - int ret = big5_mbtowc(conv,pwc,s,2); - if (ret != RET_ILSEQ) - return ret; - } - if (c == 0xa3 && c2 == 0xe1) { - *pwc = 0x20ac; - return 2; - } - if (c >= 0xfa) { - /* User-defined characters */ - *pwc = 0xe000 + 157 * (c - 0xfa) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); - return 2; - } - } else { - /* 0x81 <= c < 0xa1. */ - /* User-defined characters */ - *pwc = (c >= 0x8e ? 0xdb18 : 0xeeb8) + 157 * (c - 0x81) - + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40)); - return 2; - } - } - } - if (c == 0xf9) { - int ret = cp950ext_mbtowc(conv,pwc,s,2); - if (ret != RET_ILSEQ) - return ret; - } - } - return RET_ILSEQ; -} - -static int -cp950_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[2]; - int ret; - - /* Code set 0 (ASCII) */ - ret = ascii_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - /* Code set 1 (BIG5 extended) */ - switch (wc >> 8) { - case 0x00: - if (wc == 0x00af) { buf[0] = 0xa1; buf[1] = 0xc2; ret = 2; break; } - if (wc == 0x00a2 || wc == 0x00a3 || wc == 0x00a4) - return RET_ILUNI; - break; - case 0x02: - if (wc == 0x02cd) { buf[0] = 0xa1; buf[1] = 0xc5; ret = 2; break; } - break; - case 0x20: - if (wc == 0x2027) { buf[0] = 0xa1; buf[1] = 0x45; ret = 2; break; } - if (wc == 0x20ac) { buf[0] = 0xa3; buf[1] = 0xe1; ret = 2; break; } - if (wc == 0x2022 || wc == 0x203e) - return RET_ILUNI; - break; - case 0x22: - if (wc == 0x2215) { buf[0] = 0xa2; buf[1] = 0x41; ret = 2; break; } - if (wc == 0x2295) { buf[0] = 0xa1; buf[1] = 0xf2; ret = 2; break; } - if (wc == 0x2299) { buf[0] = 0xa1; buf[1] = 0xf3; ret = 2; break; } - if (wc == 0x223c) - return RET_ILUNI; - break; - case 0x25: - if (wc == 0x2574) { buf[0] = 0xa1; buf[1] = 0x5a; ret = 2; break; } - break; - case 0x26: - if (wc == 0x2609 || wc == 0x2641) - return RET_ILUNI; - break; - case 0xe0: case 0xe1: case 0xe2: case 0xe3: case 0xe4: case 0xe5: - case 0xe6: case 0xe7: case 0xe8: case 0xe9: case 0xea: case 0xeb: - case 0xec: case 0xed: case 0xee: case 0xef: case 0xf0: case 0xf1: - case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf6: - { - /* User-defined characters */ - unsigned int i = wc - 0xe000; - if (i < 5809) { - unsigned int c1 = i / 157; - unsigned int c2 = i % 157; - buf[0] = c1 + (c1 < 5 ? 0xfa : c1 < 24 ? 0x89 : 0x69); - buf[1] = c2 + (c2 < 0x3f ? 0x40 : 0x62); - ret = 2; - break; - } - } - break; - case 0xfe: - if (wc == 0xfe51) { buf[0] = 0xa1; buf[1] = 0x4e; ret = 2; break; } - if (wc == 0xfe68) { buf[0] = 0xa2; buf[1] = 0x42; ret = 2; break; } - break; - case 0xff: - if (wc == 0xff0f) { buf[0] = 0xa1; buf[1] = 0xfe; ret = 2; break; } - if (wc == 0xff3c) { buf[0] = 0xa2; buf[1] = 0x40; ret = 2; break; } - if (wc == 0xff5e) { buf[0] = 0xa1; buf[1] = 0xe3; ret = 2; break; } - if (wc == 0xffe0) { buf[0] = 0xa2; buf[1] = 0x46; ret = 2; break; } - if (wc == 0xffe1) { buf[0] = 0xa2; buf[1] = 0x47; ret = 2; break; } - if (wc == 0xffe3) { buf[0] = 0xa1; buf[1] = 0xc3; ret = 2; break; } - if (wc == 0xffe5) { buf[0] = 0xa2; buf[1] = 0x44; ret = 2; break; } - if (wc == 0xff64) - return RET_ILUNI; - break; - } - if (ret == RET_ILUNI) - ret = big5_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (!((buf[0] == 0xc6 && buf[1] >= 0xa1) || buf[0] == 0xc7)) { - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]; - r[1] = buf[1]; - return 2; - } - } - ret = cp950ext_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]; - r[1] = buf[1]; - return 2; - } - - return RET_ILUNI; -} diff --git a/lib/dec_hanyu.h b/lib/dec_hanyu.h deleted file mode 100644 index e4e7018b..00000000 --- a/lib/dec_hanyu.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2001, 2005, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * DEC-HANYU - */ - -static int -dec_hanyu_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - /* Code set 0 (ASCII) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (CNS 11643-1992 Plane 1), - Code set 2 (CNS 11643-1992 Plane 2), - Code set 3 (CNS 11643-1992 Plane 3) */ - if (c >= 0xa1 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c == 0xc2 && c2 == 0xcb) { - if (n < 4) - return RET_TOOFEW(0); - if (s[2] >= 0xa1 && s[2] < 0xff && s[3] >= 0xa1 && s[3] < 0xff) { - unsigned char buf[2]; - int ret; - buf[0] = s[2]-0x80; buf[1] = s[3]-0x80; - ret = cns11643_3_mbtowc(conv,pwc,buf,2); - if (ret != RET_ILSEQ) { - if (ret != 2) abort(); - return 4; - } - } - } else if (c2 >= 0xa1 && c2 < 0xff) { - if (c != 0xc2 || c2 < 0xc2) { - unsigned char buf[2]; - buf[0] = c-0x80; buf[1] = c2-0x80; - return cns11643_1_mbtowc(conv,pwc,buf,2); - } - } else if (c2 >= 0x21 && c2 < 0x7f) { - unsigned char buf[2]; - buf[0] = c-0x80; buf[1] = c2; - return cns11643_2_mbtowc(conv,pwc,buf,2); - } - } - } - return RET_ILSEQ; -} - -static int -dec_hanyu_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[3]; - int ret; - - /* Code set 0 (ASCII) */ - ret = ascii_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - ret = cns11643_wctomb(conv,buf,wc,3); - if (ret != RET_ILUNI) { - if (ret != 3) abort(); - - /* Code set 1 (CNS 11643-1992 Plane 1) */ - if (buf[0] == 1 && (buf[1] != 0x42 || buf[2] < 0x42)) { - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[1]+0x80; - r[1] = buf[2]+0x80; - return 2; - } - - /* Code set 2 (CNS 11643-1992 Plane 2) */ - if (buf[0] == 2) { - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[1]+0x80; - r[1] = buf[2]; - return 2; - } - - /* Code set 3 (CNS 11643-1992 Plane 3) */ - if (buf[0] == 3) { - if (n < 4) - return RET_TOOSMALL; - r[0] = 0xc2; - r[1] = 0xcb; - r[2] = buf[1]+0x80; - r[3] = buf[2]+0x80; - return 4; - } - } - - return RET_ILUNI; -} diff --git a/lib/dec_kanji.h b/lib/dec_kanji.h deleted file mode 100644 index 7f506021..00000000 --- a/lib/dec_kanji.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * DEC-KANJI - */ - -static int -dec_kanji_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - /* Code set 0 (ASCII or JIS X 0201-1976 Roman) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (JIS X 0208) */ - if (c >= 0xa1 && c < 0xf5) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 < 0xff) { - unsigned char buf[2]; - buf[0] = c-0x80; buf[1] = c2-0x80; - return jisx0208_mbtowc(conv,pwc,buf,2); - } - } - } - return RET_ILSEQ; -} - -static int -dec_kanji_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[2]; - int ret; - - /* Code set 0 (ASCII or JIS X 0201-1976 Roman) */ - ret = ascii_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - /* Code set 1 (JIS X 0208) */ - ret = jisx0208_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]+0x80; - r[1] = buf[1]+0x80; - return 2; - } - - return RET_ILUNI; -} diff --git a/lib/encoding.h b/lib/encoding.h new file mode 100644 index 00000000..b6086207 --- /dev/null +++ b/lib/encoding.h @@ -0,0 +1,38 @@ +/** + * @file encoding.h + * @brief Encoding structure definition. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _ENCODING_H_ +#define _ENCODING_H_ + +#include "reiconv_defines.h" + +/** + * @brief Table of all supported encodings. + */ +struct encoding +{ + struct mbtowc_funcs ifuncs; // Conversion multibyte -> unicode + struct wctomb_funcs ofuncs; // Conversion unicode -> multibyte +}; + +#endif /* _ENCODING_H_ */ diff --git a/lib/ucs4internal.h b/lib/encoding_indexes.h similarity index 52% rename from lib/ucs4internal.h rename to lib/encoding_indexes.h index ba50d5b0..ec61d773 100644 --- a/lib/ucs4internal.h +++ b/lib/encoding_indexes.h @@ -1,5 +1,10 @@ +/** + * @file encoding_indexes.h + * @brief All encoding's internal indexes. + * @copyright Copyright (C) 1999-2002, 2004-2011, 2016, 2022-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,30 +18,25 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * UCS-4-INTERNAL = UCS-4 with machine dependent endianness and alignment - */ +#ifndef _ENCODING_INDEXES_H_ +#define _ENCODING_INDEXES_H_ -static int -ucs4internal_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - if (n >= 4) { - *pwc = *(const unsigned int *)s; - return 4; - } - return RET_TOOFEW(0); -} +#define DEFENCODING(xxx_names, xxx, xxx_index, xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2) ei_##xxx, +#define DEFCODEPAGE(codepage, xxx) +#define DEFINDEX(alias, index) -static int -ucs4internal_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +enum { - if (n >= 4) { - *(unsigned int *)r = wc; - return 4; - } else - return RET_TOOSMALL; -} +#include "encodings.h.snippet" + ei_end +}; + +#undef DEFINDEX +#undef DEFCODEPAGE +#undef DEFENCODING + +#endif /* _ENCODING_INDEXES_H_ */ diff --git a/lib/encodings.def b/lib/encodings.def deleted file mode 100644 index 30524a40..00000000 --- a/lib/encodings.def +++ /dev/null @@ -1,1158 +0,0 @@ -/* Copyright (C) 1999-2011 Free Software Foundation, Inc. - This file is part of the cppp-reiconv library. - - The cppp-reiconv library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 3 - of the License, or (at your option) any later version. - - The cppp-reiconv library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the cppp-reiconv library; see the file COPYING. - If not, see . */ - -/* The list of all system independent user-visible encodings. */ - -/* By convention, an encoding named FOOBAR or FOO_BAR or FOO-BAR is defined - in a file named "foobar.h" through the functions foobar_mbtowc and - foobar_wctomb (and possibly foobar_reset). */ - -/* DEFENCODING(( name, alias1, ..., ), - xxx, - { xxx_mbtowc, xxx_flushwc }, - { xxx_wctomb, xxx_reset }) - defines an encoding with the given name and aliases. (There is no - difference between a name and an alias. By convention, the name is chosen - as the preferred MIME name or the standard name.) - All names and aliases must be in ASCII. Case is not significant, but - for the "cs*" aliases mixed case is preferred, otherwise UPPERCASE is - preferred. For all names and aliases, note where it comes from. - xxx is the name as used in the C code (lowercase). - */ - - -DEFENCODING(( "US-ASCII", /* IANA */ - "ASCII", /* IANA, JDK 1.1 */ - "ISO646-US", /* IANA */ - "ISO_646.IRV:1991", /* IANA */ - "ISO-IR-6", /* IANA */ - "ANSI_X3.4-1968", /* IANA */ - "ANSI_X3.4-1986", /* IANA */ - "CP367", /* IANA */ - "IBM367", /* IANA */ - "US", /* IANA */ - "csASCII", /* IANA */ - /*"ISO646.1991-IRV", X11R6.4 */ - ), - 367, - ascii, - { ascii_mbtowc, NULL }, { ascii_wctomb, NULL }) -#ifdef USE_SOLARIS_ALIASES -DEFALIAS( "646", /* Solaris */ - ascii) -#endif - -/* General multi-byte encodings */ - -DEFENCODING(( "UTF-8", /* IANA, RFC 2279 */ - /*"UTF8", JDK 1.1 */ - /*"CP65001", Windows */ - ), - 65001, - utf8, - { utf8_mbtowc, NULL }, { utf8_wctomb, NULL }) -#ifdef USE_HPUX_ALIASES -DEFALIAS( "UTF8", /* HP-UX */ - utf8) -#endif - -DEFENCODING(( "UCS-2", /* glibc */ - "ISO-10646-UCS-2", /* IANA */ - "csUnicode", /* IANA */ - ), - -1, - ucs2, - { ucs2_mbtowc, NULL }, { ucs2_wctomb, NULL }) - -DEFENCODING(( "UCS-2BE", /* glibc */ - "UNICODEBIG", /* glibc */ - "UNICODE-1-1", /* IANA */ - "csUnicode11", /* IANA */ - /*"CP1201", Windows */ - ), - -1, - ucs2be, - { ucs2be_mbtowc, NULL }, { ucs2be_wctomb, NULL }) - -DEFENCODING(( "UCS-2LE", /* glibc */ - "UNICODELITTLE", /* glibc */ - /*"CP1200", Windows */ - ), - -1, - ucs2le, - { ucs2le_mbtowc, NULL }, { ucs2le_wctomb, NULL }) - -DEFENCODING(( "UCS-4", /* glibc */ - "ISO-10646-UCS-4", /* IANA */ - "csUCS4", /* IANA */ - ), - -1, - ucs4, - { ucs4_mbtowc, NULL }, { ucs4_wctomb, NULL }) - -DEFENCODING(( "UCS-4BE", /* glibc */ - /*"CP12001", Windows */ - ), - -1, - ucs4be, - { ucs4be_mbtowc, NULL }, { ucs4be_wctomb, NULL }) - -DEFENCODING(( "UCS-4LE", /* glibc */ - /*"CP12000", Windows */ - ), - -1, - ucs4le, - { ucs4le_mbtowc, NULL }, { ucs4le_wctomb, NULL }) - -DEFENCODING(( "UTF-16", /* IANA, RFC 2781 */ - ), - -1, /* MS-Windows Use little endian, so CP1200 means UTF-16LE */ - utf16, - { utf16_mbtowc, NULL }, { utf16_wctomb, NULL }) - -DEFENCODING(( "UTF-16BE", /* IANA, RFC 2781 */ - ), - 1201, - utf16be, - { utf16be_mbtowc, NULL }, { utf16be_wctomb, NULL }) - -DEFENCODING(( "UTF-16LE", /* IANA, RFC 2781 */ - ), - 1200, - utf16le, - { utf16le_mbtowc, NULL }, { utf16le_wctomb, NULL }) - -DEFENCODING(( "UTF-32", /* IANA, Unicode 3.1 */ - ), - -1, - utf32, - { utf32_mbtowc, NULL }, { utf32_wctomb, NULL }) - -DEFENCODING(( "UTF-32BE", /* IANA, Unicode 3.1 */ - ), - 12001, - utf32be, - { utf32be_mbtowc, NULL }, { utf32be_wctomb, NULL }) - -DEFENCODING(( "UTF-32LE", /* IANA, Unicode 3.1 */ - ), - 12000, - utf32le, - { utf32le_mbtowc, NULL }, { utf32le_wctomb, NULL }) - -DEFENCODING(( "UTF-7", /* IANA, RFC 2152 */ - "UNICODE-1-1-UTF-7", /* IANA, RFC 1642 */ - "csUnicode11UTF7", /* IANA */ - /*"CP65000", Windows */ - ), - 65000, - utf7, - { utf7_mbtowc, NULL }, { utf7_wctomb, utf7_reset }) - -DEFENCODING(( "UCS-2-INTERNAL", /* libiconv */ - ), - -1, - ucs2internal, - { ucs2internal_mbtowc, NULL }, { ucs2internal_wctomb, NULL }) - -DEFENCODING(( "UCS-2-SWAPPED", /* libiconv */ - ), - -1, - ucs2swapped, - { ucs2swapped_mbtowc, NULL }, { ucs2swapped_wctomb, NULL }) - -DEFENCODING(( "UCS-4-INTERNAL", /* libiconv */ - ), - -1, - ucs4internal, - { ucs4internal_mbtowc, NULL },{ ucs4internal_wctomb, NULL }) - -DEFENCODING(( "UCS-4-SWAPPED", /* libiconv */ - ), - -1, - ucs4swapped, - { ucs4swapped_mbtowc, NULL }, { ucs4swapped_wctomb, NULL }) - -DEFENCODING(( "C99", - ), - -1, - c99, - { c99_mbtowc, NULL }, { c99_wctomb, NULL }) - -DEFENCODING(( "JAVA", - ), - -1, - java, - { java_mbtowc, NULL }, { java_wctomb, NULL }) - -/* Standard 8-bit encodings */ - -DEFENCODING(( "ISO-8859-1", /* IANA */ - "ISO_8859-1", /* IANA */ - "ISO_8859-1:1987", /* IANA */ - "ISO-IR-100", /* IANA */ - "CP819", /* IANA */ - "IBM819", /* IANA */ - "LATIN1", /* IANA */ - "L1", /* IANA */ - "csISOLatin1", /* IANA */ - "ISO8859-1", /* X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */ - /*"ISO8859_1", JDK 1.1 */ - /*"CP28591", Windows */ - ), - 28591, - iso8859_1, - { iso8859_1_mbtowc, NULL }, { iso8859_1_wctomb, NULL }) -#ifdef USE_HPUX_ALIASES -DEFALIAS( "ISO88591", /* HP-UX */ - iso8859_1) -#endif - -DEFENCODING(( "ISO-8859-2", /* IANA */ - "ISO_8859-2", /* IANA */ - "ISO_8859-2:1987", /* IANA */ - "ISO-IR-101", /* IANA */ - "LATIN2", /* IANA */ - "L2", /* IANA */ - "csISOLatin2", /* IANA */ - "ISO8859-2", /* X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */ - /*"ISO8859_2", JDK 1.1 */ - /*"CP28592", Windows */ - ), - 28592, - iso8859_2, - { iso8859_2_mbtowc, NULL }, { iso8859_2_wctomb, NULL }) -#ifdef USE_HPUX_ALIASES -DEFALIAS( "ISO88592", /* HP-UX */ - iso8859_2) -#endif - -DEFENCODING(( "ISO-8859-3", /* IANA */ - "ISO_8859-3", /* IANA */ - "ISO_8859-3:1988", /* IANA */ - "ISO-IR-109", /* IANA */ - "LATIN3", /* IANA */ - "L3", /* IANA */ - "csISOLatin3", /* IANA */ - "ISO8859-3", /* X11R6.4, glibc, FreeBSD, Solaris */ - /*"ISO8859_3", JDK 1.1 */ - /*"CP28593", Windows */ - ), - 28593, - iso8859_3, - { iso8859_3_mbtowc, NULL }, { iso8859_3_wctomb, NULL }) - -DEFENCODING(( "ISO-8859-4", /* IANA */ - "ISO_8859-4", /* IANA */ - "ISO_8859-4:1988", /* IANA */ - "ISO-IR-110", /* IANA */ - "LATIN4", /* IANA */ - "L4", /* IANA */ - "csISOLatin4", /* IANA */ - "ISO8859-4", /* X11R6.4, glibc, FreeBSD, OSF/1, Solaris */ - /*"ISO8859_4", JDK 1.1 */ - /*"CP28594", Windows */ - ), - 28594, - iso8859_4, - { iso8859_4_mbtowc, NULL }, { iso8859_4_wctomb, NULL }) - -DEFENCODING(( "ISO-8859-5", /* IANA */ - "ISO_8859-5", /* IANA */ - "ISO_8859-5:1988", /* IANA */ - "ISO-IR-144", /* IANA */ - "CYRILLIC", /* IANA */ - "csISOLatinCyrillic", /* IANA */ - "ISO8859-5", /* X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */ - /*"ISO8859_5", JDK 1.1 */ - /*"CP28595", Windows */ - ), - 28595, - iso8859_5, - { iso8859_5_mbtowc, NULL }, { iso8859_5_wctomb, NULL }) -#ifdef USE_HPUX_ALIASES -DEFALIAS( "ISO88595", /* HP-UX */ - iso8859_5) -#endif - -DEFENCODING(( "ISO-8859-6", /* IANA */ - "ISO_8859-6", /* IANA */ - "ISO_8859-6:1987", /* IANA */ - "ISO-IR-127", /* IANA */ - "ECMA-114", /* IANA */ - "ASMO-708", /* IANA */ - "ARABIC", /* IANA */ - "csISOLatinArabic", /* IANA */ - "ISO8859-6", /* X11R6.4, glibc, FreeBSD, AIX, Solaris */ - /*"ISO8859_6", JDK 1.1 */ - /*"CP28596", Windows */ - ), - 28596, - iso8859_6, - { iso8859_6_mbtowc, NULL }, { iso8859_6_wctomb, NULL }) -#ifdef USE_HPUX_ALIASES -DEFALIAS( "ISO88596", /* HP-UX */ - iso8859_6) -#endif - -DEFENCODING(( "ISO-8859-7", /* IANA, RFC 1947 */ - "ISO_8859-7", /* IANA */ - "ISO_8859-7:1987", /* IANA */ - "ISO_8859-7:2003", - "ISO-IR-126", /* IANA */ - "ECMA-118", /* IANA */ - "ELOT_928", /* IANA */ - "GREEK8", /* IANA */ - "GREEK", /* IANA */ - "csISOLatinGreek", /* IANA */ - "ISO8859-7", /* X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */ - /*"ISO8859_7", JDK 1.1 */ - /*"CP28597", Windows */ - ), - 28597, - iso8859_7, - { iso8859_7_mbtowc, NULL }, { iso8859_7_wctomb, NULL }) -#ifdef USE_HPUX_ALIASES -DEFALIAS( "ISO88597", /* HP-UX */ - iso8859_7) -#endif - -DEFENCODING(( "ISO-8859-8", /* IANA */ - "ISO_8859-8", /* IANA */ - "ISO_8859-8:1988", /* IANA */ - "ISO-IR-138", /* IANA */ - "HEBREW", /* IANA */ - "csISOLatinHebrew", /* IANA */ - "ISO8859-8", /* X11R6.4, glibc, FreeBSD, AIX, OSF/1, Solaris */ - /*"ISO8859_8", JDK 1.1 */ - /*"CP28598", Windows */ - /*"CP38598", Windows */ - ), - 28598, - iso8859_8, - { iso8859_8_mbtowc, NULL }, { iso8859_8_wctomb, NULL }) -#ifdef USE_HPUX_ALIASES -DEFALIAS( "ISO88598", /* HP-UX */ - iso8859_8) -#endif - -DEFENCODING(( "ISO-8859-9", /* IANA */ - "ISO_8859-9", /* IANA */ - "ISO_8859-9:1989", /* IANA */ - "ISO-IR-148", /* IANA */ - "LATIN5", /* IANA */ - "L5", /* IANA */ - "csISOLatin5", /* IANA */ - "ISO8859-9", /* X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */ - /*"ISO8859_9", JDK 1.1 */ - /*"CP28599", Windows */ - ), - 28599, - iso8859_9, - { iso8859_9_mbtowc, NULL }, { iso8859_9_wctomb, NULL }) -#ifdef USE_HPUX_ALIASES -DEFALIAS( "ISO88599", /* HP-UX */ - iso8859_9) -#endif - -DEFENCODING(( "ISO-8859-10", /* IANA */ - "ISO_8859-10", - "ISO_8859-10:1992", /* IANA */ - "ISO-IR-157", /* IANA */ - "LATIN6", /* IANA */ - "L6", /* IANA */ - "csISOLatin6", /* IANA */ - "ISO8859-10", /* X11R6.4, glibc, FreeBSD */ - ), - -1, - iso8859_10, - { iso8859_10_mbtowc, NULL }, { iso8859_10_wctomb, NULL }) - -DEFENCODING(( "ISO-8859-11", /* glibc */ - "ISO_8859-11", - "ISO8859-11", /* X11R6.7, glibc */ - ), - -1, - iso8859_11, - { iso8859_11_mbtowc, NULL }, { iso8859_11_wctomb, NULL }) - -DEFENCODING(( "ISO-8859-13", /* IANA, glibc */ - "ISO_8859-13", - "ISO-IR-179", /* glibc */ - "LATIN7", /* glibc */ - "L7", /* glibc */ - "ISO8859-13", /* glibc, FreeBSD */ - /*"CP28603", Windows */ - ), - 28603, - iso8859_13, - { iso8859_13_mbtowc, NULL }, { iso8859_13_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-921", /* AIX */ - iso8859_13) -#endif - -DEFENCODING(( "ISO-8859-14", /* IANA, glibc */ - "ISO_8859-14", /* IANA */ - "ISO_8859-14:1998", /* IANA, glibc */ - "ISO-IR-199", /* IANA */ - "LATIN8", /* IANA, glibc */ - "L8", /* IANA, glibc */ - "ISO-CELTIC", /* IANA */ - "ISO8859-14", /* glibc, FreeBSD */ - ), - -1, - iso8859_14, - { iso8859_14_mbtowc, NULL }, { iso8859_14_wctomb, NULL }) - -DEFENCODING(( "ISO-8859-15", /* IANA, glibc */ - "ISO_8859-15", /* IANA */ - "ISO_8859-15:1998", /* glibc */ - "ISO-IR-203", - "LATIN-9", /* IANA */ - "ISO8859-15", /* glibc, FreeBSD, AIX, OSF/1, Solaris */ - /*"CP28605", Windows */ - ), - 28605, - iso8859_15, - { iso8859_15_mbtowc, NULL }, { iso8859_15_wctomb, NULL }) -#ifdef USE_HPUX_ALIASES -DEFALIAS( "ISO885915", /* HP-UX */ - iso8859_15) -#endif - -DEFENCODING(( "ISO-8859-16", /* IANA */ - "ISO_8859-16", /* IANA */ - "ISO_8859-16:2001", /* IANA */ - "ISO-IR-226", /* IANA */ - "LATIN10", /* IANA */ - "L10", /* IANA */ - "ISO8859-16", /* glibc, FreeBSD */ - ), - -1, - iso8859_16, - { iso8859_16_mbtowc, NULL }, { iso8859_16_wctomb, NULL }) - -DEFENCODING(( "KOI8-R", /* IANA, RFC 1489, X11R6.4, JDK 1.1 */ - "csKOI8R", /* IANA */ - /*"CP20866", Windows */ - ), - 20866, - koi8_r, - { koi8_r_mbtowc, NULL }, { koi8_r_wctomb, NULL }) - -DEFENCODING(( "KOI8-U", /* IANA, RFC 2319 */ - ), - -1, - koi8_u, - { koi8_u_mbtowc, NULL }, { koi8_u_wctomb, NULL }) - -DEFENCODING(( "KOI8-RU", - /*"CP21866", Windows */ - ), - 21866, - koi8_ru, - { koi8_ru_mbtowc, NULL }, { koi8_ru_wctomb, NULL }) - -/* Windows 8-bit encodings */ - -DEFENCODING(( "CP1250", /* JDK 1.1 */ - "WINDOWS-1250", /* IANA */ - "MS-EE", - ), - 1250, - cp1250, - { cp1250_mbtowc, NULL }, { cp1250_wctomb, NULL }) - -DEFENCODING(( "CP1251", /* JDK 1.1 */ - "WINDOWS-1251", /* IANA */ - "MS-CYRL", - ), - 1251, - cp1251, - { cp1251_mbtowc, NULL }, { cp1251_wctomb, NULL }) -#ifdef USE_SOLARIS_ALIASES -DEFALIAS( "ANSI-1251", /* Solaris */ - cp1251) -#endif - -DEFENCODING(( "CP1252", /* JDK 1.1 */ - "WINDOWS-1252", /* IANA */ - "MS-ANSI", - ), - 1252, - cp1252, - { cp1252_mbtowc, NULL }, { cp1252_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-1252", /* AIX */ - cp1252) -#endif - -DEFENCODING(( "CP1253", /* JDK 1.1 */ - "WINDOWS-1253", /* IANA */ - "MS-GREEK", - ), - 1253, - cp1253, - { cp1253_mbtowc, NULL }, { cp1253_wctomb, NULL }) - -DEFENCODING(( "CP1254", /* JDK 1.1 */ - "WINDOWS-1254", /* IANA */ - "MS-TURK", - ), - 1254, - cp1254, - { cp1254_mbtowc, NULL }, { cp1254_wctomb, NULL }) - -DEFENCODING(( "CP1255", /* JDK 1.1 */ - "WINDOWS-1255", /* IANA */ - "MS-HEBR", - ), - 1255, - cp1255, - { cp1255_mbtowc, cp1255_flushwc }, { cp1255_wctomb, NULL }) - -DEFENCODING(( "CP1256", /* JDK 1.1 */ - "WINDOWS-1256", /* IANA */ - "MS-ARAB", - ), - 1256, - cp1256, - { cp1256_mbtowc, NULL }, { cp1256_wctomb, NULL }) - -DEFENCODING(( "CP1257", /* JDK 1.1 */ - "WINDOWS-1257", /* IANA */ - "WINBALTRIM", - ), - 1257, - cp1257, - { cp1257_mbtowc, NULL }, { cp1257_wctomb, NULL }) - -DEFENCODING(( "CP1258", /* JDK 1.1 */ - "WINDOWS-1258", /* IANA */ - ), - 1258, - cp1258, - { cp1258_mbtowc, cp1258_flushwc }, { cp1258_wctomb, NULL }) - -/* DOS 8-bit encodings */ - -DEFENCODING(( "CP850", /* IANA, JDK 1.1 */ - "IBM850", /* IANA */ - "850", /* IANA */ - "csPC850Multilingual", /* IANA */ - ), - 850, - cp850, - { cp850_mbtowc, NULL }, { cp850_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-850", /* AIX */ - cp850) -#endif - -DEFENCODING(( "CP862", /* IANA, JDK 1.1 */ - "IBM862", /* IANA */ - "862", /* IANA */ - "csPC862LatinHebrew", /* IANA */ - ), - 862, - cp862, - { cp862_mbtowc, NULL }, { cp862_wctomb, NULL }) - -DEFENCODING(( "CP866", /* IANA, JDK 1.1 */ - "IBM866", /* IANA */ - "866", /* IANA */ - "csIBM866", /* IANA */ - ), - 866, - cp866, - { cp866_mbtowc, NULL }, { cp866_wctomb, NULL }) - -DEFENCODING(( "CP1131", /* FreeBSD, MacOS X */ - ), - 1131, - cp1131, - { cp1131_mbtowc, NULL }, { cp1131_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-1131", /* AIX */ - cp1131) -#endif - -/* Macintosh 8-bit encodings */ - -DEFENCODING(( "MacRoman", /* JDK 1.1 */ - /* This is the best table for MACINTOSH. The ones */ - /* in glibc and FreeBSD-iconv are bad quality. */ - "MACINTOSH", /* IANA */ - "MAC", /* IANA */ - "csMacintosh", /* IANA */ - /*"CP10000", Windows */ - ), - 10000, - mac_roman, - { mac_roman_mbtowc, NULL }, { mac_roman_wctomb, NULL }) - -DEFENCODING(( "MacCentralEurope", /* JDK 1.1 */ - /*"CP10029", Windows */ - ), - 10029, - mac_centraleurope, - { mac_centraleurope_mbtowc, NULL }, { mac_centraleurope_wctomb, NULL }) - -DEFENCODING(( "MacIceland", /* JDK 1.1 */ - /*"CP10079", Windows */ - ), - 10079, - mac_iceland, - { mac_iceland_mbtowc, NULL }, { mac_iceland_wctomb, NULL }) - -DEFENCODING(( "MacCroatian", /* JDK 1.1 */ - /*"CP10082", Windows */ - ), - 10082, - mac_croatian, - { mac_croatian_mbtowc, NULL }, { mac_croatian_wctomb, NULL }) - -DEFENCODING(( "MacRomania", /* JDK 1.1 */ - /*"CP10010", Windows */ - ), - 10010, - mac_romania, - { mac_romania_mbtowc, NULL }, { mac_romania_wctomb, NULL }) - -DEFENCODING(( "MacCyrillic", /* JDK 1.1 */ - /*"CP10007", Windows */ - ), - 10007, - mac_cyrillic, - { mac_cyrillic_mbtowc, NULL }, { mac_cyrillic_wctomb, NULL }) - -DEFENCODING(( "MacUkraine", /* JDK 1.1 */ - /*"CP10017", Windows */ - ), - 10017, - mac_ukraine, - { mac_ukraine_mbtowc, NULL }, { mac_ukraine_wctomb, NULL }) - -DEFENCODING(( "MacGreek", /* JDK 1.1 */ - /*"CP10006", Windows */ - ), - 10006, - mac_greek, - { mac_greek_mbtowc, NULL }, { mac_greek_wctomb, NULL }) - -DEFENCODING(( "MacTurkish", /* JDK 1.1 */ - /*"CP10081", Windows */ - ), - 10081, - mac_turkish, - { mac_turkish_mbtowc, NULL }, { mac_turkish_wctomb, NULL }) - -DEFENCODING(( "MacHebrew", /* JDK 1.1 */ - /*"CP10005", Windows */ - ), - 10005, - mac_hebrew, - { mac_hebrew_mbtowc, NULL }, { mac_hebrew_wctomb, NULL }) - -DEFENCODING(( "MacArabic", /* JDK 1.1 */ - /*"CP10004", Windows */ - ), - 10004, - mac_arabic, - { mac_arabic_mbtowc, NULL }, { mac_arabic_wctomb, NULL }) - -DEFENCODING(( "MacThai", /* JDK 1.1 */ - /*"CP10021", Windows */ - ), - 10021, - mac_thai, - { mac_thai_mbtowc, NULL }, { mac_thai_wctomb, NULL }) - -/* Other platform specific 8-bit encodings */ - -DEFENCODING(( "HP-ROMAN8", /* IANA, X11R6.4 */ - "ROMAN8", /* IANA */ - "R8", /* IANA */ - "csHPRoman8", /* IANA */ - ), - -1, - hp_roman8, - { hp_roman8_mbtowc, NULL }, { hp_roman8_wctomb, NULL }) - -DEFENCODING(( "NEXTSTEP", - ), - -1, - nextstep, - { nextstep_mbtowc, NULL }, { nextstep_wctomb, NULL }) - -/* Regional 8-bit encodings used for a single language */ - -DEFENCODING(( "ARMSCII-8", - ), - -1, - armscii_8, - { armscii_8_mbtowc, NULL }, { armscii_8_wctomb, NULL }) - -DEFENCODING(( "GEORGIAN-ACADEMY", - ), - -1, - georgian_academy, - { georgian_academy_mbtowc, NULL }, { georgian_academy_wctomb, NULL }) - -DEFENCODING(( "GEORGIAN-PS", - ), - -1, - georgian_ps, - { georgian_ps_mbtowc, NULL }, { georgian_ps_wctomb, NULL }) - -DEFENCODING(( "KOI8-T", - ), - -1, - koi8_t, - { koi8_t_mbtowc, NULL }, { koi8_t_wctomb, NULL }) - -DEFENCODING(( "PT154", /* IANA, glibc */ - "PTCP154", /* IANA */ - "CP154", /* IANA */ - "CYRILLIC-ASIAN", /* IANA */ - "csPTCP154", /* IANA */ - ), - 154, - pt154, - { pt154_mbtowc, NULL }, { pt154_wctomb, NULL }) - -DEFENCODING(( "RK1048", /* IANA, glibc */ - "STRK1048-2002", /* IANA */ - "KZ-1048", /* IANA */ - "csKZ1048", /* IANA */ - ), - -1, - rk1048, - { rk1048_mbtowc, NULL }, { rk1048_wctomb, NULL }) - -DEFENCODING(( "MULELAO-1", - ), - -1, - mulelao, - { mulelao_mbtowc, NULL }, { mulelao_wctomb, NULL }) - -DEFENCODING(( "CP1133", - "IBM-CP1133", - ), - 1133, - cp1133, - { cp1133_mbtowc, NULL }, { cp1133_wctomb, NULL }) - -DEFENCODING(( "TIS-620", /* IANA */ - "TIS620", /* glibc, HP-UX */ - "TIS620-0", /* glibc */ - "TIS620.2529-1", /* glibc */ - "TIS620.2533-0", /* glibc */ - "TIS620.2533-1", - "ISO-IR-166", /* glibc */ - ), - -1, - tis620, - { tis620_mbtowc, NULL }, { tis620_wctomb, NULL }) -#ifdef USE_OSF1_ALIASES -DEFALIAS( "TACTIS", /* OSF/1 */ - tis620) -#endif -#ifdef USE_SOLARIS_ALIASES -DEFALIAS( "TIS620.2533", /* Solaris */ - tis620) -#endif - -DEFENCODING(( "CP874", /* JDK 1.1 */ - "WINDOWS-874", - ), - 874, - cp874, - { cp874_mbtowc, NULL }, { cp874_wctomb, NULL }) - -DEFENCODING(( "VISCII", /* IANA, RFC 1456 */ - "VISCII1.1-1", - "csVISCII", /* IANA */ - ), - -1, - viscii, - { viscii_mbtowc, NULL }, { viscii_wctomb, NULL }) - -DEFENCODING(( "TCVN", - "TCVN-5712", - "TCVN5712-1", - "TCVN5712-1:1993", - ), - -1, - tcvn, - { tcvn_mbtowc, tcvn_flushwc }, { tcvn_wctomb, NULL }) - -/* CJK character sets (not documented) */ - -DEFENCODING(( "JIS_C6220-1969-RO", /* IANA */ - "ISO646-JP", /* IANA */ - "ISO-IR-14", /* IANA */ - "JP", /* IANA */ - "csISO14JISC6220ro", /* IANA */ - ), - -1, - iso646_jp, - { iso646_jp_mbtowc, NULL }, { iso646_jp_wctomb, NULL }) - -DEFENCODING(( "JIS_X0201", /* IANA */ - "JISX0201-1976", - "X0201", /* IANA */ - "csHalfWidthKatakana", /* IANA */ - /*"JISX0201.1976-0", X11R6.4 */ - /*"JIS0201", JDK 1.1 */ - ), - -1, - jisx0201, - { jisx0201_mbtowc, NULL }, { jisx0201_wctomb, NULL }) - -DEFENCODING(( "JIS_X0208", - "JIS_X0208-1983", /* IANA */ - "JIS_X0208-1990", - "JIS0208", - "X0208", /* IANA */ - "ISO-IR-87", /* IANA */ - "JIS_C6226-1983", /* IANA */ - "csISO87JISX0208", /* IANA */ - /*"JISX0208.1983-0", X11R6.4 */ - /*"JISX0208.1990-0", X11R6.4 */ - /*"JIS0208", JDK 1.1 */ - ), - -1, - jisx0208, - { jisx0208_mbtowc, NULL }, { jisx0208_wctomb, NULL }) - -DEFENCODING(( "JIS_X0212", - "JIS_X0212.1990-0", - "JIS_X0212-1990", /* IANA */ - "X0212", /* IANA */ - "ISO-IR-159", /* IANA */ - "csISO159JISX02121990", /* IANA */ - /*"JISX0212.1990-0", X11R6.4 */ - /*"JIS0212", JDK 1.1 */ - ), - -1, - jisx0212, - { jisx0212_mbtowc, NULL }, { jisx0212_wctomb, NULL }) - -DEFENCODING(( "GB_1988-80", /* IANA */ - "ISO646-CN", /* IANA */ - "ISO-IR-57", /* IANA */ - "CN", /* IANA */ - "csISO57GB1988", /* IANA */ - ), - -1, - iso646_cn, - { iso646_cn_mbtowc, NULL }, { iso646_cn_wctomb, NULL }) - -DEFENCODING(( "GB_2312-80", /* IANA */ - "ISO-IR-58", /* IANA */ - "csISO58GB231280", /* IANA */ - /*"GB2312.1980-0", X11R6.4 */ - ), - -1, - gb2312, - { gb2312_mbtowc, NULL }, { gb2312_wctomb, NULL }) - -DEFENCODING(( "ISO-IR-165", - "CN-GB-ISOIR165", /* RFC 1922 */ - ), - -1, - isoir165, - { isoir165_mbtowc, NULL }, { isoir165_wctomb, NULL }) - -DEFENCODING(( "KSC_5601", /* IANA */ - "KS_C_5601-1987", /* IANA */ - "KS_C_5601-1989", /* IANA */ - "ISO-IR-149", /* IANA */ - "csKSC56011987", /* IANA */ - "KOREAN", /* IANA */ - /*"KSC5601.1987-0", X11R6.4 */ - /*"KSX1001:1992", Ken Lunde */ - ), - -1, - ksc5601, - { ksc5601_mbtowc, NULL }, { ksc5601_wctomb, NULL }) - -/* CJK encodings */ - -DEFENCODING(( "EUC-JP", /* IANA */ - "EUCJP", /* glibc, HP-UX, IRIX, OSF/1, Solaris */ - "Extended_UNIX_Code_Packed_Format_for_Japanese", /* IANA */ - "csEUCPkdFmtJapanese", /* IANA */ - /*"EUC_JP", JDK 1.1 */ - /*"CP51932", Windows */ - ), - 51932, - euc_jp, - { euc_jp_mbtowc, NULL }, { euc_jp_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-EUCJP", /* AIX */ - euc_jp) -#endif -#ifdef USE_OSF1_ALIASES -DEFALIAS( "SDECKANJI", /* OSF/1 */ - euc_jp) -#endif - -DEFENCODING(( "SHIFT_JIS", /* IANA */ - "SHIFT-JIS", /* glibc */ - "SJIS", /* JDK 1.1, HP-UX, OSF/1 */ - "MS_KANJI", /* IANA */ - "csShiftJIS", /* IANA */ - ), - -1, - sjis, - { sjis_mbtowc, NULL }, { sjis_wctomb, NULL }) -#ifdef USE_SOLARIS_ALIASES -DEFALIAS( "PCK", /* Solaris */ - sjis) -#endif - -DEFENCODING(( "CP932", /* glibc */ - ), - 932, - cp932, - { cp932_mbtowc, NULL }, { cp932_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-932", /* AIX */ - cp932) -#endif - -DEFENCODING(( "ISO-2022-JP", /* IANA, RFC 1468 */ - "csISO2022JP", /* IANA */ - /*"ISO2022JP", JDK 1.1 */ - ), - -1, - iso2022_jp, - { iso2022_jp_mbtowc, NULL }, { iso2022_jp_wctomb, iso2022_jp_reset }) - -DEFENCODING(( "ISO-2022-JP-1", /* RFC 2237 */ - ), - -1, - iso2022_jp1, - { iso2022_jp1_mbtowc, NULL }, { iso2022_jp1_wctomb, iso2022_jp1_reset }) - -DEFENCODING(( "ISO-2022-JP-2", /* IANA, RFC 1554 */ - "csISO2022JP2", /* IANA */ - ), - -1, - iso2022_jp2, - { iso2022_jp2_mbtowc, NULL }, { iso2022_jp2_wctomb, iso2022_jp2_reset }) - -DEFENCODING(( "ISO-2022-JP-MS", - "CP50221", - /*"ISO-2022-JP-ESC", Windows */ - ), - 50221, - iso2022_jpms, - { iso2022_jpms_mbtowc, NULL }, { iso2022_jpms_wctomb, iso2022_jpms_reset }) - -DEFENCODING(( "EUC-CN", /* glibc */ - "EUCCN", /* glibc, IRIX */ - "GB2312", /* IANA */ - "CN-GB", /* RFC 1922 */ - "csGB2312", /* IANA */ - "CHINESE", /* IANA */ - /*"EUC_CN", JDK 1.1 */ - /*"CP51936", Windows */ - ), - 51936, - euc_cn, - { euc_cn_mbtowc, NULL }, { euc_cn_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-EUCCN", /* AIX */ - euc_cn) -#endif -#ifdef USE_HPUX_ALIASES -DEFALIAS( "HP15CN", /* HP-UX */ - euc_cn) -#endif -#ifdef USE_OSF1_ALIASES -DEFALIAS( "DECHANZI", /* OSF/1 */ - euc_cn) -#endif - -DEFENCODING(( "GBK", /* IANA, JDK 1.1 */ - ), - -1, /* See CP936 */ - ces_gbk, - { ces_gbk_mbtowc, NULL }, { ces_gbk_wctomb, NULL }) - -DEFENCODING(( "CP936", /* IANA */ - "MS936", /* IANA */ - "WINDOWS-936", /* IANA */ - ), - 936, - cp936, - { cp936_mbtowc, NULL }, { cp936_wctomb, NULL }) - -DEFENCODING(( "GB18030", /* IANA, glibc */ - /*"CP54936", Windows */ - "GB18030:2005", - ), - 54936, - gb18030_2005, - { gb18030_2005_mbtowc, NULL },{ gb18030_2005_wctomb, NULL }) - -DEFENCODING(( "GB18030:2022", - ), - -1, - gb18030_2022, - { gb18030_2022_mbtowc, NULL },{ gb18030_2022_wctomb, NULL }) - -DEFENCODING(( "ISO-2022-CN", /* IANA, RFC 1922 */ - "csISO2022CN", - /*"ISO2022CN", JDK 1.1 */ - ), - -1, - iso2022_cn, - { iso2022_cn_mbtowc, NULL }, { iso2022_cn_wctomb, iso2022_cn_reset }) - -DEFENCODING(( "ISO-2022-CN-EXT", /* IANA, RFC 1922 */ - ), - -1, - iso2022_cn_ext, - { iso2022_cn_ext_mbtowc, NULL }, { iso2022_cn_ext_wctomb, iso2022_cn_ext_reset }) - -DEFENCODING(( "HZ", /* RFC 1843 */ - "HZ-GB-2312", /* IANA, RFC 1842 */ - /*"CP52936", Windows */ - ), - 52936, - hz, - { hz_mbtowc, NULL }, { hz_wctomb, hz_reset }) - -DEFENCODING(( "EUC-TW", /* glibc */ - "EUCTW", /* glibc, HP-UX, IRIX, OSF/1 */ - "csEUCTW", - /*"EUC_TW", JDK 1.1 */ - /*"CP51950", Windows */ - ), - 51950, - euc_tw, - { euc_tw_mbtowc, NULL }, { euc_tw_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-EUCTW", /* AIX */ - euc_tw) -#endif -#ifdef USE_SOLARIS_ALIASES -DEFALIAS( "CNS11643", /* Solaris */ - euc_tw) -#endif - -DEFENCODING(( "BIG5", /* IANA, JDK 1.1 */ - "BIG-5", /* glibc */ - "BIG-FIVE", /* glibc */ - "BIGFIVE", /* glibc */ - "CN-BIG5", /* RFC 1922 */ - "csBig5", /* IANA */ - ), - -1, /* See CP950 */ - ces_big5, - { ces_big5_mbtowc, NULL }, { ces_big5_wctomb, NULL }) - -DEFENCODING(( "CP950", /* JDK 1.1 */ - ), - 950, - cp950, - { cp950_mbtowc, NULL }, { cp950_wctomb, NULL }) - -DEFENCODING(( "BIG5-HKSCS:1999", - ), - -1, - big5hkscs1999, - { big5hkscs1999_mbtowc, big5hkscs1999_flushwc }, { big5hkscs1999_wctomb, big5hkscs1999_reset }) - -DEFENCODING(( "BIG5-HKSCS:2001", - ), - -1, - big5hkscs2001, - { big5hkscs2001_mbtowc, big5hkscs2001_flushwc }, { big5hkscs2001_wctomb, big5hkscs2001_reset }) - -DEFENCODING(( "BIG5-HKSCS:2004", - ), - -1, - big5hkscs2004, - { big5hkscs2004_mbtowc, big5hkscs2004_flushwc }, { big5hkscs2004_wctomb, big5hkscs2004_reset }) - -DEFENCODING(( "BIG5-HKSCS", /* IANA */ - "BIG5HKSCS", /* glibc */ - "BIG5-HKSCS:2008", - ), - -1, - big5hkscs2008, - { big5hkscs2008_mbtowc, big5hkscs2008_flushwc }, { big5hkscs2008_wctomb, big5hkscs2008_reset }) - -DEFENCODING(( "EUC-KR", /* IANA, RFC 1557 */ - "EUCKR", /* glibc, HP-UX, IRIX, OSF/1 */ - "csEUCKR", /* IANA */ - /*"EUC_KR", JDK 1.1 */ - /*"CP51949", Windows */ - ), - 51949, - euc_kr, - { euc_kr_mbtowc, NULL }, { euc_kr_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-EUCKR", /* AIX */ - euc_kr) -#endif -#ifdef USE_OSF1_ALIASES -DEFALIAS( "DECKOREAN", /* OSF/1 */ - euc_kr) -#endif -#ifdef USE_SOLARIS_ALIASES -DEFALIAS( "5601", /* Solaris */ - euc_kr) -#endif - -DEFENCODING(( "CP949", /* JDK 1.1 */ - "UHC", /* glibc */ - ), - 949, - cp949, - { cp949_mbtowc, NULL }, { cp949_wctomb, NULL }) -#ifdef USE_OSF1_ALIASES -DEFALIAS( "KSC5601", /* OSF/1 */ - cp949) -#endif - -DEFENCODING(( "JOHAB", /* glibc */ - "CP1361", /* glibc */ - ), - 1361, - johab, - { johab_mbtowc, NULL }, { johab_wctomb, NULL }) -#ifdef USE_SOLARIS_ALIASES -DEFALIAS( "KO_KR.JOHAP92", /* Solaris */ - johab) -#endif - -DEFENCODING(( "ISO-2022-KR", /* IANA, RFC 1557 */ - "csISO2022KR", /* IANA */ - /*"ISO2022KR", JDK 1.1 */ - /*"CP50225", Windows */ - ), - 50225, - iso2022_kr, - { iso2022_kr_mbtowc, NULL }, { iso2022_kr_wctomb, iso2022_kr_reset }) - diff --git a/lib/encodings.h.snippet b/lib/encodings.h.snippet new file mode 100644 index 00000000..43e02df7 --- /dev/null +++ b/lib/encodings.h.snippet @@ -0,0 +1,1684 @@ +/** + * @file encodings.h.snippet + * @brief Definitions of encodings. + * @copyright Copyright (C) 1999-2011 Free Software Foundation, Inc. + * @copyright Copyright (C) 2023-2024 The C++ Plus Project. + * @note By convention, an encoding named "FOOBAR" or "FOO_BAR" or "FOO-BAR" is defined in a file + * named `converters/foobar.h` through the functions `foobar_mbtowc` and `foobar_wctomb` (and + * possibly `foobar_reset`). With FOOBAR's index (and possibly codepage) + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +/* DEFENCODING(( name, alias1, ..., ), + * xxx, + * xxx_index, + * { xxx_mbtowc, xxx_flushwc }, + * { xxx_wctomb, xxx_reset }) + * Defines an encoding with the given name and aliases. (There is no difference between a name and + * an alias. By convention, the name is chosen as the preferred MIME name or the standard name.) + * All names and aliases must be in ASCII. Case is not significant, but for the "cs*" aliases mixed + * case is preferred, otherwise UPPERCASE is preferred. For all names and aliases, note where it + * comes from. + * xxx is the name as used in the C code (lowercase). xxx_index provides a unique index for the + * encoding. It will be used in a enum for fast access to the encoding. xxx is for reiconv's + * internal use only and xxx_index is for the user's + * use. Their values may be same. + * We removed all '-' and '_' of encoding's name. And turn their names to upper case. + */ + +/* + * DEFCODEPAGE(codepage, xxx) + * Defines a codepage for the given encoding. + * codepage is the codepage number, which is often used in Windows, z/OS and AIX. + * xxx is the encoding internal name. + */ + +/* + * DEFINDEX(alias, index) + * Defines an index alias for the given encoding. + * All encoding has its own index. But some encoding's index is strange. (e.g. GB18030_2022) + * So we define an alias for the index. (e.g. GB18030) + */ + +// ASCII +DEFENCODING(("USASCII", /* IANA */ + "ASCII", /* IANA, JDK 1.1 */ + "ISO646US", /* IANA */ + "ISO646.IRV:1991", /* IANA */ + "ISOIR6", /* IANA */ + "ANSIX3.41968", /* IANA */ + "ANSIX3.41986", /* IANA */ + "IBM367", /* IANA */ + "US", /* IANA */ + "CSASCII", /* IANA */ + "367", /* IANA */ + "CP367", /* IANA */ + "646", /* Solaris */ + ), + ascii, ASCII, {ascii_mbtowc, NULL}, {ascii_wctomb, NULL}) +DEFCODEPAGE(367, ascii) + +// General multi-byte encodings +// UTF-8, the MOST common encoding. +DEFENCODING(("UTF8", /* IANA, RFC 2279 */ + "U8", /* cppp-reiconv */ + "CP65001", /* IANA */ + "65001", /* IANA */ + ), + utf8, UTF8, {utf8_mbtowc, NULL}, {utf8_wctomb, NULL}) +DEFCODEPAGE(65001, utf8) + +DEFENCODING(("UCS2", /* glibc */ + "ISO10646UCS2", /* IANA */ + "CSUNICODE", /* IANA */ + ), + ucs2, UCS2, {ucs2_mbtowc, NULL}, {ucs2_wctomb, NULL}) + +DEFENCODING(("UCS2BE", /* glibc */ + "UNICODEBIG", /* glibc */ + "UNICODE11", /* IANA */ + "CSUNICODE11", /* IANA */ + "UNICODEFFFE", /* .NET */ + "CP1201", /* Windows */ + "1201" /* Windows */ + ), + ucs2be, UCS2BE, {ucs2be_mbtowc, NULL}, {ucs2be_wctomb, NULL}) +DEFCODEPAGE(1201, ucs2be) + +DEFENCODING(("UCS2LE", /* glibc */ + "UNICODELITTLE", /* glibc */ + "CP1200", /* Windows */ + "1200", /* Windows */ + ), + ucs2le, UCS2LE, {ucs2le_mbtowc, NULL}, {ucs2le_wctomb, NULL}) +DEFCODEPAGE(1200, ucs2le) + +DEFENCODING(("UCS4", /* glibc */ + "ISO10646UCS4", /* IANA */ + "CSUCS4", /* IANA */ + ), + ucs4, UCS4, {ucs4_mbtowc, NULL}, {ucs4_wctomb, NULL}) + +DEFENCODING(("UCS4BE", /* glibc */ + "12001", /* Windows */ + "CP12001", /* Windows */ + ), + ucs4be, UCS4BE, {ucs4be_mbtowc, NULL}, {ucs4be_wctomb, NULL}) +DEFCODEPAGE(12001, ucs4be) + +DEFENCODING(("UCS4LE", /* glibc */ + "CP12000", /* Windows */ + "12000", /* Windows */ + ), + ucs4le, UCS4LE, {ucs4le_mbtowc, NULL}, {ucs4le_wctomb, NULL}) +DEFCODEPAGE(12000, ucs4le) + +DEFENCODING(("UTF16", /* IANA, RFC 2781 */ + "U16", /* cppp-reiconv */ + ), + utf16, UTF16, {utf16_mbtowc, NULL}, {utf16_wctomb, NULL}) + +DEFENCODING(("UTF16BE", /* IANA, RFC 2781 */ + "U16BE", /* cppp-reiconv */ + ), + utf16be, UTF16BE, {utf16be_mbtowc, NULL}, {utf16be_wctomb, NULL}) + +DEFENCODING(("UTF16LE", /* IANA, RFC 2781 */ + "U16LE", /* cppp-reiconv */ + ), + utf16le, UTF16LE, {utf16le_mbtowc, NULL}, {utf16le_wctomb, NULL}) + +DEFENCODING(("UTF32", /* IANA, Unicode 3.1 */ + "U32", /* cppp-reiconv */ + ), + utf32, UTF32, {utf32_mbtowc, NULL}, {utf32_wctomb, NULL}) + +DEFENCODING(("UTF32BE", /* IANA, Unicode 3.1 */ + "U32BE", /* cppp-reiconv */ + ), + utf32be, UTF32BE, {utf32be_mbtowc, NULL}, {utf32be_wctomb, NULL}) + +DEFENCODING(("UTF32LE", /* IANA, Unicode 3.1 */ + "U32LE", /* cppp-reiconv */ + ), + utf32le, UTF32LE, {utf32le_mbtowc, NULL}, {utf32le_wctomb, NULL}) +DEFENCODING(("UTF7", /* IANA, RFC 2152 */ + "UNICODE11UTF7", /* IANA, RFC 1642 */ + "CSUNICODE11UTF7", /* IANA */ + "U7", /* cppp-reiconv */ + "CP65000", /* Windows */ + "65000", /* Windows */ + ), + utf7, UTF7, {utf7_mbtowc, NULL}, {utf7_wctomb, utf7_reset}) +DEFCODEPAGE(65000, utf7) + +// UCS-2/4-INTERNAL/SWAPPED are not standard encodings, but are used by +// cppp-reiconv(and libiconv)'s testsuite. + +DEFENCODING(("UCS2INTERNAL", /* libiconv */ + ), + ucs2internal, UCS2_INTERNAL, {ucs2internal_mbtowc, NULL}, {ucs2internal_wctomb, NULL}) + +DEFENCODING(("UCS2SWAPPED", /* libiconv */ + ), + ucs2swapped, UCS2_SWAPPED, {ucs2swapped_mbtowc, NULL}, {ucs2swapped_wctomb, NULL}) + +DEFENCODING(("UCS4INTERNAL", /* libiconv */ + ), + ucs4internal, UCS4_INTERNAL, {ucs4internal_mbtowc, NULL}, {ucs4internal_wctomb, NULL}) + +DEFENCODING(("UCS4SWAPPED", /* libiconv */ + ), + ucs4swapped, UCS4_SWAPPED, {ucs4swapped_mbtowc, NULL}, {ucs4swapped_wctomb, NULL}) + +DEFENCODING(("C99", ), c99, C99, {c99_mbtowc, NULL}, {c99_wctomb, NULL}) + +DEFENCODING(("JAVA", ), java, JAVA, {java_mbtowc, NULL}, {java_wctomb, NULL}) + +// CJK encodings +DEFENCODING(("EUCJP", /* IANA, glibc, HP-UX, IRIX, OSF/1, Solaris */ + "EXTENDEDUNIXCODEPACKEDFORMATFORJAPANESE", /* IANA */ + "CSEUCPKDFMTJAPANESE", /* IANA */ + "IBMEUCJP", /* AIX */ + "SDECKANJI", /* OSF/1 */ + "CP51932", /* Windows */ + "51932", /* Windows */ + ), + euc_jp, EUC_JP, {euc_jp_mbtowc, NULL}, {euc_jp_wctomb, NULL}) +DEFCODEPAGE(51932, euc_jp) + +DEFENCODING(("SHIFTJIS", /* IANA, glibc */ + "SJIS", /* JDK 1.1, HP-UX, OSF/1 */ + "MSKANJI", /* IANA */ + "CSSHIFTJIS", /* IANA */ + "PCK", /* Solaris */ + ), + sjis, SHIFT_JIS, {sjis_mbtowc, NULL}, {sjis_wctomb, NULL}) + +DEFENCODING(("IBM932", /* AIX */ + "CP932", /* Windows */ + "932", /* Windows */ + ), + cp932, IBM932, {cp932_mbtowc, NULL}, {cp932_wctomb, NULL}) +DEFCODEPAGE(932, cp932) + +DEFENCODING(("ISO2022JP", /* IANA, RFC 1468, JDK 1.1 */ + "CSISO2022JP", /* IANA */ + "CP50220", /* Windows */ + "50220", /* Windows */ + "CP50222", /* Windows */ + "50222", /* Windows */ + ), + iso2022_jp, ISO2022_JP, {iso2022_jp_mbtowc, NULL}, {iso2022_jp_wctomb, iso2022_jp_reset}) +DEFCODEPAGE(50220, iso2022_jp) +DEFCODEPAGE(50222, iso2022_jp) + +DEFENCODING(("ISO2022JP1", /* RFC 2237 */ + ), + iso2022_jp1, ISO2022_JP1, {iso2022_jp1_mbtowc, NULL}, {iso2022_jp1_wctomb, iso2022_jp1_reset}) + +DEFENCODING(("ISO2022JP2", /* IANA, RFC 1554 */ + "CSISO2022JP2", /* IANA */ + ), + iso2022_jp2, ISO2022_JP2, {iso2022_jp2_mbtowc, NULL}, {iso2022_jp2_wctomb, iso2022_jp2_reset}) + +DEFENCODING(("ISO2022JPMS", /* (Unknown) */ + "CP50221", /* Windows */ + "50221", /* Windows */ + ), + iso2022_jpms, ISO2022_JPMS, {iso2022_jpms_mbtowc, NULL}, {iso2022_jpms_wctomb, iso2022_jpms_reset}) +DEFCODEPAGE(50221, iso2022_jpms) + +DEFENCODING(("EUCCN", /* glibc, IRIX */ + "GB2312", /* IANA */ + "CNGB", /* RFC 1922 */ + "CSGB2312", /* IANA */ + "CHINESE", /* IANA */ + "IBMEUCCN", /* AIX */ + "HP15CN", /* HP-UX */ + "DECHANZI", /* OSF/1 */ + ), + euc_cn, GB2312, {euc_cn_mbtowc, NULL}, {euc_cn_wctomb, NULL}) +DEFCODEPAGE(51936, euc_cn) + +DEFENCODING(("GBK", /* IANA, JDK 1.1 */ + ), + ces_gbk, GBK, {ces_gbk_mbtowc, NULL}, {ces_gbk_wctomb, NULL}) + +DEFENCODING(("MS936", /* IANA */ + "WINDOWS936", /* IANA */ + "CP936", /* Windows */ + "936", /* Windows */ + ), + cp936, + CP936, // Chinese developer use CP936 more often than MS936 + {cp936_mbtowc, NULL}, {cp936_wctomb, NULL}) +DEFCODEPAGE(936, cp936) + +DEFENCODING(("GB18030:2005", /* libiconv */ + ), + gb18030_2005, GB18030_2005, {gb18030_2005_mbtowc, NULL}, {gb18030_2005_wctomb, NULL}) + +DEFENCODING(("GB18030", /* IANA, glibc */ + "CSGB18030", /* IANA */ + "GB18030:2022", /* libiconv */ + "CP54936", /* Windows */ + "54936", /* Windows */ + ), + gb18030_2022, GB18030_2022, {gb18030_2022_mbtowc, NULL}, {gb18030_2022_wctomb, NULL}) +DEFINDEX(GB18030, GB18030_2022) +DEFCODEPAGE(54936, gb18030_2022) + +DEFENCODING(("ISO2022CN", /* IANA, RFC 1922, JDK 1.1 */ + "CSISO2022CN", /* IANA */ + "CP50227", /* Windows */ + "50227", /* Windows */ + "XCP50227", /* .NET */ + ), + iso2022_cn, ISO2022_CN, {iso2022_cn_mbtowc, NULL}, {iso2022_cn_wctomb, iso2022_cn_reset}) +DEFCODEPAGE(50227, iso2022_cn) + +DEFENCODING(("ISO2022CNEXT", /* IANA, RFC 1922 */ + ), + iso2022_cn_ext, ISO2022_CN_EXT, {iso2022_cn_ext_mbtowc, NULL}, + {iso2022_cn_ext_wctomb, iso2022_cn_ext_reset}) + +DEFENCODING(("HZ", /* RFC 1843 */ + "HZGB2312", /* IANA, RFC 1842 */ + "CP52936", /* Windows */ + "52936", /* Windows */ + ), + hz, HZ, {hz_mbtowc, NULL}, {hz_wctomb, hz_reset}) +DEFCODEPAGE(52936, hz) + +DEFENCODING(("EUCTW", /* glibc, HPUX, IRIX, OSF/1 */ + "CSEUCTW", "IBMEUCTW", /* AIX */ + "CNS11643", /* Solaris */ + "CP51950", /* Windows */ + "51950", /* Windows */ + ), + euc_tw, EUC_TW, {euc_tw_mbtowc, NULL}, {euc_tw_wctomb, NULL}) +DEFCODEPAGE(51950, euc_tw) + +DEFENCODING(("BIG5", /* IANA, JDK 1.1, glibc */ + "BIGFIVE", /* glibc */ + "CNBIG5", /* RFC 1922 */ + "CSBIG5", /* IANA */ + ), + ces_big5, BIG5, {ces_big5_mbtowc, NULL}, {ces_big5_wctomb, NULL}) + +DEFENCODING(("WINDOWS950", /* JDK 1.1 */ + "CP950", /* Windows */ + "950", /* Windows */ + ), + cp950, WINDOWS950, {cp950_mbtowc, NULL}, {cp950_wctomb, NULL}) +DEFCODEPAGE(950, cp950) + +DEFENCODING(("BIG5HKSCS:1999", /* libiconv */ + ), + big5hkscs1999, BIG5HKSCS_1999, {big5hkscs1999_mbtowc, big5hkscs1999_flushwc}, + {big5hkscs1999_wctomb, big5hkscs1999_reset}) + +DEFENCODING(("BIG5HKSCS:2001", /* libiconv */), big5hkscs2001, BIG5HKSCS_2001, + {big5hkscs2001_mbtowc, big5hkscs2001_flushwc}, {big5hkscs2001_wctomb, big5hkscs2001_reset}) + +DEFENCODING(("BIG5HKSCS:2004", /* libiconv */), big5hkscs2004, BIG5HKSCS_2004, + {big5hkscs2004_mbtowc, big5hkscs2004_flushwc}, {big5hkscs2004_wctomb, big5hkscs2004_reset}) + +DEFENCODING(("BIG5HKSCS", /* IANA, glibc */ + "BIG5HKSCS:2008", /* libiconv */ + ), + big5hkscs2008, BIG5HKSCS_2008, {big5hkscs2008_mbtowc, big5hkscs2008_flushwc}, + {big5hkscs2008_wctomb, big5hkscs2008_reset}) +DEFINDEX(BIG5HKSCS, BIG5HKSCS_2008) + +DEFENCODING(("EUCKR", /* IANA, RFC 1557, glibc, HP-UX, IRIX, OSF/1 */ + "CSEUCKR", /* IANA */ + "IBMEUCKR", /* AIX */ + "DECKOREAN", /* OSF/1 */ + "5601", /* Solaris */ + "CP51949", /* Windows */ + "51949", /* Windows */ + ), + euc_kr, EUC_KR, {euc_kr_mbtowc, NULL}, {euc_kr_wctomb, NULL}) +DEFCODEPAGE(51949, euc_kr) + +DEFENCODING(("UHC", /* glibc */ + "CP949", /* Windows */ + "949", /* Windows */ + "KSC56011987", /* Windows */ + ), + cp949, UHC, {cp949_mbtowc, NULL}, {cp949_wctomb, NULL}) +DEFCODEPAGE(949, cp949) + +DEFENCODING(("JOHAB", /* glibc */ + "KOKR.JOHAP92", /* Solaris */ + "CP1361", /* Windows */ + "1361", /* Windows */ + ), + johab, JOHAB, {johab_mbtowc, NULL}, {johab_wctomb, NULL}) +DEFCODEPAGE(1361, johab) + +DEFENCODING(("ISO2022KR", /* IANA, RFC 1557, JDK 1.1 */ + "CSISO2022KR", /* IANA */ + "CP50225", /* Windows */ + "50225", /* Windows */ + ), + iso2022_kr, ISO2022_KR, {iso2022_kr_mbtowc, NULL}, {iso2022_kr_wctomb, iso2022_kr_reset}) +DEFCODEPAGE(50225, iso2022_kr) + +DEFENCODING(("DECKANJI", /* OSF/1 */ + ), + dec_kanji, DEC_KANJI, {dec_kanji_mbtowc, NULL}, {dec_kanji_wctomb, NULL}) + +DEFENCODING(("DECHANYU", /* OSF/1 */ + ), + dec_hanyu, DEC_HANYU, {dec_hanyu_mbtowc, NULL}, {dec_hanyu_wctomb, NULL}) + +// Standard 8-bit encodings +DEFENCODING(("ISO88591", /* IANA, X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */ + "ISO88591:1987", /* IANA */ + "ISOIR100", /* IANA */ + "IBM819", /* IANA */ + "LATIN1", /* IANA */ + "L1", /* IANA */ + "CSISOLATIN1", /* IANA */ + "CP819", /* IANA */ + "819", /* Windows */ + "CP28591", /* Windows */ + "28591", /* Windows */ + ), + iso8859_1, ISO8859_1, {iso8859_1_mbtowc, NULL}, {iso8859_1_wctomb, NULL}) +DEFCODEPAGE(819, iso8859_1) +DEFCODEPAGE(28591, iso8859_1) + +DEFENCODING(("ISO88592", /* IANA, X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */ + "ISO88592:1987", /* IANA */ + "ISOIR101", /* IANA */ + "LATIN2", /* IANA */ + "L2", /* IANA */ + "CSISOLATIN2", /* IANA */ + "CP28592", /* Windows */ + "28592", /* Windows */ + ), + iso8859_2, ISO8859_2, {iso8859_2_mbtowc, NULL}, {iso8859_2_wctomb, NULL}) +DEFCODEPAGE(28592, iso8859_2) + +DEFENCODING(("ISO88593", /* IANA, X11R6.4, glibc, FreeBSD, Solaris */ + "ISO88593:1988", /* IANA */ + "ISOIR109", /* IANA */ + "LATIN3", /* IANA */ + "L3", /* IANA */ + "CSISOLATIN3", /* IANA */ + "CP28593", /* Windows */ + "28593", /* Windows */ + ), + iso8859_3, ISO8859_3, {iso8859_3_mbtowc, NULL}, {iso8859_3_wctomb, NULL}) +DEFCODEPAGE(28593, iso8859_3) + +DEFENCODING(("ISO88594", /* IANA, X11R6.4, glibc, FreeBSD, OSF/1, Solaris */ + "ISO88594:1988", /* IANA */ + "ISOIR110", /* IANA */ + "LATIN4", /* IANA */ + "L4", /* IANA */ + "CSISOLATIN4", /* IANA */ + "CP28594", /* Windows */ + "28594", /* Windows */ + ), + iso8859_4, ISO8859_4, {iso8859_4_mbtowc, NULL}, {iso8859_4_wctomb, NULL}) +DEFCODEPAGE(28594, iso8859_4) + +DEFENCODING(("ISO88595", /* IANA, X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */ + "ISO88595:1988", /* IANA */ + "ISOIR144", /* IANA */ + "CYRILLIC", /* IANA */ + "CSISOLATINCYRILLIC", /* IANA */ + "CP28595", /* Windows */ + "28595", /* Windows */ + ), + iso8859_5, ISO8859_5, {iso8859_5_mbtowc, NULL}, {iso8859_5_wctomb, NULL}) +DEFCODEPAGE(28595, iso8859_5) + +DEFENCODING(("ISO88596", /* IANA, X11R6.4, glibc, FreeBSD, AIX, Solaris */ + "ISO88596:1987", /* IANA */ + "ISOIR127", /* IANA */ + "ECMA114", /* IANA */ + "ASMO708", /* IANA */ + "ARABIC", /* IANA */ + "CSISOLATINARABIC", /* IANA */ + "CP28596", /* Windows */ + "28596", /* Windows */ + ), + iso8859_6, ISO8859_6, {iso8859_6_mbtowc, NULL}, {iso8859_6_wctomb, NULL}) +DEFCODEPAGE(28596, iso8859_6) + +DEFENCODING(("ISO88597", /* IANA, RFC 1947, X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */ + "ISO88597:1987", /* IANA */ + "ISO88597:2003", /* cppp-reiconv */ + "ISOIR126", /* IANA */ + "ECMA118", /* IANA */ + "ELOT928", /* IANA */ + "GREEK8", /* IANA */ + "GREEK", /* IANA */ + "CSISOLATINGREEK", /* IANA */ + "CP28597", /* Windows */ + "28597", /* Windows */ + ), + iso8859_7, ISO8859_7, {iso8859_7_mbtowc, NULL}, {iso8859_7_wctomb, NULL}) +DEFCODEPAGE(28597, iso8859_7) + +DEFENCODING(("ISO88598", /* IANA, X11R6.4, glibc, FreeBSD, AIX, OSF/1, Solaris */ + "ISO88598:1988", /* IANA */ + "ISOIR138", /* IANA */ + "HEBREW", /* IANA */ + "CSISOLATINHEBREW", /* IANA */ + "ISO88598I", /* .NET */ + "CP28598", /* Windows */ + "28598", /* Windows */ + "CP38598", /* Windows */ + "38598", /* Windows */ + ), + iso8859_8, ISO8859_8, {iso8859_8_mbtowc, NULL}, {iso8859_8_wctomb, NULL}) +DEFCODEPAGE(28598, iso8859_8) +DEFCODEPAGE(38598, iso8859_8) + +DEFENCODING(("ISO88599", /* IANA, X11R6.4, glibc, FreeBSD, AIX, IRIX, OSF/1, Solaris */ + "ISO88599:1989", /* IANA */ + "ISOIR148", /* IANA */ + "LATIN5", /* IANA */ + "L5", /* IANA */ + "CSISOLATIN5", /* IANA */ + "CP28599", /* Windows */ + "28599", /* Windows */ + ), + iso8859_9, ISO8859_9, {iso8859_9_mbtowc, NULL}, {iso8859_9_wctomb, NULL}) +DEFCODEPAGE(28599, iso8859_9) + +DEFENCODING(("ISO885910", /* IANA, X11R6.4, glibc, FreeBSD */ + "ISO885910:1992", /* IANA */ + "ISOIR157", /* IANA */ + "LATIN6", /* IANA */ + "L6", /* IANA */ + "CSISOLATIN6", /* IANA */ + ), + iso8859_10, ISO8859_10, {iso8859_10_mbtowc, NULL}, {iso8859_10_wctomb, NULL}) + +DEFENCODING(("ISO885911", /* glibc, X11R6.7, glibc */ + ), + iso8859_11, ISO8859_11, {iso8859_11_mbtowc, NULL}, {iso8859_11_wctomb, NULL}) + +DEFENCODING(("ISO885913", /* IANA, glibc, FreeBSD */ + "ISOIR179", /* glibc */ + "LATIN7", /* glibc */ + "L7", /* glibc */ + "IBM921" /* AIX */ + "CP28603", /* Windows */ + "28603", /* Windows */ + ), + iso8859_13, ISO8859_13, {iso8859_13_mbtowc, NULL}, {iso8859_13_wctomb, NULL}) +DEFCODEPAGE(28603, iso8859_13) + +DEFENCODING(("ISO885914", /* IANA, glibc, FreeBSD */ + "ISO885914:1998", /* IANA, glibc */ + "ISOIR199", /* IANA */ + "LATIN8", /* IANA, glibc */ + "L8", /* IANA, glibc */ + "ISOCELTIC", /* IANA */ + ), + iso8859_14, ISO8859_14, {iso8859_14_mbtowc, NULL}, {iso8859_14_wctomb, NULL}) + +DEFENCODING(("ISO885915", /* IANA, glibc, FreeBSD, AIX, OSF/1, Solaris */ + "ISO885915:1998", /* glibc */ + "ISOIR203", /* libiconv */ + "LATIN9", /* IANA */ + "L9", /* cppp-reiconv */ + "CSISO885915" /* IANA */ + "CP28605", /* Windows */ + "28605", /* Windows */ + ), + iso8859_15, ISO8859_15, {iso8859_15_mbtowc, NULL}, {iso8859_15_wctomb, NULL}) +DEFCODEPAGE(28605, iso8859_15) + +DEFENCODING(("ISO885916", /* IANA, glibc, FreeBSD */ + "ISO885916:2001", /* IANA */ + "ISOIR226", /* IANA */ + "LATIN10", /* IANA */ + "L10", /* IANA */ + "CSISOLATIN10", /* IANA */ + ), + iso8859_16, ISO8859_16, {iso8859_16_mbtowc, NULL}, {iso8859_16_wctomb, NULL}) + +DEFENCODING(("KOI8R", /* IANA, RFC 1489, X11R6.4, JDK 1.1 */ + "CSKOI8R", /* IANA */ + "CP20866", /* Windows */ + "20866", /* Windows */ + ), + koi8_r, KOI8_R, {koi8_r_mbtowc, NULL}, {koi8_r_wctomb, NULL}) +DEFCODEPAGE(20866, koi8_r) + +DEFENCODING(("KOI8U", /* IANA, RFC 2319 */ + "CSKOI8U", /* IANA */ + ), + koi8_u, KOI8_U, {koi8_u_mbtowc, NULL}, {koi8_u_wctomb, NULL}) + +DEFENCODING(("KOI8RU", /* AIX */ + "CSKOI8RU", /* cppp-reiconv */ + "IBM1168", /* AIX */ + "CP21866", /* Windows */ + "21866", /* Windows */ + ), + koi8_ru, KOI8_RU, {koi8_ru_mbtowc, NULL}, {koi8_ru_wctomb, NULL}) +DEFCODEPAGE(21866, koi8_ru) + +// Windows 8-bit encodings +DEFENCODING(("CP1250", /* JDK 1.1 */ + "CSWINDOWS1250", /* IANA */ + "WINDOWS1250", /* IANA */ + "IBM1250", /* AIX */ + "MSEE", /* Solaris */ + "1250", /* Windows */ + ), + cp1250, MSEE, {cp1250_mbtowc, NULL}, {cp1250_wctomb, NULL}) +DEFINDEX(CP1250, MSEE) +DEFCODEPAGE(1250, cp1250) + +DEFENCODING(("WINDOWS1251", /* IANA */ + "CSWINDOWS1251", /* IANA */ + "MSCYRL", /* (Unknown) */ + "ANSI1251", /* Solaris */ + "CP1251", /* Windows */ + "1251", /* Windows */ + ), + cp1251, MSCYRL, {cp1251_mbtowc, NULL}, {cp1251_wctomb, NULL}) +DEFINDEX(CP1251, MSCYRL) +DEFCODEPAGE(1251, cp1251) + +DEFENCODING(("WINDOWS1252", /* IANA */ + "CSWINDOWS1252", /* IANA */ + "IBM1252", /* AIX */ + "MSANSI", /* (Unknown) */ + "CP1252", /* Windows */ + "1252", /* Windows */ + ), + cp1252, MSANSI, {cp1252_mbtowc, NULL}, {cp1252_wctomb, NULL}) +DEFINDEX(CP1252, MSANSI) +DEFCODEPAGE(1252, cp1252) + +DEFENCODING(("WINDOWS1253", /* IANA */ + "CSWINDOWS1253", /* IANA */ + "MSGREEK", /* (Unknown) */ + "CP1253", /* Windows */ + "1253", /* Windows */ + ), + cp1253, MSGREEK, {cp1253_mbtowc, NULL}, {cp1253_wctomb, NULL}) +DEFINDEX(CP1253, MSGREEK) +DEFCODEPAGE(1253, cp1253) + +DEFENCODING(("WINDOWS1254", /* IANA */ + "CSWINDOWS1254", /* IANA */ + "IBM1254", /* AIX */ + "MSTURK", /* (Unknown) */ + "CP1254", /* Windows */ + "1254", /* Windows */ + ), + cp1254, MSTURK, {cp1254_mbtowc, NULL}, {cp1254_wctomb, NULL}) +DEFINDEX(CP1254, MSTURK) +DEFCODEPAGE(1254, cp1254) + +DEFENCODING(("WINDOWS1255", /* IANA */ + "CSWINDOWS1255", /* IANA */ + "MSHEBR", /* (Unknown) */ + "IBM1255", /* AIX */ + "CP1255", /* Windows */ + "1255", /* Windows */ + ), + cp1255, MSHEBR, {cp1255_mbtowc, cp1255_flushwc}, {cp1255_wctomb, NULL}) +DEFINDEX(CP1255, MSHEBR) +DEFCODEPAGE(1255, cp1255) + +DEFENCODING(("WINDOWS1256", /* IANA */ + "CSWINDOWS1256", /* IANA */ + "IBM1256", /* AIX */ + "MSARAB", /* (Unknown) */ + "CP1256", /* Windows */ + "1256", /* Windows */ + ), + cp1256, MSARAB, {cp1256_mbtowc, NULL}, {cp1256_wctomb, NULL}) +DEFINDEX(CP1256, MSARAB) +DEFCODEPAGE(1256, cp1256) + +DEFENCODING(("WINDOWS1257", /* IANA */ + "CSWINDOWS1257", /* IANA */ + "WINBALTRIM", /* (Unknown) */ + "IBM1257", /* AIX */ + "CP1257", /* Windows */ + "1257", /* Windows */ + ), + cp1257, WINBALTRIM, {cp1257_mbtowc, NULL}, {cp1257_wctomb, NULL}) +DEFINDEX(CP1257, WINBALTRIM) +DEFCODEPAGE(1257, cp1257) + +DEFENCODING(("WINDOWS1258", /* IANA */ + "CSWINDOWS1258", /* IANA */ + "IBM1258", /* AIX */ + "CP1258", /* Windows */ + "1258", /* Windows */ + ), + cp1258, WINDOWS1258, {cp1258_mbtowc, cp1258_flushwc}, {cp1258_wctomb, NULL}) +DEFINDEX(CP1258, WINDOWS1258) +DEFCODEPAGE(1258, cp1258) + +// DOS 8-bit encodings +DEFENCODING(("IBM850", /* IANA */ + "850", /* IANA */ + "CSPC850MULTILINGUAL", /* IANA */ + "CP850", /* Windows */ + ), + cp850, IBM850, {cp850_mbtowc, NULL}, {cp850_wctomb, NULL}) +DEFCODEPAGE(850, cp850) + +DEFENCODING(("IBM862", /* IANA */ + "862", /* IANA */ + "CSPC862LATINHEBREW", /* IANA */ + "DOS862", /* .NET */ + "CP862", /* Windows */ + ), + cp862, IBM862, {cp862_mbtowc, NULL}, {cp862_wctomb, NULL}) +DEFCODEPAGE(862, cp862) + +DEFENCODING(("IBM866", /* IANA */ + "866", /* IANA */ + "CSIBM866", /* IANA */ + "CP866", /* Windows */ + ), + cp866, IBM866, {cp866_mbtowc, NULL}, {cp866_wctomb, NULL}) +DEFCODEPAGE(866, cp866) + +DEFENCODING(("IBM1131", /* AIX */ + "CP1131", /* cppp-reiconv */ + "1131", /* cppp-reiconv */ + ), + cp1131, IBM1131, {cp1131_mbtowc, NULL}, {cp1131_wctomb, NULL}) +DEFCODEPAGE(1131, cp1131) + +// Macintosh 8-bit encodings +// This is the best table for MACINTOSH. The ones in glibc and FreeBSD-iconv are bad quality. :) +DEFENCODING(("MACROMAN", /* JDK 1.1 */ + "MACINTOSH", /* IANA */ + "MAC", /* IANA */ + "CSMACINTOSH", /* IANA */ + "CP10000", /* Windows */ + "10000", /* Windows */ + ), + mac_roman, MACINTOSH, {mac_roman_mbtowc, NULL}, {mac_roman_wctomb, NULL}) +DEFCODEPAGE(10000, mac_roman) +DEFINDEX(MAC_ROMAN, MACINTOSH) + +DEFENCODING(("MACCENTRALEUROPE", /* JDK 1.1 */ + "XMACCE", /* Windows */ + "CP10029", /* Windows */ + "10029", /* Windows */ + ), + mac_centraleurope, MAC_CENTRALEUROPE, {mac_centraleurope_mbtowc, NULL}, {mac_centraleurope_wctomb, NULL}) +DEFCODEPAGE(10029, mac_centraleurope) + +DEFENCODING(("MACICELAND", /* JDK 1.1 */ + "XMACICELANDIC", /* Windows */ + "CP10079", /* Windows */ + "10079", /* Windows */ + ), + mac_iceland, MAC_ICELAND, {mac_iceland_mbtowc, NULL}, {mac_iceland_wctomb, NULL}) +DEFCODEPAGE(10079, mac_iceland) + +DEFENCODING(("MACCROATIAN", /* JDK 1.1 */ + "XMACCROATIAN", /* Windows */ + "CP10082", /* Windows */ + "10082", /* Windows */ + ), + mac_croatian, MAC_CROATIAN, {mac_croatian_mbtowc, NULL}, {mac_croatian_wctomb, NULL}) +DEFCODEPAGE(10082, mac_croatian) + +DEFENCODING(("MACROMANIA", /* JDK 1.1 */ + "XMACROMANIAN", /* Windows */ + "CP10010", /* Windows */ + "10010", /* Windows */ + ), + mac_romania, MAC_ROMANIA, {mac_romania_mbtowc, NULL}, {mac_romania_wctomb, NULL}) +DEFCODEPAGE(10010, mac_romania) + +DEFENCODING(("MACCYRILLIC", /* JDK 1.1 */ + "XMACCYRILLIC", /* Windows */ + "CP10007", /* Windows */ + "10007", /* Windows */ + ), + mac_cyrillic, MAC_CYRILLIC, {mac_cyrillic_mbtowc, NULL}, {mac_cyrillic_wctomb, NULL}) +DEFCODEPAGE(10007, mac_cyrillic) + +DEFENCODING(("MACUKRAINE", /* JDK 1.1 */ + "XMACUKRAINIAN", /* Windows */ + "CP10017", /* Windows */ + "10017", /* Windows */ + ), + mac_ukraine, MAC_UKRAINE, {mac_ukraine_mbtowc, NULL}, {mac_ukraine_wctomb, NULL}) +DEFCODEPAGE(10017, mac_ukraine) + +DEFENCODING(("MACGREEK", /* JDK 1.1 */ + "XMACGREEK", /* Windows */ + "CP10006", /* Windows */ + "10006", /* Windows */ + ), + mac_greek, MAC_GREEK, {mac_greek_mbtowc, NULL}, {mac_greek_wctomb, NULL}) +DEFCODEPAGE(10006, mac_greek) + +DEFENCODING(("MACTURKISH", /* JDK 1.1 */ + "XMACTURKISH", /* Windows */ + "CP10081", /* Windows */ + "10081", /* Windows */ + ), + mac_turkish, MAC_TURKISH, {mac_turkish_mbtowc, NULL}, {mac_turkish_wctomb, NULL}) +DEFCODEPAGE(10081, mac_turkish) + +DEFENCODING(("MACHEBREW", /* JDK 1.1 */ + "XMACHEBREW", /* Windows */ + "CP10005", /* Windows */ + "10005", /* Windows */ + ), + mac_hebrew, MAC_HEBREW, {mac_hebrew_mbtowc, NULL}, {mac_hebrew_wctomb, NULL}) +DEFCODEPAGE(10005, mac_hebrew) + +DEFENCODING(("MACARABIC", /* JDK 1.1 */ + "XMACARABIC", /* Windows */ + "CP10004", /* Windows */ + "10004", /* Windows */ + ), + mac_arabic, MAC_ARABIC, {mac_arabic_mbtowc, NULL}, {mac_arabic_wctomb, NULL}) +DEFCODEPAGE(10004, mac_arabic) + +DEFENCODING(("MACTHAI", /* JDK 1.1 */ + "XMACTHAI", /* Windows */ + "CP10021", /* Windows */ + "10021", /* Windows */ + ), + mac_thai, MAC_THAI, {mac_thai_mbtowc, NULL}, {mac_thai_wctomb, NULL}) +DEFCODEPAGE(10021, mac_thai) + +// Other platform specific 8-bit encodings +DEFENCODING(("HPROMAN8", /* IANA, X11R6.4 */ + "ROMAN8", /* IANA */ + "R8", /* IANA */ + "CSHPROMAN8", /* IANA */ + "CP1051", /* Windows */ + ), + hp_roman8, HPROMAN8, {hp_roman8_mbtowc, NULL}, {hp_roman8_wctomb, NULL}) + +DEFENCODING(("NEXTSTEP", /* (Unknown) */ + ), + nextstep, NEXTSTEP, {nextstep_mbtowc, NULL}, {nextstep_wctomb, NULL}) + +// Regional 8-bit encodings used for a single language +DEFENCODING(("ARMSCII8", /* Armenia Standard */ + ), + armscii_8, ARMSCII8, {armscii_8_mbtowc, NULL}, {armscii_8_wctomb, NULL}) + +DEFENCODING(("GEORGIANACADEMY", /* Georgia Academy */ + ), + georgian_academy, GEORGIANACADEMY, {georgian_academy_mbtowc, NULL}, {georgian_academy_wctomb, NULL}) + +DEFENCODING(("GEORGIANPS", /* Georgia PS */ + ), + georgian_ps, GEORGIANPS, {georgian_ps_mbtowc, NULL}, {georgian_ps_wctomb, NULL}) + +DEFENCODING(("KOI8T", /* (Unknown) */ + ), + koi8_t, KOI8T, {koi8_t_mbtowc, NULL}, {koi8_t_wctomb, NULL}) + +DEFENCODING(("PT154", /* IANA, glibc */ + "PTCP154", /* IANA */ + "CYRILLICASIAN", /* IANA */ + "CSPTCP154", /* IANA */ + "IBM1169", /* AIX */ + "CYRIILLICASIAN", /* AIX */ + "CP154", /* cppp-reiconv */ + "154", /* cppp-reiconv */ + ), + pt154, PT154, {pt154_mbtowc, NULL}, {pt154_wctomb, NULL}) +DEFCODEPAGE(154, pt154) + +DEFENCODING(("RK1048", /* IANA, glibc */ + "STRK10482002", /* IANA */ + "KZ1048", /* IANA */ + "CSKZ1048", /* IANA */ + ), + rk1048, RK1048, {rk1048_mbtowc, NULL}, {rk1048_wctomb, NULL}) + +DEFENCODING(("MULELAO1", /* (Unknown) */ + ), + mulelao, MULELAO1, {mulelao_mbtowc, NULL}, {mulelao_wctomb, NULL}) + +DEFENCODING(("IBMCP1133", /* (Unknown) */ + "CP1133", /* cppp-reiconv */ + "1133", /* cppp-reiconv */ + ), + cp1133, IBMCP1133, {cp1133_mbtowc, NULL}, {cp1133_wctomb, NULL}) +DEFCODEPAGE(1133, cp1133) + +DEFENCODING(("TIS620", /* IANA, glibc, HP-UX */ + "TIS6200", /* glibc */ + "TIS620.25291", /* glibc */ + "TIS620.25330", /* glibc */ + "TIS620.25331", "ISOIR166", /* glibc */ + "TACTIS", /* OSF/1 */ + "TIS620.2533", /* Solaris */ + ), + tis620, TIS620, {tis620_mbtowc, NULL}, {tis620_wctomb, NULL}) + +DEFENCODING(("WINDOWS874", /* IANA */ + "CSWINDOWS874", /* IANA */ + "MS874", /* AIX */ + "CP874", /* Windows */ + "874", /* Windows */ + ), + cp874, WINDOWS874, {cp874_mbtowc, NULL}, {cp874_wctomb, NULL}) +DEFCODEPAGE(874, cp874) + +DEFENCODING(("VISCII", /* IANA, RFC 1456 */ + "VISCII1.11", /* IANA */ + "CSVISCII", /* IANA */ + ), + viscii, VISCII, {viscii_mbtowc, NULL}, {viscii_wctomb, NULL}) + +DEFENCODING(("TCVN", /* (Unknown) */ + "TCVN5712", /* (Unknown) */ + "TCVN57121", /* (Unknown) */ + "TCVN57121:1993", /* (Unknown) */ + ), + tcvn, TCVN, {tcvn_mbtowc, tcvn_flushwc}, {tcvn_wctomb, NULL}) + +// CJK character sets (not documented) +DEFENCODING(("JISC62201969RO", /* IANA */ + "ISO646JP", /* IANA */ + "ISOIR14", /* IANA */ + "JP", /* IANA */ + "CSISO14JISC6220RO", /* IANA */ + ), + iso646_jp, JP, {iso646_jp_mbtowc, NULL}, {iso646_jp_wctomb, NULL}) + +DEFENCODING(("JISX0201", /* IANA */ + "JISX02011976", "X0201", /* IANA */ + "CSHALFWIDTHKATAKANA", /* IANA */ + ), + jisx0201, JISX0201, {jisx0201_mbtowc, NULL}, {jisx0201_wctomb, NULL}) + +DEFENCODING(("JISX0208", "JISX02081983", /* IANA */ + "JISX02081990", "JIS0208", "X0208", /* IANA */ + "ISOIR87", /* IANA */ + "JISC62261983", /* IANA */ + "CSISO87JISX0208", /* IANA */ + ), + jisx0208, JISX0208, {jisx0208_mbtowc, NULL}, {jisx0208_wctomb, NULL}) + +DEFENCODING(("JISX0212", "JISX0212.19900", "JISX02121990", /* IANA */ + "X0212", /* IANA */ + "ISOIR159", /* IANA */ + "CSISO159JISX02121990", /* IANA */ + ), + jisx0212, JISX0212, {jisx0212_mbtowc, NULL}, {jisx0212_wctomb, NULL}) + +DEFENCODING(("GB198880", /* IANA */ + "ISO646CN", /* IANA */ + "ISOIR57", /* IANA */ + "CN", /* IANA */ + "CSISO57GB1988", /* IANA */ + ), + iso646_cn, GB1988_80, {iso646_cn_mbtowc, NULL}, {iso646_cn_wctomb, NULL}) + +DEFENCODING(("GB231280", /* IANA */ + "ISOIR58", /* IANA */ + "CSISO58GB231280", /* IANA */ + ), + gb2312, GB2312_80, {gb2312_mbtowc, NULL}, {gb2312_wctomb, NULL}) + +DEFENCODING(("ISOIR165", "CNGBISOIR165", /* RFC 1922 */ + ), + isoir165, CNGBISOIR165, {isoir165_mbtowc, NULL}, {isoir165_wctomb, NULL}) + +DEFENCODING(("KSC5601", /* IANA */ + "KSC56011987", /* IANA */ + "KSC56011989", /* IANA */ + "ISOIR149", /* IANA */ + "CSKSC56011987", /* IANA */ + "KOREAN", /* IANA */ + ), + ksc5601, KOREAN, {ksc5601_mbtowc, NULL}, {ksc5601_wctomb, NULL}) + +// AIX locales +DEFENCODING(("IBM856", /* AIX */ + "CP856", /* AIX */ + "856", /* AIX */ + ), + cp856, IBM856, {cp856_mbtowc, NULL}, {cp856_wctomb, NULL}) +DEFCODEPAGE(856, cp856) + +DEFENCODING(("IBM922", /* AIX */ + "CP922", /* AIX */ + "922", /* AIX */ + ), + cp922, IBM922, {cp922_mbtowc, NULL}, {cp922_wctomb, NULL}) +DEFCODEPAGE(922, cp922) + +DEFENCODING(("IBM943", /* AIX */ + "CP943", /* AIX */ + "943", /* AIX */ + ), + cp943, IBM943, {cp943_mbtowc, NULL}, {cp943_wctomb, NULL}) +DEFCODEPAGE(943, cp943) + +DEFENCODING(("IBM1046", /* AIX */ + "CP1046", /* AIX */ + "1046", /* AIX */ + ), + cp1046, IBM1046, {cp1046_mbtowc, NULL}, {cp1046_wctomb, NULL}) +DEFCODEPAGE(1046, cp1046) + +DEFENCODING(("IBM1124", /* AIX */ + "CP1124", /* AIX */ + "1124", /* AIX */ + ), + cp1124, IBM1124, {cp1124_mbtowc, NULL}, {cp1124_wctomb, NULL}) +DEFCODEPAGE(1124, cp1124) + +DEFENCODING(("IBM1129", /* AIX */ + "CP1129", /* AIX */ + "1129", /* AIX */ + ), + cp1129, IBM1129, {cp1129_mbtowc, NULL}, {cp1129_wctomb, NULL}) +DEFCODEPAGE(1129, cp1129) + +DEFENCODING(("IBM1161", /* glibc */ + "CSIBM1161", /* glibc */ + "CP1161", /* AIX */ + "1161", /* AIX */ + ), + cp1161, IBM1161, {cp1161_mbtowc, NULL}, {cp1161_wctomb, NULL}) +DEFCODEPAGE(1161, cp1161) + +DEFENCODING(("IBM1162", /* glibc */ + "CSIBM1162", /* glibc */ + "CP1162", /* AIX */ + "1162", /* AIX */ + ), + cp1162, IBM1162, {cp1162_mbtowc, NULL}, {cp1162_wctomb, NULL}) +DEFCODEPAGE(1162, cp1162) + +DEFENCODING(("IBM1163", /* glibc */ + "CSIBM1163", /* glibc */ + "CP1163", /* AIX */ + "1163", /* AIX */ + ), + cp1163, IBM1163, {cp1163_mbtowc, NULL}, {cp1163_wctomb, NULL}) +DEFCODEPAGE(1163, cp1163) + +// MS-DOS locales +DEFENCODING(("IBM437", /* IANA */ + "437", /* IANA */ + "CSPC8CODEPAGE437", /* IANA */ + "CP437", /* IANA */ + ), + cp437, CP437, {cp437_mbtowc, NULL}, {cp437_wctomb, NULL}) +DEFCODEPAGE(437, cp437) + +DEFENCODING(("IBM737", /* Windows */ + "CP737", /* Windows */ + "737", /* Windows */ + ), + cp737, CP737, {cp737_mbtowc, NULL}, {cp737_wctomb, NULL}) +DEFCODEPAGE(737, cp737) + +DEFENCODING(("IBM775", /* IANA */ + "CSPC775BALTIC", /* IANA */ + "CP775", /* Windows */ + "775", /* Windows */ + ), + cp775, CP775, {cp775_mbtowc, NULL}, {cp775_wctomb, NULL}) +DEFCODEPAGE(775, cp775) + +DEFENCODING(("IBM852", /* IANA */ + "852", /* IANA */ + "CSPCP852", /* IANA */ + "CP852", /* Windows */ + ), + cp852, CP852, {cp852_mbtowc, NULL}, {cp852_wctomb, NULL}) +DEFCODEPAGE(852, cp852) + +DEFENCODING(("IBM853", /* (Unknown) */ + "853", /* (Unknown) */ + "CCSID853", /* dbpedia.org */ + "CSIBM853", /* (Unknown) */ + "CP853" /* cppp-reiconv */ + ), + cp853, CP853, {cp853_mbtowc, NULL}, {cp853_wctomb, NULL}) +DEFCODEPAGE(853, cp853) + +DEFENCODING(("IBM855", /* IANA */ + "855", /* IANA */ + "CSIBM855", /* IANA */ + "CP855" /* Windows */ + ), + cp855, CP855, {cp855_mbtowc, NULL}, {cp855_wctomb, NULL}) +DEFCODEPAGE(855, cp855) + +DEFENCODING(("IBM857", /* IANA */ + "857", /* IANA */ + "CSIBM857", /* IANA */ + "CP857", /* Windows */ + ), + cp857, CP857, {cp857_mbtowc, NULL}, {cp857_wctomb, NULL}) +DEFCODEPAGE(857, cp857) + +DEFENCODING(("IBM858", /* Solaris */ + "858", /* Solaris */ + "IBM00858", /* Windows */ + "CP858", /* Windows */ + "CCSID00858", /* Solaris */ + "CP00858", /* Solaris */ + "CSIBM858" /* Solaris */ + ), + cp858, CP858, {cp858_mbtowc, NULL}, {cp858_wctomb, NULL}) +DEFCODEPAGE(858, cp858) + +DEFENCODING(("IBM860", /* IANA */ + "860", /* IANA */ + "CSIBM860", /* IANA */ + "CP860", /* AIX */ + ), + cp860, CP860, {cp860_mbtowc, NULL}, {cp860_wctomb, NULL}) +DEFCODEPAGE(860, cp860) + +DEFENCODING(("IBM861", /* IANA */ + "861", /* IANA */ + "CP861", /* IANA */ + "CPIS", /* IANA */ + "CSIBM861", /* IANA */ + ), + cp861, CP861, {cp861_mbtowc, NULL}, {cp861_wctomb, NULL}) +DEFCODEPAGE(861, cp861) + +DEFENCODING(("IBM863", /* IANA */ + "863", /* IANA */ + "CSIBM863", /* IANA */ + "CP863", /* AIX */ + ), + cp863, CP863, {cp863_mbtowc, NULL}, {cp863_wctomb, NULL}) +DEFCODEPAGE(863, cp863) + +DEFENCODING(("IBM864", /* IANA */ + "CSIBM864", /* IANA */ + "CP864", /* AIX */ + "864", /* IANA */ + ), + cp864, CP864, {cp864_mbtowc, NULL}, {cp864_wctomb, NULL}) +DEFCODEPAGE(864, cp864) + +DEFENCODING(("IBM865", /* IANA */ + "865", /* IANA */ + "CSIBM865", /* IANA */ + "CP865", /* AIX */ + ), + cp865, CP865, {cp865_mbtowc, NULL}, {cp865_wctomb, NULL}) +DEFCODEPAGE(865, cp865) + +DEFENCODING(("IBM869", /* IANA */ + "869", /* IANA */ + "CPGR", /* IANA */ + "CSIBM869", /* IANA */ + "CP869", /* AIX */ + "CP-GR", /* AIX */ + ), + cp869, CP869, {cp869_mbtowc, NULL}, {cp869_wctomb, NULL}) +DEFCODEPAGE(869, cp869) + +DEFENCODING(("IBM1125", /* AIX */ + "1125", /* AIX */ + "SYSTEM1125", /* AIX */ + "CSIBM1125", /* AIX */ + "RUSCII", /* AIX */ + "CP866U", /* AIX */ + "CP1125", /* AIX */ + ), + cp1125, CP1125, {cp1125_mbtowc, NULL}, {cp1125_wctomb, NULL}) +DEFCODEPAGE(1125, cp1125) + +// z/OS locales +DEFENCODING(("IBM037", /* IANA */ + "EBCDICCPUS", /* IANA */ + "EBCDICCPCA", /* IANA */ + "EBCDICCPWT", /* IANA */ + "EBCDICCPNL", /* IANA */ + "CSIBM037", /* IANA */ + "CP037", /* IANA */ + "CP0037", /* IANA */ + ), + ebcdic037, EBCDIC_037, {ebcdic037_mbtowc, NULL}, {ebcdic037_wctomb, NULL}) +DEFCODEPAGE(37, ebcdic037) + +DEFENCODING(("IBM273", /* IANA */ + "CSIBM273", /* IANA */ + "CP273", /* AIX */ + "273", /* AIX */ + ), + ebcdic273, EBCDIC_273, {ebcdic273_mbtowc, NULL}, {ebcdic273_wctomb, NULL}) +DEFCODEPAGE(273, ebcdic273) +DEFCODEPAGE(20273, ebcdic273) + +DEFENCODING(("IBM277", /* IANA */ + "EBCDICCPDK", /* IANA */ + "EBCDICCPNO", /* IANA */ + "CSIBM277", /* IANA */ + "CP277", /* AIX */ + "277", /* AIX */ + ), + ebcdic277, EBCDIC_277, {ebcdic277_mbtowc, NULL}, {ebcdic277_wctomb, NULL}) +DEFCODEPAGE(277, ebcdic277) +DEFCODEPAGE(20277, ebcdic277) + +DEFENCODING(("IBM278", /* IANA */ + "EBCDICCPFI", /* IANA */ + "EBCDICCPSE", /* IANA */ + "CSIBM278", /* IANA */ + "CP278", /* AIX */ + "278", /* AIX */ + ), + ebcdic278, EBCDIC_278, {ebcdic278_mbtowc, NULL}, {ebcdic278_wctomb, NULL}) +DEFCODEPAGE(278, ebcdic278) +DEFCODEPAGE(20278, ebcdic278) + +DEFENCODING(("IBM280", /* IANA */ + "EBCDICCPIT", /* IANA */ + "CSIBM280", /* IANA */ + "CP280", /* AIX */ + "280", /* AIX */ + ), + ebcdic280, EBCDIC_280, {ebcdic280_mbtowc, NULL}, {ebcdic280_wctomb, NULL}) +DEFCODEPAGE(280, ebcdic280) +DEFCODEPAGE(20280, ebcdic280) + +DEFENCODING(("IBM282", /* (Unknown) */ + "282", /* cppp-reiconv */ + "CP282", /* cppp-reiconv */ + ), + ebcdic282, EBCDIC_282, {ebcdic282_mbtowc, NULL}, {ebcdic282_wctomb, NULL}) +DEFCODEPAGE(282, ebcdic282) + +DEFENCODING(("IBM284", /* IANA */ + "EBCDICCPES", /* IANA */ + "CSIBM284", /* IANA */ + "CP284", /* AIX */ + "284", /* AIX */ + ), + ebcdic284, EBCDIC_284, {ebcdic284_mbtowc, NULL}, {ebcdic284_wctomb, NULL}) +DEFCODEPAGE(284, ebcdic284) +DEFCODEPAGE(20284, ebcdic284) + +DEFENCODING(("IBM285", /* IANA */ + "CP285", /* IANA */ + "EBCDICCPGB", /* IANA */ + "CSIBM285", /* IANA */ + "285", /* AIX */ + ), + ebcdic285, EBCDIC_285, {ebcdic285_mbtowc, NULL}, {ebcdic285_wctomb, NULL}) +DEFCODEPAGE(285, ebcdic285) +DEFCODEPAGE(20285, ebcdic285) + +DEFENCODING(("IBM297", /* IANA */ + "EBCDICCPFR", /* IANA */ + "CSIBM297", /* IANA */ + "CP297", /* AIX */ + "297", /* AIX */ + ), + ebcdic297, EBCDIC_297, {ebcdic297_mbtowc, NULL}, {ebcdic297_wctomb, NULL}) +DEFCODEPAGE(297, ebcdic297) +DEFCODEPAGE(20297, ebcdic297) + +DEFENCODING(("IBM423", /* IANA */ + "EBCDICCPGR", /* IANA */ + "CSIBM423", /* IANA */ + "CP423", /* AIX */ + "423", /* AIX */ + ), + ebcdic423, EBCDIC_423, {ebcdic423_mbtowc, NULL}, {ebcdic423_wctomb, NULL}) +DEFCODEPAGE(423, ebcdic423) +DEFCODEPAGE(20423, ebcdic423) + +DEFENCODING(("IBM424", /* IANA */ + "EBCDICCPHE", /* IANA */ + "CSIBM424", /* IANA */ + "CP424", /* AIX */ + "424", /* AIX */ + ), + ebcdic424, EBCDIC_424, {ebcdic424_mbtowc, NULL}, {ebcdic424_wctomb, NULL}) +DEFCODEPAGE(424, ebcdic424) +DEFCODEPAGE(20424, ebcdic424) + +DEFENCODING(("IBM425", /* (Unknown) */ + "CP425", /* cppp-reiconv */ + "425", /* cppp-reiconv */ + ), + ebcdic425, EBCDIC_425, {ebcdic425_mbtowc, NULL}, {ebcdic425_wctomb, NULL}) +DEFCODEPAGE(425, ebcdic425) + +DEFENCODING(("IBM500", /* IANA */ + "EBCDICCPBE", /* IANA */ + "EBCDICCPCH", /* IANA */ + "CSIBM500", /* IANA */ + "CP500", /* AIX */ + "500", /* AIX */ + ), + ebcdic500, EBCDIC_500, {ebcdic500_mbtowc, NULL}, {ebcdic500_wctomb, NULL}) + +DEFCODEPAGE(500, ebcdic500) + +DEFENCODING(("IBM838", /* AIX */ + "IBMTHAI", /* IANA */ + "CSIBMTHAI", /* IANA */ + "CP838", /* AIX */ + "838", /* AIX */ + ), + ebcdic838, EBCDIC_838, {ebcdic838_mbtowc, NULL}, {ebcdic838_wctomb, NULL}) +DEFCODEPAGE(838, ebcdic838) + +DEFENCODING(("IBM870", /* IANA */ + "CP870", /* IANA */ + "EBCDICCPROECE", /* IANA */ + "EBCDICCPYU", /* IANA */ + "CSIBM870", /* IANA */ + "870", /* AIX */ + ), + ebcdic870, EBCDIC_870, {ebcdic870_mbtowc, NULL}, {ebcdic870_wctomb, NULL}) +DEFCODEPAGE(870, ebcdic870) + +DEFENCODING(("IBM871", /* IANA */ + "EBCDICCPIS", /* IANA */ + "CSIBM871", /* IANA */ + "CP871", /* AIX */ + "871", /* AIX */ + ), + ebcdic871, EBCDIC_871, {ebcdic871_mbtowc, NULL}, {ebcdic871_wctomb, NULL}) +DEFCODEPAGE(871, ebcdic871) +DEFCODEPAGE(20871, ebcdic871) + +DEFENCODING(("IBM875", /* glibc */ + "EBCDICGREEK", /* glibc */ + "CP875", /* AIX */ + "875", /* AIX */ + ), + ebcdic875, EBCDIC_875, {ebcdic875_mbtowc, NULL}, {ebcdic875_wctomb, NULL}) +DEFCODEPAGE(875, ebcdic875) + +DEFENCODING(("IBM880", /* IANA */ + "EBCDICCYRILLIC", /* IANA */ + "CSIBM880", /* IANA */ + "CP880", /* cppp-reiconv */ + "880", /*cppp-reiconv*/ + ), + ebcdic880, EBCDIC_880, {ebcdic880_mbtowc, NULL}, {ebcdic880_wctomb, NULL}) +DEFCODEPAGE(880, ebcdic880) +DEFCODEPAGE(20880, ebcdic880) + +DEFENCODING(("IBM905", /* IANA */ + "EBCDICCPTR", /* IANA */ + "CSIBM905", /* IANA */ + ), + ebcdic905, EBCDIC_905, {ebcdic905_mbtowc, NULL}, {ebcdic905_wctomb, NULL}) +DEFCODEPAGE(905, ebcdic905) +DEFCODEPAGE(20905, ebcdic905) + +DEFENCODING(("IBM924", /* SUSE Linux Enterprise Server */ + "IBM00924", /* IANA */ + "CCSID00924", /* IANA */ + "CP00924", /* IANA */ + "EBCDICLATIN9EURO", /* IANA */ + "CSIBM00924", /* IANA */ + "CP924", /* SUSE Linux Enterprise Server */ + "924", /* SUSE Linux Enterprise Server */ + ), + ebcdic924, EBCDIC_924, {ebcdic924_mbtowc, NULL}, {ebcdic924_wctomb, NULL}) +DEFCODEPAGE(924, ebcdic924) +DEFCODEPAGE(20924, ebcdic924) + +DEFENCODING(("IBM1025", /* glibc */ + "CP1025", /* AIX */ + "1025", /* AIX */ + ), + ebcdic1025, EBCDIC_1025, {ebcdic1025_mbtowc, NULL}, {ebcdic1025_wctomb, NULL}) +DEFCODEPAGE(1025, ebcdic1025) + +DEFENCODING(("IBM1026", /* IANA */ + "CSIBM1026", /* IANA */ + "CP1026", /* AIX */ + "1026", /* AIX */ + ), + ebcdic1026, EBCDIC_1026, {ebcdic1026_mbtowc, NULL}, {ebcdic1026_wctomb, NULL}) +DEFCODEPAGE(1026, ebcdic1026) + +DEFENCODING(("IBM1047", /* IANA */ + "CSIBM1047", /* IANA */ + "CP1047", /* AIX */ + "1047", /* AIX */ + ), + ebcdic1047, EBCDIC_1047, {ebcdic1047_mbtowc, NULL}, {ebcdic1047_wctomb, NULL}) +DEFCODEPAGE(1047, ebcdic1047) + +DEFENCODING(("IBM1097", /* glibc */ + "CP1097", /* AIX */ + ), + ebcdic1097, EBCDIC_1097, {ebcdic1097_mbtowc, NULL}, {ebcdic1097_wctomb, NULL}) +DEFCODEPAGE(1097, ebcdic1097) + +DEFENCODING(("IBM1112", /* glibc */ + "CP1112", /* AIX */ + "1112", /* AIX */ + ), + ebcdic1112, EBCDIC_1112, {ebcdic1112_mbtowc, NULL}, {ebcdic1112_wctomb, NULL}) +DEFCODEPAGE(1112, ebcdic1112) + +DEFENCODING(("IBM1122", /* glibc */ + "CP1122", /* AIX */ + "1122", /* AIX */ + ), + ebcdic1122, EBCDIC_1122, {ebcdic1122_mbtowc, NULL}, {ebcdic1122_wctomb, NULL}) +DEFCODEPAGE(1122, ebcdic1122) + +DEFENCODING(("IBM1123", /* glibc */ + "CP1123", /* AIX */ + "1123", /* AIX */ + ), + ebcdic1123, EBCDIC_1123, {ebcdic1123_mbtowc, NULL}, {ebcdic1123_wctomb, NULL}) +DEFCODEPAGE(1123, ebcdic1123) + +DEFENCODING(("IBM1130", /* glibc */ + "CP1130", /* cppp-reiconv */ + "1130", /* cppp-reiconv */ + ), + ebcdic1130, EBCDIC_1130, {ebcdic1130_mbtowc, NULL}, {ebcdic1130_wctomb, NULL}) +DEFCODEPAGE(1130, ebcdic1130) + +DEFENCODING(("IBM1132", /* glibc */ + "CP1132", /* cppp-reiconv */ + "1132", /* cppp-reiconv */ + ), + ebcdic1132, EBCDIC_1132, {ebcdic1132_mbtowc, NULL}, {ebcdic1132_wctomb, NULL}) +DEFCODEPAGE(1132, ebcdic1132) + +DEFENCODING(("IBM1137", /* glibc */ + "CP1137", /* cppp-reiconv */ + "1137", /* cppp-reiconv */ + ), + ebcdic1137, EBCDIC_1137, {ebcdic1137_mbtowc, NULL}, {ebcdic1137_wctomb, NULL}) +DEFCODEPAGE(1137, ebcdic1137) + +DEFENCODING(("IBM1140", /* IANA */ + "IBM01140", /* IANA */ + "CCSID01140", /* IANA */ + "CP01140", /* IANA */ + "EBCDICUS37+EURO", /* IANA */ + "CSIBM01140", /* IANA */ + "CP1140", /* AIX */ + "1140", /* AIX */ + ), + ebcdic1140, EBCDIC_1140, {ebcdic1140_mbtowc, NULL}, {ebcdic1140_wctomb, NULL}) +DEFCODEPAGE(1140, ebcdic1140) + +DEFENCODING(("IBM1141", /* IANA */ + "IBM01141", /* IANA */ + "CCSID01141", /* IANA */ + "CP01141", /* IANA */ + "EBCDICDE273+EURO", /* IANA */ + "CSIBM01141", /* IANA */ + "CP1141", /* AIX */ + "1141", /* AIX */ + ), + ebcdic1141, EBCDIC_1141, {ebcdic1141_mbtowc, NULL}, {ebcdic1141_wctomb, NULL}) +DEFCODEPAGE(1141, ebcdic1141) + +DEFENCODING(("IBM1142", /* AIX */ + "IBM01142", /* IANA */ + "CCSID01142", /* IANA */ + "CP01142", /* IANA */ + "EBCDICDK277+EURO", /* IANA */ + "EBCDICNO277+EURO", /* IANA */ + "CSIBM01142", /* IANA */ + "CP1142", /* AIX */ + "1142", /* AIX */ + ), + ebcdic1142, EBCDIC_1142, {ebcdic1142_mbtowc, NULL}, {ebcdic1142_wctomb, NULL}) +DEFCODEPAGE(1142, ebcdic1142) + +DEFENCODING(("IBM1143", /* AIX */ + "IBM01143", /* IANA */ + "CCSID01143", /* IANA */ + "CP01143", /* IANA */ + "EBCDICFI278+EURO", /* IANA */ + "EBCDICSE278+EURO", /* IANA */ + "CSIBM01143", /* IANA */ + "CP1143", /* AIX */ + "1143", /* AIX */ + ), + ebcdic1143, EBCDIC_1143, {ebcdic1143_mbtowc, NULL}, {ebcdic1143_wctomb, NULL}) +DEFCODEPAGE(1143, ebcdic1143) + +DEFENCODING(("IBM1144", /* AIX */ + "IBM01144", /* IANA */ + "CCSID01144", /* IANA */ + "CP01144", /* IANA */ + "EBCDICIT280+EURO", /* IANA */ + "CSPC8CODEPAGE1144", /* IANA */ + "CP1144", /* AIX */ + "1144", /* AIX */ + ), + ebcdic1144, EBCDIC_1144, {ebcdic1144_mbtowc, NULL}, {ebcdic1144_wctomb, NULL}) +DEFCODEPAGE(1144, ebcdic1144) + +DEFENCODING(("IBM1145", /* AIX */ + "IBM01145", /* IANA */ + "CCSID01145", /* IANA */ + "CP01145", /* IANA */ + "EBCDICES284+EURO", /* IANA */ + "CSIBM01145", /* IANA */ + "CP1145", /* AIX */ + "1145", /* AIX */ + ), + ebcdic1145, EBCDIC_1145, {ebcdic1145_mbtowc, NULL}, {ebcdic1145_wctomb, NULL}) +DEFCODEPAGE(1145, ebcdic1145) + +DEFENCODING(("IBM1146", /* AIX */ + "IBM01146", /* IANA */ + "CCSID01146", /* IANA */ + "CP01146", /* IANA */ + "EBCDICGB285+EURO", /* IANA */ + "CSPC8CODEPAGE1146", /* IANA */ + "CP1146", /* AIX */ + "1146", /* AIX */ + ), + ebcdic1146, EBCDIC_1146, {ebcdic1146_mbtowc, NULL}, {ebcdic1146_wctomb, NULL}) +DEFCODEPAGE(1146, ebcdic1146) + +DEFENCODING(("IBM1147", /* AIX */ + "IBM01147", /* IANA */ + "CCSID01147", /* IANA */ + "CP01147", /* IANA */ + "EBCDICFR297+EURO", /* IANA */ + "CSIBM01147", /* IANA */ + "CP1147", /* AIX */ + "1147", /* AIX */ + ), + ebcdic1147, EBCDIC_1147, {ebcdic1147_mbtowc, NULL}, {ebcdic1147_wctomb, NULL}) +DEFCODEPAGE(1147, ebcdic1147) + +DEFENCODING(("IBM1148", /* AIX */ + "IBM01148", /* IANA */ + "CCSID01148", /* IANA */ + "CP01148", /* IANA */ + "EBCDICINTERNATIONAL500+EURO", /* IANA */ + "CSIBM01148", /* IANA */ + "CP1148", /* AIX */ + "1148", /* AIX */ + ), + ebcdic1148, EBCDIC_1148, {ebcdic1148_mbtowc, NULL}, {ebcdic1148_wctomb, NULL}) +DEFCODEPAGE(1148, ebcdic1148) + +DEFENCODING(("IBM1149", /* AIX */ + "IBM01149", /* IANA */ + "CCSID01149", /* IANA */ + "CP01149", /* IANA */ + "EBCDICIS871+EURO", /* IANA */ + "CSIBM01149", /* IANA */ + "CP1149", /* AIX */ + "1149", /* AIX */ + ), + ebcdic1149, EBCDIC_1149, {ebcdic1149_mbtowc, NULL}, {ebcdic1149_wctomb, NULL}) +DEFCODEPAGE(1149, ebcdic1149) + +DEFENCODING(("IBM1153", /* glibc */ + "CP1153", /* cppp-reiconv */ + "1153", /* cppp-reiconv */ + ), + ebcdic1153, EBCDIC_1153, {ebcdic1153_mbtowc, NULL}, {ebcdic1153_wctomb, NULL}) +DEFCODEPAGE(1153, ebcdic1153) + +DEFENCODING(("IBM1154", /* glibc */ + "CP1154", /* cppp-reiconv */ + "1154", /* cppp-reiconv */ + ), + ebcdic1154, EBCDIC_1154, {ebcdic1154_mbtowc, NULL}, {ebcdic1154_wctomb, NULL}) +DEFCODEPAGE(1154, ebcdic1154) + +DEFENCODING(("IBM1155", /* glibc */ + "CP1155", /* cppp-reiconv */ + "1155", /* cppp-reiconv */ + ), + ebcdic1155, EBCDIC_1155, {ebcdic1155_mbtowc, NULL}, {ebcdic1155_wctomb, NULL}) +DEFCODEPAGE(1155, ebcdic1155) + +DEFENCODING(("IBM1156", /* glibc */ + "CP1156", /* cppp-reiconv */ + "1156", /* cppp-reiconv */ + ), + ebcdic1156, EBCDIC_1156, {ebcdic1156_mbtowc, NULL}, {ebcdic1156_wctomb, NULL}) +DEFCODEPAGE(1156, ebcdic1156) + +DEFENCODING(("IBM1157", /* glibc */ + "CP1157", /* cppp-reiconv */ + "1157", /* cppp-reiconv */ + ), + ebcdic1157, EBCDIC_1157, {ebcdic1157_mbtowc, NULL}, {ebcdic1157_wctomb, NULL}) +DEFCODEPAGE(1157, ebcdic1157) + +DEFENCODING(("IBM1158", /* glibc */ + "CP1158", /* cppp-reiconv */ + "1158", /* cppp-reiconv */ + ), + ebcdic1158, EBCDIC_1158, {ebcdic1158_mbtowc, NULL}, {ebcdic1158_wctomb, NULL}) +DEFCODEPAGE(1158, ebcdic1158) + +DEFENCODING(("IBM1160", /* glibc */ + "CP1160", /* cppp-reiconv */ + "1160", /* cppp-reiconv */ + ), + ebcdic1160, EBCDIC_1160, {ebcdic1160_mbtowc, NULL}, {ebcdic1160_wctomb, NULL}) +DEFCODEPAGE(1160, ebcdic1160) + +DEFENCODING(("IBM1164", /* glibc */ + "CP1164", /* cppp-reiconv */ + "1164", /* cppp-reiconv */ + ), + ebcdic1164, EBCDIC_1164, {ebcdic1164_mbtowc, NULL}, {ebcdic1164_wctomb, NULL}) +DEFCODEPAGE(1164, ebcdic1164) + +DEFENCODING(("IBM1165", /* libiconv */ + "CP1165", /* cppp-reiconv */ + "1165", /* cppp-reiconv */ + ), + ebcdic1165, EBCDIC_1165, {ebcdic1165_mbtowc, NULL}, {ebcdic1165_wctomb, NULL}) +DEFCODEPAGE(1165, ebcdic1165) + +DEFENCODING(("IBM1166", /* glibc */ + "CP1166", /* cppp-reiconv */ + "1166", /* cppp-reiconv */ + ), + ebcdic1166, EBCDIC_1166, {ebcdic1166_mbtowc, NULL}, {ebcdic1166_wctomb, NULL}) +DEFCODEPAGE(1166, ebcdic1166) + +DEFENCODING(("IBM4971", /* glibc */ + "CP4971", /* cppp-reiconv */ + "4971", /* cppp-reiconv */ + ), + ebcdic4971, EBCDIC_4971, {ebcdic4971_mbtowc, NULL}, {ebcdic4971_wctomb, NULL}) +DEFCODEPAGE(4971, ebcdic4971) + +DEFENCODING(("IBM12712", /* glibc */ + "CP12712", /* cppp-reiconv */ + "12712", /* cppp-reiconv */ + ), + ebcdic12712, EBCDIC_12712, {ebcdic12712_mbtowc, NULL}, {ebcdic12712_wctomb, NULL}) +DEFCODEPAGE(12712, ebcdic12712) + +DEFENCODING(("IBM16804", /* glibc */ + "CP16804", /* cppp-reiconv */ + "16804", /* cppp-reiconv */ + ), + ebcdic16804, EBCDIC_16804, {ebcdic16804_mbtowc, NULL}, {ebcdic16804_wctomb, NULL}) +DEFCODEPAGE(16804, ebcdic16804) + +// Extra encodigns +DEFENCODING(("EUCJISX0213", /* x0213.org */ + "EUCJIS2004", /* x0213.org */ + ), + euc_jisx0213, EUC_JISX0213, {euc_jisx0213_mbtowc, euc_jisx0213_flushwc}, + {euc_jisx0213_wctomb, euc_jisx0213_reset}) + +DEFENCODING(("SHIFTJISX0213", /* x0213.org */ + "SHIFTJIS2004", /* x0213.org */ + ), + shift_jisx0213, SHIFT_JISX0213, {shift_jisx0213_mbtowc, shift_jisx0213_flushwc}, + {shift_jisx0213_wctomb, shift_jisx0213_reset}) + +DEFENCODING(("ISO2022JP3", /* x0213.org */ + "ISO2022JP2004", /* x0213.org */ + ), + iso2022_jp3, ISO2022_JP3, {iso2022_jp3_mbtowc, iso2022_jp3_flushwc}, + {iso2022_jp3_wctomb, iso2022_jp3_reset}) + +DEFENCODING(("BIG52003", /* (Unknown) */ + ), + big5_2003, BIG5_2003, {big5_2003_mbtowc, NULL}, {big5_2003_wctomb, NULL}) + +DEFENCODING(("TDS565", /* (Unknown) */ + "ISOIR230", /* (Unknown) */ + ), + tds565, TDS565, {tds565_mbtowc, NULL}, {tds565_wctomb, NULL}) + +DEFENCODING(("ATARIST", /* (Unknown) */ + "ATARI", /* (Unknown) */ + ), + atarist, ATARIST, {atarist_mbtowc, NULL}, {atarist_wctomb, NULL}) +DEFINDEX(ATARI, ATARIST) + +DEFENCODING(("RISCOSLATIN1", /* (Unknown) */ + ), + riscos1, RISCOS_LATIN1, {riscos1_mbtowc, NULL}, {riscos1_wctomb, NULL}) diff --git a/lib/encodings_aix.def b/lib/encodings_aix.def deleted file mode 100644 index fda56fa0..00000000 --- a/lib/encodings_aix.def +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright (C) 2000-2002, 2008 Free Software Foundation, Inc. - This file is part of the cppp-reiconv library. - - The cppp-reiconv library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 3 - of the License, or (at your option) any later version. - - The cppp-reiconv library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the cppp-reiconv library; see the file COPYING. - If not, see . */ - -/* Encodings used by system dependent locales on AIX. */ - -DEFENCODING(( "CP856", - ), - 856, - cp856, - { cp856_mbtowc, NULL }, { cp856_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-856", /* AIX */ - cp856) -#endif - -DEFENCODING(( "CP922", - ), - 922, - cp922, - { cp922_mbtowc, NULL }, { cp922_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-922", /* AIX */ - cp922) -#endif - -DEFENCODING(( "CP943", - ), - 943, - cp943, - { cp943_mbtowc, NULL }, { cp943_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-943", /* AIX */ - cp943) -#endif - -DEFENCODING(( "CP1046", - ), - 1046, - cp1046, - { cp1046_mbtowc, NULL }, { cp1046_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-1046", /* AIX */ - cp1046) -#endif - -DEFENCODING(( "CP1124", - ), - 1124, - cp1124, - { cp1124_mbtowc, NULL }, { cp1124_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-1124", /* AIX */ - cp1124) -#endif - -DEFENCODING(( "CP1129", - ), - 1129, - cp1129, - { cp1129_mbtowc, NULL }, { cp1129_wctomb, NULL }) -#ifdef USE_AIX_ALIASES -DEFALIAS( "IBM-1129", /* AIX */ - cp1129) -#endif - -DEFENCODING(( "CP1161", - "IBM1161", /* glibc */ - "IBM-1161", /* glibc */ - "csIBM1161", /* glibc */ - ), - 1161, - cp1161, - { cp1161_mbtowc, NULL }, { cp1161_wctomb, NULL }) - -DEFENCODING(( "CP1162", - "IBM1162", /* glibc */ - "IBM-1162", /* glibc */ - "csIBM1162", /* glibc */ - ), - 1162, - cp1162, - { cp1162_mbtowc, NULL }, { cp1162_wctomb, NULL }) - -DEFENCODING(( "CP1163", - "IBM1163", /* glibc */ - "IBM-1163", /* glibc */ - "csIBM1163", /* glibc */ - ), - 1163, - cp1163, - { cp1163_mbtowc, NULL }, { cp1163_wctomb, NULL }) diff --git a/lib/encodings_dos.def b/lib/encodings_dos.def deleted file mode 100644 index b9d350df..00000000 --- a/lib/encodings_dos.def +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright (C) 2001-2002 Free Software Foundation, Inc. - This file is part of the cppp-reiconv library. - - The cppp-reiconv library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 3 - of the License, or (at your option) any later version. - - The cppp-reiconv library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the cppp-reiconv library; see the file COPYING. - If not, see . */ - -/* Encodings used by system dependent locales on MSDOS. */ - -DEFENCODING(( "CP437", /* IANA, JDK 1.1 */ - "IBM437", /* IANA */ - "437", /* IANA */ - "csPC8CodePage437", /* IANA */ - ), - 437, - cp437, - { cp437_mbtowc, NULL }, { cp437_wctomb, NULL }) - -DEFENCODING(( "CP737", /* JDK 1.1 */ - "IBM737", /* Windows */ - ), - 737, - cp737, - { cp737_mbtowc, NULL }, { cp737_wctomb, NULL }) - -DEFENCODING(( "CP775", /* IANA, JDK 1.1 */ - "IBM775", /* IANA */ - "csPC775Baltic", /* IANA */ - ), - 775, - cp775, - { cp775_mbtowc, NULL }, { cp775_wctomb, NULL }) - -DEFENCODING(( "CP852", /* IANA, JDK 1.1 */ - "IBM852", /* IANA */ - "852", /* IANA */ - "csPCp852", /* IANA */ - ), - 852, - cp852, - { cp852_mbtowc, NULL }, { cp852_wctomb, NULL }) - -DEFENCODING(( "CP853", - ), - 853, - cp853, - { cp853_mbtowc, NULL }, { cp853_wctomb, NULL }) - -DEFENCODING(( "CP855", /* IANA, JDK 1.1 */ - "IBM855", /* IANA */ - "855", /* IANA */ - "csIBM855", /* IANA */ - ), - 855, - cp855, - { cp855_mbtowc, NULL }, { cp855_wctomb, NULL }) - -DEFENCODING(( "CP857", /* IANA, JDK 1.1 */ - "IBM857", /* IANA */ - "857", /* IANA */ - "csIBM857", /* IANA */ - ), - 857, - cp857, - { cp857_mbtowc, NULL }, { cp857_wctomb, NULL }) - -DEFENCODING(( "CP858", /* JDK 1.1.7 */ - ), - 858, - cp858, - { cp858_mbtowc, NULL }, { cp858_wctomb, NULL }) - -DEFENCODING(( "CP860", /* IANA, JDK 1.1 */ - "IBM860", /* IANA */ - "860", /* IANA */ - "csIBM860", /* IANA */ - ), - 860, - cp860, - { cp860_mbtowc, NULL }, { cp860_wctomb, NULL }) - -DEFENCODING(( "CP861", /* IANA, JDK 1.1 */ - "IBM861", /* IANA */ - "861", /* IANA */ - "CP-IS", /* IANA */ - "csIBM861", /* IANA */ - ), - 861, - cp861, - { cp861_mbtowc, NULL }, { cp861_wctomb, NULL }) - -DEFENCODING(( "CP863", /* IANA, JDK 1.1 */ - "IBM863", /* IANA */ - "863", /* IANA */ - "csIBM863", /* IANA */ - ), - 863, - cp863, - { cp863_mbtowc, NULL }, { cp863_wctomb, NULL }) - -DEFENCODING(( "CP864", /* IANA, JDK 1.1 */ - "IBM864", /* IANA */ - "csIBM864", /* IANA */ - ), - 864, - cp864, - { cp864_mbtowc, NULL }, { cp864_wctomb, NULL }) - -DEFENCODING(( "CP865", /* IANA, JDK 1.1 */ - "IBM865", /* IANA */ - "865", /* IANA */ - "csIBM865", /* IANA */ - ), - 865, - cp865, - { cp865_mbtowc, NULL }, { cp865_wctomb, NULL }) - -DEFENCODING(( "CP869", /* IANA, JDK 1.1 */ - "IBM869", /* IANA */ - "869", /* IANA */ - "CP-GR", /* IANA */ - "csIBM869", /* IANA */ - ), - 869, - cp869, - { cp869_mbtowc, NULL }, { cp869_wctomb, NULL }) - -DEFENCODING(( "CP1125", /* ICU */ - ), - 1125, - cp1125, - { cp1125_mbtowc, NULL }, { cp1125_wctomb, NULL }) diff --git a/lib/encodings_extra.def b/lib/encodings_extra.def deleted file mode 100644 index 11a52043..00000000 --- a/lib/encodings_extra.def +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2002, 2005, 2008 Free Software Foundation, Inc. - This file is part of the cppp-reiconv library. - - The cppp-reiconv library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 3 - of the License, or (at your option) any later version. - - The cppp-reiconv library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the cppp-reiconv library; see the file COPYING. - If not, see . */ - -DEFENCODING(( "EUC-JISX0213", - "EUC-JIS-2004", /* x0213.org */ - ), - -1, - euc_jisx0213, - { euc_jisx0213_mbtowc, euc_jisx0213_flushwc }, { euc_jisx0213_wctomb, euc_jisx0213_reset }) - -DEFENCODING(( "SHIFT_JISX0213", - "SHIFT_JIS-2004", /* x0213.org */ - ), - -1, - shift_jisx0213, - { shift_jisx0213_mbtowc, shift_jisx0213_flushwc }, { shift_jisx0213_wctomb, shift_jisx0213_reset }) - -DEFENCODING(( "ISO-2022-JP-3", - "ISO-2022-JP-2004", /* x0213.org */ - ), - -1, - iso2022_jp3, - { iso2022_jp3_mbtowc, iso2022_jp3_flushwc }, { iso2022_jp3_wctomb, iso2022_jp3_reset }) - -DEFENCODING(( "BIG5-2003", - ), - -1, - big5_2003, - { big5_2003_mbtowc, NULL }, { big5_2003_wctomb, NULL }) - -DEFENCODING(( "TDS565", - "ISO-IR-230", - ), - -1, - tds565, - { tds565_mbtowc, NULL }, { tds565_wctomb, NULL }) - -DEFENCODING(( "ATARIST", - "ATARI", - ), - -1, - atarist, - { atarist_mbtowc, NULL }, { atarist_wctomb, NULL }) - -DEFENCODING(( "RISCOS-LATIN1", - ), - -1, - riscos1, - { riscos1_mbtowc, NULL }, { riscos1_wctomb, NULL }) diff --git a/lib/encodings_osf1.def b/lib/encodings_osf1.def deleted file mode 100644 index 2ba1c36e..00000000 --- a/lib/encodings_osf1.def +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2001, 2008 Free Software Foundation, Inc. - This file is part of the cppp-reiconv library. - - The cppp-reiconv library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 3 - of the License, or (at your option) any later version. - - The cppp-reiconv library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the cppp-reiconv library; see the file COPYING. - If not, see . */ - -/* Encodings used by system dependent locales on OSF/1 a.k.a. Tru64. */ - -DEFENCODING(( "DEC-KANJI", - ), - -1, - dec_kanji, - { dec_kanji_mbtowc, NULL }, { dec_kanji_wctomb, NULL }) -#ifdef USE_OSF1_ALIASES -DEFALIAS( "DECKANJI", /* OSF/1 */ - dec_kanji) -#endif - -DEFENCODING(( "DEC-HANYU", - ), - -1, - dec_hanyu, - { dec_hanyu_mbtowc, NULL }, { dec_hanyu_wctomb, NULL }) -#ifdef USE_OSF1_ALIASES -DEFALIAS( "DECHANYU", /* OSF/1 */ - dec_hanyu) -#endif diff --git a/lib/encodings_zos.def b/lib/encodings_zos.def deleted file mode 100644 index d7f455c1..00000000 --- a/lib/encodings_zos.def +++ /dev/null @@ -1,524 +0,0 @@ -/* Copyright (C) 2022 Free Software Foundation, Inc. - This file is part of the cppp-reiconv library. - - The cppp-reiconv library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 3 - of the License, or (at your option) any later version. - - The cppp-reiconv library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the cppp-reiconv library; see the file COPYING. - If not, see . */ - -/* Encodings used by system dependent locales on z/OS. */ - -DEFENCODING(( "IBM-037", - "IBM037", /* IANA */ - "CP037", /* IANA */ - "EBCDIC-CP-US", /* IANA */ - "EBCDIC-CP-CA", /* IANA */ - "EBCDIC-CP-WT", /* IANA */ - "EBCDIC-CP-NL", /* IANA */ - "csIBM037", /* IANA */ - ), - 037, - ebcdic037, - { ebcdic037_mbtowc, NULL }, { ebcdic037_wctomb, NULL }) - -DEFENCODING(( "IBM-273", - "IBM273", /* IANA */ - "CP273", /* IANA */ - "csIBM273", /* IANA */ - ), - 273, - ebcdic273, - { ebcdic273_mbtowc, NULL }, { ebcdic273_wctomb, NULL }) - -DEFENCODING(( "IBM-277", - "IBM277", /* IANA */ - "EBCDIC-CP-DK", /* IANA */ - "EBCDIC-CP-NO", /* IANA */ - "csIBM277", /* IANA */ - ), - 277, - ebcdic277, - { ebcdic277_mbtowc, NULL }, { ebcdic277_wctomb, NULL }) - -DEFENCODING(( "IBM-278", - "IBM278", /* IANA */ - "CP278", /* IANA */ - "EBCDIC-CP-FI", /* IANA */ - "EBCDIC-CP-SE", /* IANA */ - "csIBM278", /* IANA */ - ), - 278, - ebcdic278, - { ebcdic278_mbtowc, NULL }, { ebcdic278_wctomb, NULL }) - -DEFENCODING(( "IBM-280", - "IBM280", /* IANA */ - "CP280", /* IANA */ - "EBCDIC-CP-IT", /* IANA */ - "csIBM280", /* IANA */ - ), - 280, - ebcdic280, - { ebcdic280_mbtowc, NULL }, { ebcdic280_wctomb, NULL }) - -DEFENCODING(( "IBM-282", - "IBM282", - ), - 282, - ebcdic282, - { ebcdic282_mbtowc, NULL }, { ebcdic282_wctomb, NULL }) - -DEFENCODING(( "IBM-284", - "IBM284", /* IANA */ - "CP284", /* IANA */ - "EBCDIC-CP-ES", /* IANA */ - "csIBM284", /* IANA */ - ), - 284, - ebcdic284, - { ebcdic284_mbtowc, NULL }, { ebcdic284_wctomb, NULL }) - -DEFENCODING(( "IBM-285", - "IBM285", /* IANA */ - "CP285", /* IANA */ - "EBCDIC-CP-GB", /* IANA */ - "csIBM285", /* IANA */ - ), - 285, - ebcdic285, - { ebcdic285_mbtowc, NULL }, { ebcdic285_wctomb, NULL }) - -DEFENCODING(( "IBM-297", - "IBM297", /* IANA */ - "CP297", /* IANA */ - "EBCDIC-CP-FR", /* IANA */ - "csIBM297", /* IANA */ - ), - 297, - ebcdic297, - { ebcdic297_mbtowc, NULL }, { ebcdic297_wctomb, NULL }) - -DEFENCODING(( "IBM-423", - "IBM423", /* IANA */ - "CP423", /* IANA */ - "EBCDIC-CP-GR", /* IANA */ - "csIBM423", /* IANA */ - ), - 423, - ebcdic423, - { ebcdic423_mbtowc, NULL }, { ebcdic423_wctomb, NULL }) - -DEFENCODING(( "IBM-424", - "IBM424", /* IANA */ - "CP424", /* IANA */ - "EBCDIC-CP-HE", /* IANA */ - "csIBM424", /* IANA */ - ), - 424, - ebcdic424, - { ebcdic424_mbtowc, NULL }, { ebcdic424_wctomb, NULL }) - -DEFENCODING(( "IBM-425", - "IBM425", - ), - 425, - ebcdic425, - { ebcdic425_mbtowc, NULL }, { ebcdic425_wctomb, NULL }) - -DEFENCODING(( "IBM-500", - "IBM500", /* IANA */ - "CP500", /* IANA */ - "EBCDIC-CP-BE", /* IANA */ - "EBCDIC-CP-CH", /* IANA */ - "csIBM500", /* IANA */ - ), - 500, - ebcdic500, - { ebcdic500_mbtowc, NULL }, { ebcdic500_wctomb, NULL }) - -DEFENCODING(( "IBM-838", - "IBM838", - "IBM-THAI", /* IANA */ - "csIBMThai", /* IANA */ - ), - 838, - ebcdic838, - { ebcdic838_mbtowc, NULL }, { ebcdic838_wctomb, NULL }) - -DEFENCODING(( "IBM-870", - "IBM870", /* IANA */ - "CP870", /* IANA */ - "EBCDIC-CP-ROECE", /* IANA */ - "EBCDIC-CP-YU", /* IANA */ - "csIBM870", /* IANA */ - ), - 870, - ebcdic870, - { ebcdic870_mbtowc, NULL }, { ebcdic870_wctomb, NULL }) - -DEFENCODING(( "IBM-871", - "IBM871", /* IANA */ - "CP871", /* IANA */ - "EBCDIC-CP-IS", /* IANA */ - "csIBM871", /* IANA */ - ), - 871, - ebcdic871, - { ebcdic871_mbtowc, NULL }, { ebcdic871_wctomb, NULL }) - -DEFENCODING(( "IBM-875", - "IBM875", /* glibc */ - "CP875", /* glibc */ - "EBCDIC-GREEK", /* glibc */ - ), - 875, - ebcdic875, - { ebcdic875_mbtowc, NULL }, { ebcdic875_wctomb, NULL }) - -DEFENCODING(( "IBM-880", - "IBM880", /* IANA */ - "CP880", /* IANA */ - "EBCDIC-CYRILLIC", /* IANA */ - "csIBM880", /* IANA */ - ), - 880, - ebcdic880, - { ebcdic880_mbtowc, NULL }, { ebcdic880_wctomb, NULL }) - -DEFENCODING(( "IBM-905", - "IBM905", /* IANA */ - "CP905", /* IANA */ - "EBCDIC-CP-TR", /* IANA */ - "csIBM905", /* IANA */ - ), - 905, - ebcdic905, - { ebcdic905_mbtowc, NULL }, { ebcdic905_wctomb, NULL }) - -DEFENCODING(( "IBM-924", - "IBM924", - "IBM00924", /* IANA */ - "CCSID00924", /* IANA */ - "CP00924", /* IANA */ - "EBCDIC-LATIN9-EURO", /* IANA */ - "csIBM00924", /* IANA */ - ), - 924, - ebcdic924, - { ebcdic924_mbtowc, NULL }, { ebcdic924_wctomb, NULL }) - -DEFENCODING(( "IBM-1025", - "IBM1025", /* glibc */ - "CP1025", /* glibc */ - ), - 1025, - ebcdic1025, - { ebcdic1025_mbtowc, NULL }, { ebcdic1025_wctomb, NULL }) - -DEFENCODING(( "IBM-1026", - "IBM1026", /* IANA */ - "CP1026", /* IANA */ - "csIBM1026", /* IANA */ - ), - 1026, - ebcdic1026, - { ebcdic1026_mbtowc, NULL }, { ebcdic1026_wctomb, NULL }) - -DEFENCODING(( "IBM-1047", /* IANA */ - "IBM1047", /* IANA */ - "CP1047", /* glibc */ - "csIBM1047", /* IANA */ - ), - 1047, - ebcdic1047, - { ebcdic1047_mbtowc, NULL }, { ebcdic1047_wctomb, NULL }) - -DEFENCODING(( "IBM-1097", - "IBM1097", /* glibc */ - "CP1097", /* glibc */ - ), - 1097, - ebcdic1097, - { ebcdic1097_mbtowc, NULL }, { ebcdic1097_wctomb, NULL }) - -DEFENCODING(( "IBM-1112", - "IBM1112", /* glibc */ - "CP1112", /* glibc */ - ), - 1112, - ebcdic1112, - { ebcdic1112_mbtowc, NULL }, { ebcdic1112_wctomb, NULL }) - -DEFENCODING(( "IBM-1122", - "IBM1122", /* glibc */ - "CP1122", /* glibc */ - ), - 1122, - ebcdic1122, - { ebcdic1122_mbtowc, NULL }, { ebcdic1122_wctomb, NULL }) - -DEFENCODING(( "IBM-1123", - "IBM1123", /* glibc */ - "CP1123", /* glibc */ - ), - 1123, - ebcdic1123, - { ebcdic1123_mbtowc, NULL }, { ebcdic1123_wctomb, NULL }) - -DEFENCODING(( "IBM-1130", - "IBM1130", /* glibc */ - "CP1130", /* glibc */ - ), - 1130, - ebcdic1130, - { ebcdic1130_mbtowc, NULL }, { ebcdic1130_wctomb, NULL }) - -DEFENCODING(( "IBM-1132", - "IBM1132", /* glibc */ - "CP1132", /* glibc */ - ), - 1132, - ebcdic1132, - { ebcdic1132_mbtowc, NULL }, { ebcdic1132_wctomb, NULL }) - -DEFENCODING(( "IBM-1137", - "IBM1137", /* glibc */ - "CP1137", /* glibc */ - ), - 1137, - ebcdic1137, - { ebcdic1137_mbtowc, NULL }, { ebcdic1137_wctomb, NULL }) - -DEFENCODING(( "IBM-1140", - "IBM1140", - "IBM01140", /* IANA */ - "CCSID01140", /* IANA */ - "CP01140", /* IANA */ - "EBCDIC-US-37+EURO", /* IANA */ - "csIBM01140", /* IANA */ - ), - 1140, - ebcdic1140, - { ebcdic1140_mbtowc, NULL }, { ebcdic1140_wctomb, NULL }) - -DEFENCODING(( "IBM-1141", - "IBM1141", - "IBM01141", /* IANA */ - "CCSID01141", /* IANA */ - "CP01141", /* IANA */ - "EBCDIC-DE-273+EURO", /* IANA */ - "csIBM01141", /* IANA */ - ), - 1141, - ebcdic1141, - { ebcdic1141_mbtowc, NULL }, { ebcdic1141_wctomb, NULL }) - -DEFENCODING(( "IBM-1142", - "IBM1142", - "IBM01142", /* IANA */ - "CCSID01142", /* IANA */ - "CP01142", /* IANA */ - "EBCDIC-DK-277+EURO", /* IANA */ - "EBCDIC-NO-277+EURO", /* IANA */ - "csIBM01142", /* IANA */ - ), - 1142, - ebcdic1142, - { ebcdic1142_mbtowc, NULL }, { ebcdic1142_wctomb, NULL }) - -DEFENCODING(( "IBM-1143", - "IBM1143", - "IBM01143", /* IANA */ - "CCSID01143", /* IANA */ - "CP01143", /* IANA */ - "EBCDIC-FI-278+EURO", /* IANA */ - "EBCDIC-SE-278+EURO", /* IANA */ - "csIBM01143", /* IANA */ - ), - 1143, - ebcdic1143, - { ebcdic1143_mbtowc, NULL }, { ebcdic1143_wctomb, NULL }) - -DEFENCODING(( "IBM-1144", - "IBM1144", - "IBM01144", /* IANA */ - "CCSID01144", /* IANA */ - "CP01144", /* IANA */ - "EBCDIC-IT-280+EURO", /* IANA */ - "csPC8CodePage1144", /* IANA */ - ), - 1144, - ebcdic1144, - { ebcdic1144_mbtowc, NULL }, { ebcdic1144_wctomb, NULL }) - -DEFENCODING(( "IBM-1145", - "IBM1145", - "IBM01145", /* IANA */ - "CCSID01145", /* IANA */ - "CP01145", /* IANA */ - "EBCDIC-ES-284+EURO", /* IANA */ - "csIBM01145", /* IANA */ - ), - 1145, - ebcdic1145, - { ebcdic1145_mbtowc, NULL }, { ebcdic1145_wctomb, NULL }) - -DEFENCODING(( "IBM-1146", - "IBM1146", - "IBM01146", /* IANA */ - "CCSID01146", /* IANA */ - "CP01146", /* IANA */ - "EBCDIC-GB-285+EURO", /* IANA */ - "csPC8CodePage1146", /* IANA */ - ), - 1146, - ebcdic1146, - { ebcdic1146_mbtowc, NULL }, { ebcdic1146_wctomb, NULL }) - -DEFENCODING(( "IBM-1147", - "IBM1147", - "IBM01147", /* IANA */ - "CCSID01147", /* IANA */ - "CP01147", /* IANA */ - "EBCDIC-FR-297+EURO", /* IANA */ - "csIBM01147", /* IANA */ - ), - 1147, - ebcdic1147, - { ebcdic1147_mbtowc, NULL }, { ebcdic1147_wctomb, NULL }) - -DEFENCODING(( "IBM-1148", - "IBM1148", - "IBM01148", /* IANA */ - "CCSID01148", /* IANA */ - "CP01148", /* IANA */ - "EBCDIC-INTERNATIONAL-500+EURO", /* IANA */ - "csIBM01148", /* IANA */ - ), - 1148, - ebcdic1148, - { ebcdic1148_mbtowc, NULL }, { ebcdic1148_wctomb, NULL }) - -DEFENCODING(( "IBM-1149", - "IBM1149", - "IBM01149", /* IANA */ - "CCSID01149", /* IANA */ - "CP01149", /* IANA */ - "EBCDIC-IS-871+EURO", /* IANA */ - "csIBM01149", /* IANA */ - ), - 1149, - ebcdic1149, - { ebcdic1149_mbtowc, NULL }, { ebcdic1149_wctomb, NULL }) - -DEFENCODING(( "IBM-1153", - "IBM1153", /* glibc */ - "CP1153", /* glibc */ - ), - 1153, - ebcdic1153, - { ebcdic1153_mbtowc, NULL }, { ebcdic1153_wctomb, NULL }) - -DEFENCODING(( "IBM-1154", - "IBM1154", /* glibc */ - "CP1154", /* glibc */ - ), - 1154, - ebcdic1154, - { ebcdic1154_mbtowc, NULL }, { ebcdic1154_wctomb, NULL }) - -DEFENCODING(( "IBM-1155", - "IBM1155", /* glibc */ - "CP1155", /* glibc */ - ), - 1155, - ebcdic1155, - { ebcdic1155_mbtowc, NULL }, { ebcdic1155_wctomb, NULL }) - -DEFENCODING(( "IBM-1156", - "IBM1156", /* glibc */ - "CP1156", /* glibc */ - ), - 1156, - ebcdic1156, - { ebcdic1156_mbtowc, NULL }, { ebcdic1156_wctomb, NULL }) - -DEFENCODING(( "IBM-1157", - "IBM1157", /* glibc */ - "CP1157", /* glibc */ - ), - 1157, - ebcdic1157, - { ebcdic1157_mbtowc, NULL }, { ebcdic1157_wctomb, NULL }) - -DEFENCODING(( "IBM-1158", - "IBM1158", /* glibc */ - "CP1158", /* glibc */ - ), - 1158, - ebcdic1158, - { ebcdic1158_mbtowc, NULL }, { ebcdic1158_wctomb, NULL }) - -DEFENCODING(( "IBM-1160", - "IBM1160", /* glibc */ - "CP1160", /* glibc */ - ), - 1160, - ebcdic1160, - { ebcdic1160_mbtowc, NULL }, { ebcdic1160_wctomb, NULL }) - -DEFENCODING(( "IBM-1164", - "IBM1164", /* glibc */ - "CP1164", /* glibc */ - ), - 1164, - ebcdic1164, - { ebcdic1164_mbtowc, NULL }, { ebcdic1164_wctomb, NULL }) - -DEFENCODING(( "IBM-1165", - "IBM1165", - ), - 1165, - ebcdic1165, - { ebcdic1165_mbtowc, NULL }, { ebcdic1165_wctomb, NULL }) - -DEFENCODING(( "IBM-1166", - "IBM1166", /* glibc */ - "CP1166", /* glibc */ - ), - 1166, - ebcdic1166, - { ebcdic1166_mbtowc, NULL }, { ebcdic1166_wctomb, NULL }) - -DEFENCODING(( "IBM-4971", - "IBM4971", /* glibc */ - "CP4971", /* glibc */ - ), - 4971, - ebcdic4971, - { ebcdic4971_mbtowc, NULL }, { ebcdic4971_wctomb, NULL }) - -DEFENCODING(( "IBM-12712", - "IBM12712", /* glibc */ - "CP12712", /* glibc */ - ), - 12712, - ebcdic12712, - { ebcdic12712_mbtowc, NULL }, { ebcdic12712_wctomb, NULL }) - -DEFENCODING(( "IBM-16804", - "IBM16804", /* glibc */ - "CP16804", /* glibc */ - ), - 16804, - ebcdic16804, - { ebcdic16804_mbtowc, NULL }, { ebcdic16804_wctomb, NULL }) diff --git a/lib/euc_cn.h b/lib/euc_cn.h deleted file mode 100644 index 37012921..00000000 --- a/lib/euc_cn.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * EUC-CN - */ - -static int -euc_cn_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - /* Code set 0 (ASCII or GB 1988-89) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (GB 2312-1980) */ - if (c >= 0xa1 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 < 0xff) { - unsigned char buf[2]; - buf[0] = c-0x80; buf[1] = c2-0x80; - return gb2312_mbtowc(conv,pwc,buf,2); - } else - return RET_ILSEQ; - } - } - return RET_ILSEQ; -} - -static int -euc_cn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[2]; - int ret; - - /* Code set 0 (ASCII or GB 1988-89) */ - ret = ascii_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - /* Code set 1 (GB 2312-1980) */ - ret = gb2312_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]+0x80; - r[1] = buf[1]+0x80; - return 2; - } - - return RET_ILUNI; -} diff --git a/lib/euc_jisx0213.h b/lib/euc_jisx0213.h deleted file mode 100644 index 9cf2ee0c..00000000 --- a/lib/euc_jisx0213.h +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * EUC-JISX0213 - */ - -/* The structure of EUC-JISX0213 is as follows: - - 0x00..0x7F: ASCII - - 0x8E{A1..FE}: JISX0201 Katakana, with prefix 0x8E, offset by +0x80. - - 0x8F{A1..FE}{A1..FE}: JISX0213 plane 2, with prefix 0x8F, offset by +0x8080. - - 0x{A1..FE}{A1..FE}: JISX0213 plane 1, offset by +0x8080. - - Note that some JISX0213 characters are not contained in Unicode 3.2 - and are therefore best represented as sequences of Unicode characters. -*/ - -#include "jisx0213.h" -#include "flushwc.h" - -static int -euc_jisx0213_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - ucs4_t last_wc = conv->istate; - if (last_wc) { - /* Output the buffered character. */ - conv->istate = 0; - *pwc = last_wc; - return 0; /* Don't advance the input pointer. */ - } else { - unsigned char c = *s; - if (c < 0x80) { - /* Plain ASCII character. */ - *pwc = (ucs4_t) c; - return 1; - } else { - if ((c >= 0xa1 && c <= 0xfe) || c == 0x8e || c == 0x8f) { - /* Two or three byte character. */ - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 <= 0xfe) { - if (c == 0x8e) { - /* Half-width katakana. */ - if (c2 <= 0xdf) { - *pwc = c2 + 0xfec0; - return 2; - } - } else { - ucs4_t wc; - if (c == 0x8f) { - /* JISX 0213 plane 2. */ - if (n >= 3) { - unsigned char c3 = s[2]; - wc = jisx0213_to_ucs4(0x200-0x80+c2,c3^0x80); - } else - return RET_TOOFEW(0); - } else { - /* JISX 0213 plane 1. */ - wc = jisx0213_to_ucs4(0x100-0x80+c,c2^0x80); - } - if (wc) { - if (wc < 0x80) { - /* It's a combining character. */ - ucs4_t wc1 = jisx0213_to_ucs_combining[wc - 1][0]; - ucs4_t wc2 = jisx0213_to_ucs_combining[wc - 1][1]; - /* We cannot output two Unicode characters at once. So, - output the first character and buffer the second one. */ - *pwc = wc1; - conv->istate = wc2; - } else - *pwc = wc; - return (c == 0x8f ? 3 : 2); - } - } - } - } else - return RET_TOOFEW(0); - } - return RET_ILSEQ; - } - } -} - -#define euc_jisx0213_flushwc normal_flushwc - -/* Composition tables for each of the relevant combining characters. */ -static const struct { unsigned short base; unsigned short composed; } euc_jisx0213_comp_table_data[] = { -#define euc_jisx0213_comp_table02e5_idx 0 -#define euc_jisx0213_comp_table02e5_len 1 - { 0xabe4, 0xabe5 }, /* 0x12B65 = 0x12B64 U+02E5 */ -#define euc_jisx0213_comp_table02e9_idx (euc_jisx0213_comp_table02e5_idx+euc_jisx0213_comp_table02e5_len) -#define euc_jisx0213_comp_table02e9_len 1 - { 0xabe0, 0xabe6 }, /* 0x12B66 = 0x12B60 U+02E9 */ -#define euc_jisx0213_comp_table0300_idx (euc_jisx0213_comp_table02e9_idx+euc_jisx0213_comp_table02e9_len) -#define euc_jisx0213_comp_table0300_len 5 - { 0xa9dc, 0xabc4 }, /* 0x12B44 = 0x1295C U+0300 */ - { 0xabb8, 0xabc8 }, /* 0x12B48 = 0x12B38 U+0300 */ - { 0xabb7, 0xabca }, /* 0x12B4A = 0x12B37 U+0300 */ - { 0xabb0, 0xabcc }, /* 0x12B4C = 0x12B30 U+0300 */ - { 0xabc3, 0xabce }, /* 0x12B4E = 0x12B43 U+0300 */ -#define euc_jisx0213_comp_table0301_idx (euc_jisx0213_comp_table0300_idx+euc_jisx0213_comp_table0300_len) -#define euc_jisx0213_comp_table0301_len 4 - { 0xabb8, 0xabc9 }, /* 0x12B49 = 0x12B38 U+0301 */ - { 0xabb7, 0xabcb }, /* 0x12B4B = 0x12B37 U+0301 */ - { 0xabb0, 0xabcd }, /* 0x12B4D = 0x12B30 U+0301 */ - { 0xabc3, 0xabcf }, /* 0x12B4F = 0x12B43 U+0301 */ -#define euc_jisx0213_comp_table309a_idx (euc_jisx0213_comp_table0301_idx+euc_jisx0213_comp_table0301_len) -#define euc_jisx0213_comp_table309a_len 14 - { 0xa4ab, 0xa4f7 }, /* 0x12477 = 0x1242B U+309A */ - { 0xa4ad, 0xa4f8 }, /* 0x12478 = 0x1242D U+309A */ - { 0xa4af, 0xa4f9 }, /* 0x12479 = 0x1242F U+309A */ - { 0xa4b1, 0xa4fa }, /* 0x1247A = 0x12431 U+309A */ - { 0xa4b3, 0xa4fb }, /* 0x1247B = 0x12433 U+309A */ - { 0xa5ab, 0xa5f7 }, /* 0x12577 = 0x1252B U+309A */ - { 0xa5ad, 0xa5f8 }, /* 0x12578 = 0x1252D U+309A */ - { 0xa5af, 0xa5f9 }, /* 0x12579 = 0x1252F U+309A */ - { 0xa5b1, 0xa5fa }, /* 0x1257A = 0x12531 U+309A */ - { 0xa5b3, 0xa5fb }, /* 0x1257B = 0x12533 U+309A */ - { 0xa5bb, 0xa5fc }, /* 0x1257C = 0x1253B U+309A */ - { 0xa5c4, 0xa5fd }, /* 0x1257D = 0x12544 U+309A */ - { 0xa5c8, 0xa5fe }, /* 0x1257E = 0x12548 U+309A */ - { 0xa6f5, 0xa6f8 }, /* 0x12678 = 0x12675 U+309A */ -}; - -static int -euc_jisx0213_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - int count = 0; - unsigned short lasttwo = conv->ostate; - - if (lasttwo) { - /* Attempt to combine the last character with this one. */ - unsigned int idx; - unsigned int len; - - if (wc == 0x02e5) - idx = euc_jisx0213_comp_table02e5_idx, - len = euc_jisx0213_comp_table02e5_len; - else if (wc == 0x02e9) - idx = euc_jisx0213_comp_table02e9_idx, - len = euc_jisx0213_comp_table02e9_len; - else if (wc == 0x0300) - idx = euc_jisx0213_comp_table0300_idx, - len = euc_jisx0213_comp_table0300_len; - else if (wc == 0x0301) - idx = euc_jisx0213_comp_table0301_idx, - len = euc_jisx0213_comp_table0301_len; - else if (wc == 0x309a) - idx = euc_jisx0213_comp_table309a_idx, - len = euc_jisx0213_comp_table309a_len; - else - goto not_combining; - - do - if (euc_jisx0213_comp_table_data[idx].base == lasttwo) - break; - while (++idx, --len > 0); - - if (len > 0) { - /* Output the combined character. */ - if (n >= 2) { - lasttwo = euc_jisx0213_comp_table_data[idx].composed; - r[0] = (lasttwo >> 8) & 0xff; - r[1] = lasttwo & 0xff; - conv->ostate = 0; - return 2; - } else - return RET_TOOSMALL; - } - - not_combining: - /* Output the buffered character. */ - if (n < 2) - return RET_TOOSMALL; - r[0] = (lasttwo >> 8) & 0xff; - r[1] = lasttwo & 0xff; - r += 2; - count = 2; - } - - if (wc < 0x80) { - /* Plain ASCII character. */ - if (n > count) { - r[0] = (unsigned char) wc; - conv->ostate = 0; - return count+1; - } else - return RET_TOOSMALL; - } else if (wc >= 0xff61 && wc <= 0xff9f) { - /* Half-width katakana. */ - if (n >= count+2) { - r[0] = 0x8e; - r[1] = wc - 0xfec0; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } else { - unsigned short jch = ucs4_to_jisx0213(wc); - if (jch != 0) { - if (jch & 0x0080) { - /* A possible match in comp_table_data. We have to buffer it. */ - /* We know it's a JISX 0213 plane 1 character. */ - if (jch & 0x8000) abort(); - conv->ostate = jch | 0x8080; - return count+0; - } - if (jch & 0x8000) { - /* JISX 0213 plane 2. */ - if (n >= count+3) { - r[0] = 0x8f; - r[1] = (jch >> 8) | 0x80; - r[2] = (jch & 0xff) | 0x80; - conv->ostate = 0; - return count+3; - } else - return RET_TOOSMALL; - } else { - /* JISX 0213 plane 1. */ - if (n >= count+2) { - r[0] = (jch >> 8) | 0x80; - r[1] = (jch & 0xff) | 0x80; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - } - return RET_ILUNI; - } -} - -static int -euc_jisx0213_reset (conv_t conv, unsigned char *r, size_t n) -{ - state_t lasttwo = conv->ostate; - - if (lasttwo) { - if (n < 2) - return RET_TOOSMALL; - r[0] = (lasttwo >> 8) & 0xff; - r[1] = lasttwo & 0xff; - /* conv->ostate = 0; will be done by the caller */ - return 2; - } else - return 0; -} diff --git a/lib/euc_jp.h b/lib/euc_jp.h deleted file mode 100644 index 828f04f4..00000000 --- a/lib/euc_jp.h +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2005, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * EUC-JP - */ - -static int -euc_jp_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - /* Code set 0 (ASCII or JIS X 0201-1976 Roman) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (JIS X 0208) */ - if (c >= 0xa1 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - if (c < 0xf5) { - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 < 0xff) { - unsigned char buf[2]; - buf[0] = c-0x80; buf[1] = c2-0x80; - return jisx0208_mbtowc(conv,pwc,buf,2); - } else - return RET_ILSEQ; - } else { - /* User-defined range. See - * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 < 0xff) { - *pwc = 0xe000 + 94*(c-0xf5) + (c2-0xa1); - return 2; - } else - return RET_ILSEQ; - } - } - /* Code set 2 (half-width katakana) */ - if (c == 0x8e) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 < 0xe0) { - int ret = jisx0201_mbtowc(conv,pwc,s+1,n-1); - if (ret == RET_ILSEQ) - return RET_ILSEQ; - if (ret != 1) abort(); - return 2; - } else - return RET_ILSEQ; - } - } - /* Code set 3 (JIS X 0212-1990) */ - if (c == 0x8f) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 < 0xff) { - if (n < 3) - return RET_TOOFEW(0); - if (c2 < 0xf5) { - unsigned char c3 = s[2]; - if (c3 >= 0xa1 && c3 < 0xff) { - unsigned char buf[2]; - int ret; - buf[0] = c2-0x80; buf[1] = c3-0x80; - ret = jisx0212_mbtowc(conv,pwc,buf,2); - if (ret == RET_ILSEQ) - return RET_ILSEQ; - if (ret != 2) abort(); - return 3; - } else - return RET_ILSEQ; - } else { - /* User-defined range. See - * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ - unsigned char c3 = s[2]; - if (c3 >= 0xa1 && c3 < 0xff) { - *pwc = 0xe3ac + 94*(c2-0xf5) + (c3-0xa1); - return 3; - } else - return RET_ILSEQ; - } - } else - return RET_ILSEQ; - } - } - return RET_ILSEQ; -} - -static int -euc_jp_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[2]; - int ret; - - /* Code set 0 (ASCII or JIS X 0201-1976 Roman) */ - ret = ascii_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - /* Code set 1 (JIS X 0208) */ - ret = jisx0208_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]+0x80; - r[1] = buf[1]+0x80; - return 2; - } - - /* Code set 2 (half-width katakana) */ - ret = jisx0201_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI && buf[0] >= 0x80) { - if (ret != 1) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = 0x8e; - r[1] = buf[0]; - return 2; - } - - /* Code set 3 (JIS X 0212-1990) */ - ret = jisx0212_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 3) - return RET_TOOSMALL; - r[0] = 0x8f; - r[1] = buf[0]+0x80; - r[2] = buf[1]+0x80; - return 3; - } - - /* Extra compatibility with Shift_JIS. */ - if (wc == 0x00a5) { - r[0] = 0x5c; - return 1; - } - if (wc == 0x203e) { - r[0] = 0x7e; - return 1; - } - - /* User-defined range. See - * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ - if (wc >= 0xe000 && wc < 0xe758) { - if (wc < 0xe3ac) { - unsigned char c1, c2; - if (n < 2) - return RET_TOOSMALL; - c1 = (unsigned int) (wc - 0xe000) / 94; - c2 = (unsigned int) (wc - 0xe000) % 94; - r[0] = c1+0xf5; - r[1] = c2+0xa1; - return 2; - } else { - unsigned char c1, c2; - if (n < 3) - return RET_TOOSMALL; - c1 = (unsigned int) (wc - 0xe3ac) / 94; - c2 = (unsigned int) (wc - 0xe3ac) % 94; - r[0] = 0x8f; - r[1] = c1+0xf5; - r[2] = c2+0xa1; - return 3; - } - } - - return RET_ILUNI; -} diff --git a/lib/euc_kr.h b/lib/euc_kr.h deleted file mode 100644 index e1fb10a3..00000000 --- a/lib/euc_kr.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2007, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * EUC-KR - */ - -/* Specification: RFC 1557 */ - -static int -euc_kr_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - /* Code set 0 (ASCII or KS C 5636-1993) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (KS C 5601-1992, now KS X 1001:2002) */ - if (c >= 0xa1 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 < 0xff) { - unsigned char buf[2]; - buf[0] = c-0x80; buf[1] = c2-0x80; - return ksc5601_mbtowc(conv,pwc,buf,2); - } else - return RET_ILSEQ; - } - } - return RET_ILSEQ; -} - -static int -euc_kr_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[2]; - int ret; - - /* Code set 0 (ASCII or KS C 5636-1993) */ - ret = ascii_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - /* Code set 1 (KS C 5601-1992, now KS X 1001:2002) */ - ret = ksc5601_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]+0x80; - r[1] = buf[1]+0x80; - return 2; - } - - return RET_ILUNI; -} diff --git a/lib/euc_tw.h b/lib/euc_tw.h deleted file mode 100644 index 97fd3a05..00000000 --- a/lib/euc_tw.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * EUC-TW - */ - -static int -euc_tw_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - /* Code set 0 (ASCII) */ - if (c < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - /* Code set 1 (CNS 11643-1992 Plane 1) */ - if (c >= 0xa1 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 < 0xff) { - unsigned char buf[2]; - buf[0] = c-0x80; buf[1] = c2-0x80; - return cns11643_1_mbtowc(conv,pwc,buf,2); - } else - return RET_ILSEQ; - } - } - /* Code set 2 (CNS 11643-1992 Planes 1-16) */ - if (c == 0x8e) { - if (n < 4) - return RET_TOOFEW(0); - { - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 <= 0xb0) { - unsigned char c3 = s[2]; - unsigned char c4 = s[3]; - if (c3 >= 0xa1 && c3 < 0xff && c4 >= 0xa1 && c4 < 0xff) { - unsigned char buf[2]; - int ret; - buf[0] = c3-0x80; buf[1] = c4-0x80; - switch (c2-0xa0) { - case 1: ret = cns11643_1_mbtowc(conv,pwc,buf,2); break; - case 2: ret = cns11643_2_mbtowc(conv,pwc,buf,2); break; - case 3: ret = cns11643_3_mbtowc(conv,pwc,buf,2); break; - case 4: ret = cns11643_4_mbtowc(conv,pwc,buf,2); break; - case 5: ret = cns11643_5_mbtowc(conv,pwc,buf,2); break; - case 6: ret = cns11643_6_mbtowc(conv,pwc,buf,2); break; - case 7: ret = cns11643_7_mbtowc(conv,pwc,buf,2); break; - case 15: ret = cns11643_15_mbtowc(conv,pwc,buf,2); break; - default: return RET_ILSEQ; - } - if (ret == RET_ILSEQ) - return RET_ILSEQ; - if (ret != 2) abort(); - return 4; - } - } - } - } - return RET_ILSEQ; -} - -static int -euc_tw_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[3]; - int ret; - - /* Code set 0 (ASCII) */ - ret = ascii_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - ret = cns11643_wctomb(conv,buf,wc,3); - if (ret != RET_ILUNI) { - if (ret != 3) abort(); - - /* Code set 1 (CNS 11643-1992 Plane 1) */ - if (buf[0] == 1) { - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[1]+0x80; - r[1] = buf[2]+0x80; - return 2; - } - - /* Code set 2 (CNS 11643-1992 Planes 1-16) */ - if (n < 4) - return RET_TOOSMALL; - r[0] = 0x8e; - r[1] = buf[0]+0xa0; - r[2] = buf[1]+0x80; - r[3] = buf[2]+0x80; - return 4; - } - - return RET_ILUNI; -} diff --git a/lib/gb12345.h b/lib/gb12345.h deleted file mode 100644 index b95dec4f..00000000 --- a/lib/gb12345.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * GB/T 12345-1990 - */ - -/* - * GB/T 12345-1990 is a traditional chinese counterpart of GB 2312-1986. - * According to the unicode.org tables: - * 2146 characters have been changed to their traditional counterpart, - * 103 characters have been added, no characters have been removed. - * Therefore we use an auxiliary table, which contains only the changes. - */ - -#include "gb12345ext.h" - -static int -gb12345_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - int ret; - - /* The gb12345ext table overrides some entries in the gb2312 table. */ - /* Try the GB12345 extensions -> Unicode table. */ - ret = gb12345ext_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - /* Try the GB2312 -> Unicode table. */ - ret = gb2312_mbtowc(conv,pwc,s,n); - return ret; -} - -static int -gb12345_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - int ret; - - /* The gb12345ext table overrides some entries in the gb2312 table. */ - /* Try the Unicode -> GB12345 extensions table. */ - ret = gb12345ext_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - /* Try the Unicode -> GB2312 table, and check that the resulting GB2312 - byte sequence is not overridden by the GB12345 extensions table. */ - ret = gb2312_wctomb(conv,r,wc,n); - if (ret == 2 && gb12345ext_mbtowc(conv,&wc,r,2) == 2) - return RET_ILUNI; - else - return ret; -} diff --git a/lib/gb18030_2022.h b/lib/gb18030_2022.h deleted file mode 100644 index 0977a7c3..00000000 --- a/lib/gb18030_2022.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2005, 2012, 2016, 2023 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * GB18030:2022 - */ - -/* - * GB18030, in the version from 2022, is like the version from 2005, - * except that a few mappings to the Unicode PUA have been replaced with - * mappings to assigned Unicode characters. - */ - -static int -gb18030_2022_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - int ret; - - /* Code set 0 (ASCII) */ - if (*s < 0x80) - return ascii_mbtowc(conv,pwc,s,n); - - /* Code set 1 (GBK extended) */ - ret = gbk_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - - ret = gb18030_2022_ext_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - - /* Code set 2 (remainder of Unicode U+0000..U+FFFF), including - User-defined characters, two-byte part of range U+E766..U+E864 */ - ret = gb18030_2022_uni_mbtowc(conv,pwc,s,n); - if (ret != RET_ILSEQ) - return ret; - /* User-defined characters range U+E000..U+E765 */ - { - unsigned char c1 = s[0]; - if ((c1 >= 0xaa && c1 <= 0xaf) || (c1 >= 0xf8 && c1 <= 0xfe)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 <= 0xfe) { - *pwc = 0xe000 + 94 * (c1 >= 0xf8 ? c1 - 0xf2 : c1 - 0xaa) + (c2 - 0xa1); - return 2; - } - } else - return RET_TOOFEW(0); - } else if (c1 >= 0xa1 && c1 <= 0xa7) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x40 && c2 <= 0xa1 && c2 != 0x7f) { - *pwc = 0xe4c6 + 96 * (c1 - 0xa1) + c2 - (c2 >= 0x80 ? 0x41 : 0x40); - return 2; - } - } else - return RET_TOOFEW(0); - } - } - - /* Code set 3 (Unicode U+10000..U+10FFFF) */ - { - unsigned char c1 = s[0]; - if (c1 >= 0x90 && c1 <= 0xe3) { - if (n >= 2) { - unsigned char c2 = s[1]; - if (c2 >= 0x30 && c2 <= 0x39) { - if (n >= 3) { - unsigned char c3 = s[2]; - if (c3 >= 0x81 && c3 <= 0xfe) { - if (n >= 4) { - unsigned char c4 = s[3]; - if (c4 >= 0x30 && c4 <= 0x39) { - unsigned int i = (((c1 - 0x90) * 10 + (c2 - 0x30)) * 126 + (c3 - 0x81)) * 10 + (c4 - 0x30); - if (i >= 0 && i < 0x100000) { - *pwc = (ucs4_t) (0x10000 + i); - return 4; - } - } - return RET_ILSEQ; - } - return RET_TOOFEW(0); - } - return RET_ILSEQ; - } - return RET_TOOFEW(0); - } - return RET_ILSEQ; - } - return RET_TOOFEW(0); - } - return RET_ILSEQ; - } -} - -static const unsigned short gb18030_2022_pua2charset[23*3] = { -/* Unicode range GB18030 range */ - 0xe766, 0xe76b, 0xa2ab, /*.. 0xa2b0, */ - 0xe76d, 0xe76d, 0xa2e4, - 0xe76e, 0xe76f, 0xa2ef, /*.. 0xa2f0, */ - 0xe770, 0xe771, 0xa2fd, /*.. 0xa2fe, */ - 0xe772, 0xe77c, 0xa4f4, /*.. 0xa4fe, */ - 0xe77d, 0xe784, 0xa5f7, /*.. 0xa5fe, */ - 0xe785, 0xe78c, 0xa6b9, /*.. 0xa6c0, */ - 0xe797, 0xe79f, 0xa6f6, /*.. 0xa6fe, */ - 0xe7a0, 0xe7ae, 0xa7c2, /*.. 0xa7d0, */ - 0xe7af, 0xe7bb, 0xa7f2, /*.. 0xa7fe, */ - 0xe7bc, 0xe7c6, 0xa896, /*.. 0xa8a0, */ - 0xe7c9, 0xe7cc, 0xa8c1, /*.. 0xa8c4, */ - 0xe7cd, 0xe7e1, 0xa8ea, /*.. 0xa8fe, */ - 0xe7e2, 0xe7e2, 0xa958, - 0xe7e3, 0xe7e3, 0xa95b, - 0xe7e4, 0xe7e6, 0xa95d, /*.. 0xa95f, */ - 0xe7f4, 0xe800, 0xa997, /*.. 0xa9a3, */ - 0xe801, 0xe80f, 0xa9f0, /*.. 0xa9fe, */ - 0xe810, 0xe814, 0xd7fa, /*.. 0xd7fe, */ - 0xe816, 0xe818, 0xfe51, /*.. 0xfe53, */ - 0xe831, 0xe831, 0xfe6c, - 0xe83b, 0xe83b, 0xfe76, - 0xe855, 0xe855, 0xfe91, -}; - -static int -gb18030_2022_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - int ret; - - /* Code set 0 (ASCII) */ - ret = ascii_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - /* Code set 1 (GBK extended) */ - ret = gbk_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - ret = gb18030ext_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - /* Code set 2 (remainder of Unicode U+0000..U+FFFF) */ - if (wc >= 0xe000 && wc <= 0xe864) { - if (n >= 2) { - if (wc < 0xe766) { - /* User-defined characters range U+E000..U+E765 */ - if (wc < 0xe4c6) { - unsigned int i = wc - 0xe000; - r[1] = (i % 94) + 0xa1; i = i / 94; - r[0] = (i < 6 ? i + 0xaa : i + 0xf2); - return 2; - } else { - unsigned int i = wc - 0xe4c6; - r[0] = (i / 96) + 0xa1; i = i % 96; - r[1] = i + (i >= 0x3f ? 0x41 : 0x40); - return 2; - } - } else { - /* User-defined characters, two-byte part of range U+E766..U+E864 */ - unsigned int k1 = 0; - unsigned int k2 = 23; - /* Invariant: We know that if wc occurs in Unicode interval in - gb18030_2022_pua2charset, it does so at a k with k1 <= k < k2. */ - while (k1 < k2) { - unsigned int k = (k1 + k2) / 2; - if (wc < gb18030_2022_pua2charset[k*3+0]) - k2 = k; - else if (wc > gb18030_2022_pua2charset[k*3+1]) - k1 = k + 1; - else { - unsigned short c = - gb18030_2022_pua2charset[k*3+2] + (wc - gb18030_2022_pua2charset[k*3+0]); - r[0] = (c >> 8); - r[1] = (c & 0xff); - return 2; - } - } - } - } else - return RET_TOOSMALL; - } - ret = gb18030_2022_uni_wctomb(conv,r,wc,n); - if (ret != RET_ILUNI) - return ret; - - /* Code set 3 (Unicode U+10000..U+10FFFF) */ - if (n >= 4) { - if (wc >= 0x10000 && wc < 0x110000) { - unsigned int i = wc - 0x10000; - r[3] = (i % 10) + 0x30; i = i / 10; - r[2] = (i % 126) + 0x81; i = i / 126; - r[1] = (i % 10) + 0x30; i = i / 10; - r[0] = i + 0x90; - return 4; - } - return RET_ILUNI; - } - return RET_TOOSMALL; -} diff --git a/lib/gb18030ext.h b/lib/gb18030ext.h deleted file mode 100644 index 64bce198..00000000 --- a/lib/gb18030ext.h +++ /dev/null @@ -1,431 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2005, 2011, 2016, 2023 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * GB18030 two-byte extension - */ - -static const unsigned short gb18030ext_2uni_pagea9[13] = { - /* 0xa9 */ - 0x303e, 0x2ff0, 0x2ff1, 0x2ff2, 0x2ff3, 0x2ff4, 0x2ff5, 0x2ff6, - 0x2ff7, 0x2ff8, 0x2ff9, 0x2ffa, 0x2ffb, -}; -static const unsigned int gb18030_2005_ext_2uni_pagefe[96] = { - /* 0xfe */ - 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, - 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, - 0x2e81, 0x20087, 0x20089, 0x200cc, 0x2e84, 0x3473, 0x3447, 0x2e88, - 0x2e8b, 0x9fb4, 0x359e, 0x361a, 0x360e, 0x2e8c, 0x2e97, 0x396e, - 0x3918, 0x9fb5, 0x39cf, 0x39df, 0x3a73, 0x39d0, 0x9fb6, 0x9fb7, - 0x3b4e, 0x3c6e, 0x3ce0, 0x2ea7, 0x215d7, 0x9fb8, 0x2eaa, 0x4056, - 0x415f, 0x2eae, 0x4337, 0x2eb3, 0x2eb6, 0x2eb7, 0x2298f, 0x43b1, - 0x43ac, 0x2ebb, 0x43dd, 0x44d6, 0x4661, 0x464c, 0x9fb9, 0x4723, - 0x4729, 0x477c, 0x478d, 0x2eca, 0x4947, 0x497a, 0x497d, 0x4982, - 0x4983, 0x4985, 0x4986, 0x499f, 0x499b, 0x49b7, 0x49b6, 0x9fba, - 0x241fe, 0x4ca3, 0x4c9f, 0x4ca0, 0x4ca1, 0x4c77, 0x4ca2, 0x4d13, - 0x4d14, 0x4d15, 0x4d16, 0x4d17, 0x4d18, 0x4d19, 0x4dae, 0x9fbb, -}; - -static const unsigned short gb18030_2022_ext_2uni_pagefe[96] = { - /* 0xfe */ - 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, - 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, - 0x2e81, 0xe816, 0xe817, 0xe818, 0x2e84, 0x3473, 0x3447, 0x2e88, - 0x2e8b, 0x9fb4, 0x359e, 0x361a, 0x360e, 0x2e8c, 0x2e97, 0x396e, - 0x3918, 0x9fb5, 0x39cf, 0x39df, 0x3a73, 0x39d0, 0x9fb6, 0x9fb7, - 0x3b4e, 0x3c6e, 0x3ce0, 0x2ea7, 0xe831, 0x9fb8, 0x2eaa, 0x4056, - 0x415f, 0x2eae, 0x4337, 0x2eb3, 0x2eb6, 0x2eb7, 0xe83b, 0x43b1, - 0x43ac, 0x2ebb, 0x43dd, 0x44d6, 0x4661, 0x464c, 0x9fb9, 0x4723, - 0x4729, 0x477c, 0x478d, 0x2eca, 0x4947, 0x497a, 0x497d, 0x4982, - 0x4983, 0x4985, 0x4986, 0x499f, 0x499b, 0x49b7, 0x49b6, 0x9fba, - 0xe855, 0x4ca3, 0x4c9f, 0x4ca0, 0x4ca1, 0x4c77, 0x4ca2, 0x4d13, - 0x4d14, 0x4d15, 0x4d16, 0x4d17, 0x4d18, 0x4d19, 0x4dae, 0x9fbb, -}; - -static int -gb18030_2005_ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c1 = s[0]; - if ((c1 == 0xa2) || (c1 >= 0xa4 && c1 <= 0xa9) || (c1 == 0xd7) || (c1 == 0xfe)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xff)) { - unsigned int i = 190 * (c1 - 0x81) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); - unsigned int wc = 0xfffd; - switch (c1) { - case 0xa2: - if (i >= 6376 && i <= 6381) /* 0xA2AB..0xA2B0 */ - wc = 0xe766 + (i - 6376); - else if (i == 6432) /* 0xA2E3 */ - wc = 0x20ac; - else if (i == 6433) /* 0xA2E4 */ - wc = 0xe76d; - else if (i >= 6444 && i <= 6445) /* 0xA2EF..0xA2F0 */ - wc = 0xe76e + (i - 6444); - else if (i >= 6458 && i <= 6459) /* 0xA2FD..0xA2FE */ - wc = 0xe770 + (i - 6458); - break; - case 0xa4: - if (i >= 6829 && i <= 6839) /* 0xA4F4..0xA4FE */ - wc = 0xe772 + (i - 6829); - break; - case 0xa5: - if (i >= 7022 && i <= 7029) /* 0xA5F7..0xA5FE */ - wc = 0xe77d + (i - 7022); - break; - case 0xa6: - if (i >= 7150 && i <= 7157) /* 0xA6B9..0xA6C0 */ - wc = 0xe785 + (i - 7150); - else if (i >= 7183 && i <= 7184) /* 0xA6DA..0xA6DB */ - wc = 0xfe12 - (i - 7183); - else if (i >= 7182 && i <= 7190) /* 0xA6D9..0xA6DF */ - wc = 0xfe10 + (i - 7182); - else if (i >= 7201 && i <= 7202) /* 0xA6EC..0xA6ED */ - wc = 0xfe17 + (i - 7201); - else if (i == 7208) /* 0xA6F3 */ - wc = 0xfe19; - else if (i >= 7211 && i <= 7219) /* 0xA6F6..0xA6FE */ - wc = 0xe797 + (i - 7211); - break; - case 0xa7: - if (i >= 7349 && i <= 7363) /* 0xA7C2..0xA7D0 */ - wc = 0xe7a0 + (i - 7349); - else if (i >= 7397 && i <= 7409) /* 0xA7F2..0xA7FE */ - wc = 0xe7af + (i - 7397); - break; - case 0xa8: - if (i >= 7495 && i <= 7505) /* 0xA896..0xA8A0 */ - wc = 0xe7bc + (i - 7495); - else if (i == 7533) /* 0xA8BC */ - wc = 0x1e3f; - else if (i == 7536) /* 0xA8BF */ - wc = 0x01f9; - else if (i >= 7538 && i <= 7541) /* 0xA8C1..0xA8C4 */ - wc = 0xe7c9 + (i - 7538); - else if (i >= 7579 && i <= 7599) /* 0xA8EA..0xA8FE */ - wc = 0xe7cd + (i - 7579); - break; - case 0xa9: - if (i == 7624) /* 0xA958 */ - wc = 0xe7e2; - else if (i == 7627) /* 0xA95B */ - wc = 0xe7e3; - else if (i >= 7629 && i <= 7631) /* 0xA95D..0xA95F */ - wc = 0xe7e4 + (i - 7629); - else if (i >= 7672 && i < 7685) /* 0xA989..0xA995 */ - wc = gb18030ext_2uni_pagea9[i-7672]; - else if (i >= 7686 && i <= 7698) /* 0xA997..0xA9A3 */ - wc = 0xe7f4 + (i - 7686); - else if (i >= 7775 && i <= 7789) /* 0xA9F0..0xA9FE */ - wc = 0xe801 + (i - 7775); - break; - case 0xd7: - if (i >= 16525 && i <= 16529) /* 0xD7FA..0xD7FE */ - wc = 0xe810 + (i - 16525); - break; - case 0xfe: - if (i < 23846) - wc = gb18030_2005_ext_2uni_pagefe[i-23750]; - break; - default: - break; - } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; - } - } - return RET_ILSEQ; - } - return RET_TOOFEW(0); - } - return RET_ILSEQ; -} - -static int -gb18030_2022_ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c1 = s[0]; - if ((c1 == 0xa2) || (c1 >= 0xa4 && c1 <= 0xa9) || (c1 == 0xd7) || (c1 == 0xfe)) { - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xff)) { - unsigned int i = 190 * (c1 - 0x81) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40)); - unsigned int wc = 0xfffd; - switch (c1) { - case 0xa2: - if (i >= 6376 && i <= 6381) /* 0xA2AB..0xA2B0 */ - wc = 0xe766 + (i - 6376); - else if (i == 6432) /* 0xA2E3 */ - wc = 0x20ac; - else if (i == 6433) /* 0xA2E4 */ - wc = 0xe76d; - else if (i >= 6444 && i <= 6445) /* 0xA2EF..0xA2F0 */ - wc = 0xe76e + (i - 6444); - else if (i >= 6458 && i <= 6459) /* 0xA2FD..0xA2FE */ - wc = 0xe770 + (i - 6458); - break; - case 0xa4: - if (i >= 6829 && i <= 6839) /* 0xA4F4..0xA4FE */ - wc = 0xe772 + (i - 6829); - break; - case 0xa5: - if (i >= 7022 && i <= 7029) /* 0xA5F7..0xA5FE */ - wc = 0xe77d + (i - 7022); - break; - case 0xa6: - if (i >= 7150 && i <= 7157) /* 0xA6B9..0xA6C0 */ - wc = 0xe785 + (i - 7150); - else if (i >= 7183 && i <= 7184) /* 0xA6DA..0xA6DB */ - wc = 0xfe12 - (i - 7183); - else if (i >= 7182 && i <= 7190) /* 0xA6D9..0xA6DF */ - wc = 0xfe10 + (i - 7182); - else if (i >= 7201 && i <= 7202) /* 0xA6EC..0xA6ED */ - wc = 0xfe17 + (i - 7201); - else if (i == 7208) /* 0xA6F3 */ - wc = 0xfe19; - else if (i >= 7211 && i <= 7219) /* 0xA6F6..0xA6FE */ - wc = 0xe797 + (i - 7211); - break; - case 0xa7: - if (i >= 7349 && i <= 7363) /* 0xA7C2..0xA7D0 */ - wc = 0xe7a0 + (i - 7349); - else if (i >= 7397 && i <= 7409) /* 0xA7F2..0xA7FE */ - wc = 0xe7af + (i - 7397); - break; - case 0xa8: - if (i >= 7495 && i <= 7505) /* 0xA896..0xA8A0 */ - wc = 0xe7bc + (i - 7495); - else if (i == 7533) /* 0xA8BC */ - wc = 0x1e3f; - else if (i == 7536) /* 0xA8BF */ - wc = 0x01f9; - else if (i >= 7538 && i <= 7541) /* 0xA8C1..0xA8C4 */ - wc = 0xe7c9 + (i - 7538); - else if (i >= 7579 && i <= 7599) /* 0xA8EA..0xA8FE */ - wc = 0xe7cd + (i - 7579); - break; - case 0xa9: - if (i == 7624) /* 0xA958 */ - wc = 0xe7e2; - else if (i == 7627) /* 0xA95B */ - wc = 0xe7e3; - else if (i >= 7629 && i <= 7631) /* 0xA95D..0xA95F */ - wc = 0xe7e4 + (i - 7629); - else if (i >= 7672 && i < 7685) /* 0xA989..0xA995 */ - wc = gb18030ext_2uni_pagea9[i-7672]; - else if (i >= 7686 && i <= 7698) /* 0xA997..0xA9A3 */ - wc = 0xe7f4 + (i - 7686); - else if (i >= 7775 && i <= 7789) /* 0xA9F0..0xA9FE */ - wc = 0xe801 + (i - 7775); - break; - case 0xd7: - if (i >= 16525 && i <= 16529) /* 0xD7FA..0xD7FE */ - wc = 0xe810 + (i - 16525); - break; - case 0xfe: - if (i < 23846) - wc = gb18030_2022_ext_2uni_pagefe[i-23750]; - break; - default: - break; - } - if (wc != 0xfffd) { - *pwc = (ucs4_t) wc; - return 2; - } - } - return RET_ILSEQ; - } - return RET_TOOFEW(0); - } - return RET_ILSEQ; -} - -static const unsigned short gb18030ext_page2e[80] = { - 0x0000, 0xfe50, 0x0000, 0x0000, 0xfe54, 0x0000, 0x0000, 0x0000, /*0x80-0x87*/ - 0xfe57, 0x0000, 0x0000, 0xfe58, 0xfe5d, 0x0000, 0x0000, 0x0000, /*0x88-0x8f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe5e, /*0x90-0x97*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x98-0x9f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe6b, /*0xa0-0xa7*/ - 0x0000, 0x0000, 0xfe6e, 0x0000, 0x0000, 0x0000, 0xfe71, 0x0000, /*0xa8-0xaf*/ - 0x0000, 0x0000, 0x0000, 0xfe73, 0x0000, 0x0000, 0xfe74, 0xfe75, /*0xb0-0xb7*/ - 0x0000, 0x0000, 0x0000, 0xfe79, 0x0000, 0x0000, 0x0000, 0x0000, /*0xb8-0xbf*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xc0-0xc7*/ - 0x0000, 0x0000, 0xfe84, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xc8-0xcf*/ -}; -static const unsigned short gb18030ext_page2f[16] = { - 0xa98a, 0xa98b, 0xa98c, 0xa98d, 0xa98e, 0xa98f, 0xa990, 0xa991, /*0xf0-0xf7*/ - 0xa992, 0xa993, 0xa994, 0xa995, 0x0000, 0x0000, 0x0000, 0x0000, /*0xf8-0xff*/ -}; -static const unsigned short gb18030ext_page34[56] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe56, /*0x40-0x47*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x48-0x4f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x50-0x57*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x58-0x5f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x60-0x67*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x68-0x6f*/ - 0x0000, 0x0000, 0x0000, 0xfe55, 0x0000, 0x0000, 0x0000, 0x0000, /*0x70-0x77*/ -}; -static const unsigned short gb18030ext_page36[24] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe5c, 0x0000, /*0x08-0x0f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x10-0x17*/ - 0x0000, 0x0000, 0xfe5b, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x18-0x1f*/ -}; -static const unsigned short gb18030ext_page39[24] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe62, /*0xc8-0xcf*/ - 0xfe65, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xd0-0xd7*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe63, /*0xd8-0xdf*/ -}; -static const unsigned short gb18030ext_page43[56] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0xfe78, 0x0000, 0x0000, 0x0000, /*0xa8-0xaf*/ - 0x0000, 0xfe77, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xb0-0xb7*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xb8-0xbf*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xc0-0xc7*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xc8-0xcf*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xd0-0xd7*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe7a, 0x0000, 0x0000, /*0xd8-0xdf*/ -}; -static const unsigned short gb18030ext_page46[32] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0xfe7d, 0x0000, 0x0000, 0x0000, /*0x48-0x4f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x50-0x57*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x58-0x5f*/ - 0x0000, 0xfe7c, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x60-0x67*/ -}; -static const unsigned short gb18030ext_page47_1[16] = { - 0x0000, 0x0000, 0x0000, 0xfe80, 0x0000, 0x0000, 0x0000, 0x0000, /*0x20-0x27*/ - 0x0000, 0xfe81, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x28-0x2f*/ -}; -static const unsigned short gb18030ext_page47_2[24] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0xfe82, 0x0000, 0x0000, 0x0000, /*0x78-0x7f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x80-0x87*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe83, 0x0000, 0x0000, /*0x88-0x8f*/ -}; -static const unsigned short gb18030ext_page49[120] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe85, /*0x40-0x47*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x48-0x4f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x50-0x57*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x58-0x5f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x60-0x67*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x68-0x6f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x70-0x77*/ - 0x0000, 0x0000, 0xfe86, 0x0000, 0x0000, 0xfe87, 0x0000, 0x0000, /*0x78-0x7f*/ - 0x0000, 0x0000, 0xfe88, 0xfe89, 0x0000, 0xfe8a, 0xfe8b, 0x0000, /*0x80-0x87*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x88-0x8f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x90-0x97*/ - 0x0000, 0x0000, 0x0000, 0xfe8d, 0x0000, 0x0000, 0x0000, 0xfe8c, /*0x98-0x9f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xa0-0xa7*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0xa8-0xaf*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe8f, 0xfe8e, /*0xb0-0xb7*/ -}; -static const unsigned short gb18030ext_page4c[56] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe96, /*0x70-0x77*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x78-0x7f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x80-0x87*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x88-0x8f*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x90-0x97*/ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfe93, /*0x98-0x9f*/ - 0xfe94, 0xfe95, 0xfe97, 0xfe92, 0x0000, 0x0000, 0x0000, 0x0000, /*0xa0-0xa7*/ -}; -static const unsigned short gb18030ext_page4d[16] = { - 0x0000, 0x0000, 0x0000, 0xfe98, 0xfe99, 0xfe9a, 0xfe9b, 0xfe9c, /*0x10-0x17*/ - 0xfe9d, 0xfe9e, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x18-0x1f*/ -}; -static const unsigned short gb18030ext_page9f[16] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0xfe59, 0xfe61, 0xfe66, 0xfe67, /*0xb0-0xb7*/ - 0xfe6d, 0xfe7e, 0xfe90, 0xfea0, 0x0000, 0x0000, 0x0000, 0x0000, /*0xb8-0xbf*/ -}; -static const unsigned short gb18030ext_pagefe[16] = { - 0xa6d9, 0xa6db, 0xa6da, 0xa6dc, 0xa6dd, 0xa6de, 0xa6df, 0xa6ec, /*0x10-0x17*/ - 0xa6ed, 0xa6f3, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x18-0x1f*/ -}; - -static int -gb18030ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (n >= 2) { - unsigned short c = 0; - if (wc == 0x01f9) - c = 0xa8bf; - else if (wc == 0x1e3f) - c = 0xa8bc; - else if (wc == 0x20ac) - c = 0xa2e3; - else if (wc >= 0x2e80 && wc < 0x2ed0) - c = gb18030ext_page2e[wc-0x2e80]; - else if (wc >= 0x2ff0 && wc < 0x3000) - c = gb18030ext_page2f[wc-0x2ff0]; - else if (wc == 0x303e) - c = 0xa989; - else if (wc >= 0x3440 && wc < 0x3478) - c = gb18030ext_page34[wc-0x3440]; - else if (wc == 0x359e) - c = 0xfe5a; - else if (wc >= 0x3608 && wc < 0x3620) - c = gb18030ext_page36[wc-0x3608]; - else if (wc == 0x3918) - c = 0xfe60; - else if (wc == 0x396e) - c = 0xfe5f; - else if (wc >= 0x39c8 && wc < 0x39e0) - c = gb18030ext_page39[wc-0x39c8]; - else if (wc == 0x3a73) - c = 0xfe64; - else if (wc == 0x3b4e) - c = 0xfe68; - else if (wc == 0x3c6e) - c = 0xfe69; - else if (wc == 0x3ce0) - c = 0xfe6a; - else if (wc == 0x4056) - c = 0xfe6f; - else if (wc == 0x415f) - c = 0xfe70; - else if (wc == 0x4337) - c = 0xfe72; - else if (wc >= 0x43a8 && wc < 0x43e0) - c = gb18030ext_page43[wc-0x43a8]; - else if (wc == 0x44d6) - c = 0xfe7b; - else if (wc >= 0x4648 && wc < 0x4668) - c = gb18030ext_page46[wc-0x4648]; - else if (wc >= 0x4720 && wc < 0x4730) - c = gb18030ext_page47_1[wc-0x4720]; - else if (wc >= 0x4778 && wc < 0x4790) - c = gb18030ext_page47_2[wc-0x4778]; - else if (wc >= 0x4940 && wc < 0x49b8) - c = gb18030ext_page49[wc-0x4940]; - else if (wc >= 0x4c70 && wc < 0x4ca8) - c = gb18030ext_page4c[wc-0x4c70]; - else if (wc >= 0x4d10 && wc < 0x4d20) - c = gb18030ext_page4d[wc-0x4d10]; - else if (wc == 0x4dae) - c = 0xfe9f; - else if (wc >= 0x9fb4 && wc < 0x9fbc) - c = gb18030ext_page9f[wc-0x9fb0]; - else if (wc >= 0xfe10 && wc < 0xfe1a) - c = gb18030ext_pagefe[wc-0xfe10]; - if (c != 0) { - r[0] = (c >> 8); r[1] = (c & 0xff); - return 2; - } - return RET_ILUNI; - } - return RET_TOOSMALL; -} diff --git a/lib/gbk.h b/lib/gbk.h deleted file mode 100644 index 00d16002..00000000 --- a/lib/gbk.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2005, 2008, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * GBK - */ - -/* - * GBK, as described in Ken Lunde's book, is an extension of GB 2312-1980 - * (shifted by adding 0x8080 to the range 0xA1A1..0xFEFE, as used in EUC-CN). - * It adds the following ranges: - * - * (part of GBK/1) 0xA2A1-0xA2AA Small Roman numerals - * GBK/3 0x{81-A0}{40-7E,80-FE} 6080 new characters, all in Unicode - * GBK/4 0x{AA-FE}{40-7E,80-A0} 8160 new characters, 8080 in Unicode - * GBK/5 0x{A8-A9}{40-7E,80-A0} 166 new characters, 153 in Unicode - * - * Furthermore, all four tables I have looked at - * - the CP936 table by Microsoft, found on ftp.unicode.org in 1999, - * - the GBK table by Sun, investigated on a Solaris 2.7 machine, - * - the GBK tables by CWEX, found in the Big5+ package, - * - the GB18030 standard (second printing), - * agree in the following extensions. (Ken Lunde must have overlooked these - * differences between GB2312 and GBK. Also, the CWEX tables have additional - * differences.) - * - * 1. Some characters in the GB2312 range are defined differently: - * - * code GB2312 GBK - * 0xA1A4 0x30FB # KATAKANA MIDDLE DOT 0x00B7 # MIDDLE DOT - * 0xA1AA 0x2015 # HORIZONTAL BAR 0x2014 # EM DASH - * - * 2. 19 characters added in the range 0xA6E0-0xA6F5. - * - * 3. 4 characters added in the range 0xA8BB-0xA8C0. - * - * CP936 as of 1999 was identical to GBK. However, since 1999, Microsoft has - * added new mappings to CP936... - */ - -#include "gbkext1.h" -#include "gbkext2.h" -#include "gbkext_inv.h" -#include "cp936ext.h" - -static int -gbk_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - - if (c >= 0x81 && c < 0xff) { - if (n < 2) - return RET_TOOFEW(0); - if (c >= 0xa1 && c <= 0xf7) { - unsigned char c2 = s[1]; - if (c == 0xa1) { - if (c2 == 0xa4) { - *pwc = 0x00b7; - return 2; - } - if (c2 == 0xaa) { - *pwc = 0x2014; - return 2; - } - } - if (c2 >= 0xa1 && c2 < 0xff) { - unsigned char buf[2]; - int ret; - buf[0] = c-0x80; buf[1] = c2-0x80; - ret = gb2312_mbtowc(conv,pwc,buf,2); - if (ret != RET_ILSEQ) - return ret; - buf[0] = c; buf[1] = c2; - ret = cp936ext_mbtowc(conv,pwc,buf,2); - if (ret != RET_ILSEQ) - return ret; - } - } - if (c >= 0x81 && c <= 0xa0) - return gbkext1_mbtowc(conv,pwc,s,2); - if (c >= 0xa8 && c <= 0xfe) - return gbkext2_mbtowc(conv,pwc,s,2); - if (c == 0xa2) { - unsigned char c2 = s[1]; - if (c2 >= 0xa1 && c2 <= 0xaa) { - *pwc = 0x2170+(c2-0xa1); - return 2; - } - } - } - return RET_ILSEQ; -} - -static int -gbk_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[2]; - int ret; - - if (wc != 0x30fb && wc != 0x2015) { - ret = gb2312_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]+0x80; - r[1] = buf[1]+0x80; - return 2; - } - } - ret = gbkext_inv_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]; - r[1] = buf[1]; - return 2; - } - if (wc >= 0x2170 && wc <= 0x2179) { - if (n < 2) - return RET_TOOSMALL; - r[0] = 0xa2; - r[1] = 0xa1 + (wc-0x2170); - return 2; - } - ret = cp936ext_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]; - r[1] = buf[1]; - return 2; - } - if (wc == 0x00b7) { - if (n < 2) - return RET_TOOSMALL; - r[0] = 0xa1; - r[1] = 0xa4; - return 2; - } - if (wc == 0x2014) { - if (n < 2) - return RET_TOOSMALL; - r[0] = 0xa1; - r[1] = 0xaa; - return 2; - } - - return RET_ILUNI; -} diff --git a/lib/generated/aliases.h b/lib/generated/aliases.h index f0b0123f..135f27e5 100644 --- a/lib/generated/aliases.h +++ b/lib/generated/aliases.h @@ -1,6 +1,6 @@ -/* C++ code produced by gperf version 3.1 */ -/* Command-line: gperf -L C++ -Z HashPool -m 10 lib/generated/aliases.gperf */ -/* Computed positions: -k'1,3-11,$' */ +/* ANSI-C code produced by gperf version 3.1 */ +/* Command-line: gperf -L ANSI-C -m 10 lib/generated/aliases.gperf */ +/* Computed positions: -k'1-10,$' */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ @@ -29,1695 +29,4198 @@ #error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif -#line 1 "lib/generated/aliases.gperf" +#line 2 "lib/generated/aliases.gperf" struct alias { int name; unsigned int encoding_index; }; -#define TOTAL_KEYWORDS 349 +#define TOTAL_KEYWORDS 840 #define MIN_WORD_LENGTH 2 -#define MAX_WORD_LENGTH 45 -#define MIN_HASH_VALUE 7 -#define MAX_HASH_VALUE 875 -/* maximum key range = 869, duplicates = 0 */ +#define MAX_WORD_LENGTH 39 +#define MIN_HASH_VALUE 4 +#define MAX_HASH_VALUE 4067 +/* maximum key range = 4064, duplicates = 0 */ -class HashPool -{ -private: - static inline unsigned int aliases_hash (const char *str, size_t len); -public: - static const struct alias *aliases_lookup (const char *str, size_t len); -}; - -inline unsigned int -HashPool::aliases_hash (const char *str, size_t len) +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static unsigned int +aliases_hash (register const char *str, register size_t len) { static const unsigned short asso_values[] = { - 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, - 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, - 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, - 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, - 876, 876, 876, 876, 876, 2, 87, 876, 73, 4, - 29, 66, 16, 22, 11, 179, 3, 10, 152, 876, - 876, 876, 876, 876, 876, 10, 221, 9, 35, 96, - 163, 49, 84, 63, 281, 195, 16, 84, 5, 2, - 3, 876, 2, 2, 110, 42, 132, 137, 230, 20, - 3, 876, 876, 876, 876, 3, 876, 876, 876, 876, - 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, - 876, 876, 876, 876, 876, 876, 876, 876, 876, 876, - 876, 876, 876, 876, 876, 876, 876, 876 + 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, + 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, + 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, + 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, + 4068, 4068, 4068, 4068, 4068, 1, 44, 4068, 3, 0, + 34, 260, 15, 6, 98, 544, 64, 341, 644, 844, + 849, 805, 4068, 4068, 4068, 530, 441, 0, 748, 328, + 469, 5, 177, 0, 589, 510, 3, 1, 11, 386, + 25, 112, 151, 0, 424, 2, 182, 536, 220, 14, + 2, 8, 0, 0, 4068, 4068, 4068, 4068, 4068, 4068, + 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, + 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, + 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, 4068, + 4068, 4068 }; - unsigned int hval = len; + register unsigned int hval = len; switch (hval) { default: - hval += asso_values[static_cast(str[10])]; - /*FALLTHROUGH*/ - case 10: - hval += asso_values[static_cast(str[9])]; + hval += asso_values[(unsigned char)str[9]]; /*FALLTHROUGH*/ case 9: - hval += asso_values[static_cast(str[8])]; + hval += asso_values[(unsigned char)str[8]]; /*FALLTHROUGH*/ case 8: - hval += asso_values[static_cast(str[7])]; + hval += asso_values[(unsigned char)str[7]]; /*FALLTHROUGH*/ case 7: - hval += asso_values[static_cast(str[6])]; + hval += asso_values[(unsigned char)str[6]]; /*FALLTHROUGH*/ case 6: - hval += asso_values[static_cast(str[5])]; + hval += asso_values[(unsigned char)str[5]+4]; /*FALLTHROUGH*/ case 5: - hval += asso_values[static_cast(str[4])]; + hval += asso_values[(unsigned char)str[4]]; /*FALLTHROUGH*/ case 4: - hval += asso_values[static_cast(str[3])]; + hval += asso_values[(unsigned char)str[3]]; /*FALLTHROUGH*/ case 3: - hval += asso_values[static_cast(str[2])]; + hval += asso_values[(unsigned char)str[2]]; /*FALLTHROUGH*/ case 2: + hval += asso_values[(unsigned char)str[1]+2]; + /*FALLTHROUGH*/ case 1: - hval += asso_values[static_cast(str[0])]; + hval += asso_values[(unsigned char)str[0]]; break; } - return hval + asso_values[static_cast(str[len - 1])]; + return hval + asso_values[(unsigned char)str[len - 1]]; } struct stringpool_t { - char stringpool_str7[sizeof("R8")]; - char stringpool_str16[sizeof("CN")]; - char stringpool_str21[sizeof("L8")]; - char stringpool_str22[sizeof("L1")]; - char stringpool_str28[sizeof("866")]; - char stringpool_str29[sizeof("L6")]; - char stringpool_str32[sizeof("C99")]; - char stringpool_str34[sizeof("L4")]; - char stringpool_str40[sizeof("L5")]; - char stringpool_str41[sizeof("CP819")]; - char stringpool_str46[sizeof("US")]; - char stringpool_str47[sizeof("L2")]; - char stringpool_str50[sizeof("CP866")]; - char stringpool_str60[sizeof("CP949")]; - char stringpool_str63[sizeof("UHC")]; - char stringpool_str64[sizeof("862")]; - char stringpool_str66[sizeof("PT154")]; - char stringpool_str72[sizeof("CP154")]; - char stringpool_str73[sizeof("SJIS")]; - char stringpool_str76[sizeof("CP1258")]; - char stringpool_str78[sizeof("CP1251")]; - char stringpool_str80[sizeof("PTCP154")]; - char stringpool_str83[sizeof("UCS-4")]; - char stringpool_str84[sizeof("L3")]; - char stringpool_str86[sizeof("CP862")]; - char stringpool_str89[sizeof("HZ")]; - char stringpool_str92[sizeof("CP1256")]; - char stringpool_str97[sizeof("CP1131")]; - char stringpool_str100[sizeof("CSUCS4")]; - char stringpool_str102[sizeof("CP1254")]; - char stringpool_str104[sizeof("CP1361")]; - char stringpool_str105[sizeof("MAC")]; - char stringpool_str107[sizeof("RK1048")]; - char stringpool_str109[sizeof("UCS-2")]; - char stringpool_str112[sizeof("CP936")]; - char stringpool_str113[sizeof("ROMAN8")]; - char stringpool_str114[sizeof("CP1255")]; - char stringpool_str120[sizeof("ISO8859-8")]; - char stringpool_str122[sizeof("ISO8859-1")]; - char stringpool_str123[sizeof("ISO-8859-8")]; - char stringpool_str124[sizeof("ISO_8859-8")]; - char stringpool_str125[sizeof("ISO-8859-1")]; - char stringpool_str126[sizeof("ISO_8859-1")]; - char stringpool_str127[sizeof("ISO8859-11")]; - char stringpool_str128[sizeof("CP1252")]; - char stringpool_str129[sizeof("EUCCN")]; - char stringpool_str130[sizeof("ISO-8859-11")]; - char stringpool_str131[sizeof("ISO_8859-11")]; - char stringpool_str132[sizeof("EUC-CN")]; - char stringpool_str133[sizeof("ISO646-CN")]; - char stringpool_str134[sizeof("ISO8859-9")]; - char stringpool_str136[sizeof("ISO8859-6")]; - char stringpool_str137[sizeof("ISO-8859-9")]; - char stringpool_str138[sizeof("ISO_8859-9")]; - char stringpool_str139[sizeof("ISO-8859-6")]; - char stringpool_str140[sizeof("ISO_8859-6")]; - char stringpool_str141[sizeof("ISO8859-16")]; - char stringpool_str143[sizeof("ISO_8859-16:2001")]; - char stringpool_str144[sizeof("ISO-8859-16")]; - char stringpool_str145[sizeof("ISO_8859-16")]; - char stringpool_str146[sizeof("ISO8859-4")]; - char stringpool_str147[sizeof("ISO_8859-14:1998")]; - char stringpool_str148[sizeof("CP932")]; - char stringpool_str149[sizeof("ISO-8859-4")]; - char stringpool_str150[sizeof("ISO_8859-4")]; - char stringpool_str151[sizeof("ISO8859-14")]; - char stringpool_str152[sizeof("850")]; - char stringpool_str153[sizeof("ISO_8859-15:1998")]; - char stringpool_str154[sizeof("ISO-8859-14")]; - char stringpool_str155[sizeof("ISO_8859-14")]; - char stringpool_str156[sizeof("MS-CYRL")]; - char stringpool_str158[sizeof("ISO8859-5")]; - char stringpool_str160[sizeof("ISO646-US")]; - char stringpool_str161[sizeof("ISO-8859-5")]; - char stringpool_str162[sizeof("ISO_8859-5")]; - char stringpool_str163[sizeof("ISO8859-15")]; - char stringpool_str164[sizeof("ISO-IR-6")]; - char stringpool_str165[sizeof("L10")]; - char stringpool_str166[sizeof("ISO-8859-15")]; - char stringpool_str167[sizeof("ISO_8859-15")]; - char stringpool_str170[sizeof("ISO-IR-148")]; - char stringpool_str171[sizeof("ISO-IR-58")]; - char stringpool_str172[sizeof("ISO8859-2")]; - char stringpool_str175[sizeof("ISO-8859-2")]; - char stringpool_str176[sizeof("ISO_8859-2")]; - char stringpool_str177[sizeof("CP50221")]; - char stringpool_str178[sizeof("ISO-IR-199")]; - char stringpool_str179[sizeof("ISO-IR-14")]; - char stringpool_str180[sizeof("IBM819")]; - char stringpool_str181[sizeof("ISO-IR-166")]; - char stringpool_str184[sizeof("ISO-IR-149")]; - char stringpool_str185[sizeof("CP850")]; - char stringpool_str187[sizeof("MS936")]; - char stringpool_str189[sizeof("IBM866")]; - char stringpool_str190[sizeof("ISO-IR-159")]; - char stringpool_str192[sizeof("CP950")]; + char stringpool_str4[sizeof("MAC")]; + char stringpool_str6[sizeof("US")]; + char stringpool_str7[sizeof("SJIS")]; + char stringpool_str22[sizeof("1201")]; + char stringpool_str25[sizeof("1251")]; + char stringpool_str26[sizeof("12001")]; + char stringpool_str28[sizeof("1200")]; + char stringpool_str31[sizeof("1250")]; + char stringpool_str32[sizeof("12000")]; + char stringpool_str37[sizeof("1255")]; + char stringpool_str38[sizeof("CN")]; + char stringpool_str45[sizeof("425")]; + char stringpool_str48[sizeof("10010")]; + char stringpool_str49[sizeof("500")]; + char stringpool_str51[sizeof("10000")]; + char stringpool_str54[sizeof("L2")]; + char stringpool_str55[sizeof("1254")]; + char stringpool_str57[sizeof("10005")]; + char stringpool_str63[sizeof("424")]; + char stringpool_str75[sizeof("10004")]; + char stringpool_str76[sizeof("10021")]; + char stringpool_str77[sizeof("5601")]; + char stringpool_str79[sizeof("U32")]; + char stringpool_str84[sizeof("1025")]; + char stringpool_str89[sizeof("CSUCS4")]; + char stringpool_str93[sizeof("1252")]; + char stringpool_str106[sizeof("10081")]; + char stringpool_str108[sizeof("1361")]; + char stringpool_str113[sizeof("50221")]; + char stringpool_str118[sizeof("L4")]; + char stringpool_str125[sizeof("50225")]; + char stringpool_str131[sizeof("861")]; + char stringpool_str137[sizeof("860")]; + char stringpool_str143[sizeof("865")]; + char stringpool_str153[sizeof("1258")]; + char stringpool_str155[sizeof("CPIS")]; + char stringpool_str161[sizeof("864")]; + char stringpool_str166[sizeof("16804")]; + char stringpool_str167[sizeof("L6")]; + char stringpool_str171[sizeof("CP500")]; + char stringpool_str172[sizeof("CP1051")]; + char stringpool_str174[sizeof("10082")]; + char stringpool_str176[sizeof("CP10010")]; + char stringpool_str178[sizeof("CP1141")]; + char stringpool_str181[sizeof("HZ")]; + char stringpool_str185[sizeof("CP10000")]; + char stringpool_str190[sizeof("CP1140")]; + char stringpool_str191[sizeof("CP10005")]; + char stringpool_str192[sizeof("CP154")]; char stringpool_str195[sizeof("CYRILLIC")]; - char stringpool_str196[sizeof("ISO-IR-144")]; - char stringpool_str197[sizeof("L7")]; - char stringpool_str199[sizeof("ISO-IR-126")]; - char stringpool_str200[sizeof("GEORGIAN-PS")]; - char stringpool_str201[sizeof("CSPTCP154")]; - char stringpool_str202[sizeof("CP1253")]; - char stringpool_str203[sizeof("ISO-IR-165")]; - char stringpool_str204[sizeof("HP-ROMAN8")]; - char stringpool_str206[sizeof("LATIN8")]; - char stringpool_str208[sizeof("LATIN1")]; - char stringpool_str209[sizeof("MACROMAN")]; - char stringpool_str211[sizeof("CYRILLIC-ASIAN")]; - char stringpool_str212[sizeof("GB2312")]; - char stringpool_str213[sizeof("ASCII")]; - char stringpool_str214[sizeof("ECMA-118")]; - char stringpool_str215[sizeof("CSHPROMAN8")]; - char stringpool_str216[sizeof("CP1250")]; - char stringpool_str218[sizeof("UTF-8")]; - char stringpool_str220[sizeof("ISO-IR-138")]; - char stringpool_str221[sizeof("CP1133")]; - char stringpool_str222[sizeof("LATIN6")]; - char stringpool_str223[sizeof("LATIN-9")]; - char stringpool_str224[sizeof("ISO-IR-226")]; - char stringpool_str225[sizeof("IBM862")]; - char stringpool_str226[sizeof("CSASCII")]; - char stringpool_str228[sizeof("CP874")]; - char stringpool_str229[sizeof("ISO-IR-101")]; - char stringpool_str230[sizeof("ISO_8859-10:1992")]; - char stringpool_str232[sizeof("LATIN4")]; - char stringpool_str233[sizeof("GB_1988-80")]; - char stringpool_str236[sizeof("MS-ANSI")]; - char stringpool_str237[sizeof("GEORGIAN-ACADEMY")]; - char stringpool_str239[sizeof("UTF-16")]; - char stringpool_str240[sizeof("ECMA-114")]; - char stringpool_str241[sizeof("ISO-IR-109")]; - char stringpool_str243[sizeof("MULELAO-1")]; - char stringpool_str244[sizeof("LATIN5")]; - char stringpool_str246[sizeof("ISO8859-3")]; - char stringpool_str248[sizeof("ARMSCII-8")]; - char stringpool_str249[sizeof("ISO-8859-3")]; - char stringpool_str250[sizeof("ISO_8859-3")]; - char stringpool_str251[sizeof("ISO8859-13")]; - char stringpool_str254[sizeof("ISO-8859-13")]; - char stringpool_str255[sizeof("ISO_8859-13")]; - char stringpool_str256[sizeof("TCVN")]; - char stringpool_str257[sizeof("ISO-10646-UCS-4")]; - char stringpool_str258[sizeof("LATIN2")]; - char stringpool_str259[sizeof("ISO-2022-CN")]; - char stringpool_str262[sizeof("US-ASCII")]; - char stringpool_str264[sizeof("ELOT_928")]; - char stringpool_str265[sizeof("ISO8859-10")]; - char stringpool_str266[sizeof("CSISO2022CN")]; - char stringpool_str267[sizeof("UCS-4-SWAPPED")]; - char stringpool_str268[sizeof("ISO-8859-10")]; - char stringpool_str269[sizeof("ISO_8859-10")]; - char stringpool_str270[sizeof("ISO-10646-UCS-2")]; - char stringpool_str273[sizeof("KOI8-R")]; - char stringpool_str274[sizeof("UNICODE-1-1")]; - char stringpool_str277[sizeof("UCS-4LE")]; - char stringpool_str280[sizeof("UCS-2-SWAPPED")]; - char stringpool_str281[sizeof("ISO_8859-8:1988")]; - char stringpool_str283[sizeof("CSKOI8R")]; - char stringpool_str284[sizeof("CSUNICODE11")]; - char stringpool_str286[sizeof("JP")]; - char stringpool_str289[sizeof("MACROMANIA")]; - char stringpool_str290[sizeof("UCS-2LE")]; - char stringpool_str294[sizeof("ISO_8859-4:1988")]; - char stringpool_str295[sizeof("ISO_8859-9:1989")]; - char stringpool_str298[sizeof("ISO-IR-110")]; - char stringpool_str299[sizeof("CSISOLATIN1")]; - char stringpool_str300[sizeof("ISO_8859-5:1988")]; - char stringpool_str303[sizeof("KZ-1048")]; - char stringpool_str304[sizeof("TIS620")]; - char stringpool_str307[sizeof("TIS-620")]; - char stringpool_str309[sizeof("EUCKR")]; - char stringpool_str311[sizeof("MACCYRILLIC")]; - char stringpool_str312[sizeof("EUC-KR")]; - char stringpool_str313[sizeof("CSISOLATIN6")]; - char stringpool_str314[sizeof("CSKZ1048")]; - char stringpool_str315[sizeof("CSISOLATINARABIC")]; - char stringpool_str316[sizeof("CSISOLATINCYRILLIC")]; - char stringpool_str318[sizeof("BIG5")]; - char stringpool_str319[sizeof("KOREAN")]; - char stringpool_str320[sizeof("MACCROATIAN")]; - char stringpool_str321[sizeof("BIG-5")]; - char stringpool_str323[sizeof("CSISOLATIN4")]; - char stringpool_str324[sizeof("IBM850")]; - char stringpool_str326[sizeof("X0212")]; - char stringpool_str328[sizeof("ARABIC")]; - char stringpool_str329[sizeof("KSC_5601")]; - char stringpool_str332[sizeof("LATIN3")]; - char stringpool_str335[sizeof("CSISOLATIN5")]; - char stringpool_str337[sizeof("UTF-32")]; - char stringpool_str338[sizeof("VISCII")]; - char stringpool_str341[sizeof("GB_2312-80")]; - char stringpool_str343[sizeof("X0208")]; - char stringpool_str344[sizeof("ISO_8859-3:1988")]; - char stringpool_str345[sizeof("X0201")]; - char stringpool_str347[sizeof("ISO-IR-179")]; - char stringpool_str348[sizeof("GB18030")]; - char stringpool_str349[sizeof("CSISOLATIN2")]; - char stringpool_str350[sizeof("KS_C_5601-1989")]; - char stringpool_str351[sizeof("LATIN10")]; - char stringpool_str353[sizeof("KOI8-U")]; - char stringpool_str356[sizeof("KOI8-RU")]; - char stringpool_str362[sizeof("CSEUCKR")]; - char stringpool_str364[sizeof("ASMO-708")]; - char stringpool_str366[sizeof("CSUNICODE")]; - char stringpool_str367[sizeof("ISO-IR-100")]; - char stringpool_str368[sizeof("ISO-2022-CN-EXT")]; - char stringpool_str370[sizeof("UCS-4-INTERNAL")]; - char stringpool_str372[sizeof("MACICELAND")]; - char stringpool_str374[sizeof("CHINESE")]; - char stringpool_str377[sizeof("IBM-CP1133")]; - char stringpool_str378[sizeof("ISO-IR-203")]; - char stringpool_str379[sizeof("MS-EE")]; - char stringpool_str381[sizeof("TIS620-0")]; - char stringpool_str383[sizeof("UCS-2-INTERNAL")]; - char stringpool_str385[sizeof("VISCII1.1-1")]; - char stringpool_str389[sizeof("ISO-CELTIC")]; - char stringpool_str390[sizeof("WINDOWS-1258")]; - char stringpool_str391[sizeof("WINDOWS-1251")]; - char stringpool_str392[sizeof("CSBIG5")]; - char stringpool_str395[sizeof("CN-BIG5")]; - char stringpool_str397[sizeof("EUCJP")]; - char stringpool_str398[sizeof("WINDOWS-1256")]; - char stringpool_str400[sizeof("EUC-JP")]; - char stringpool_str401[sizeof("ISO646-JP")]; - char stringpool_str403[sizeof("WINDOWS-1254")]; - char stringpool_str406[sizeof("CSPC850MULTILINGUAL")]; - char stringpool_str409[sizeof("WINDOWS-1255")]; - char stringpool_str410[sizeof("ISO_646.IRV:1991")]; - char stringpool_str412[sizeof("CSVISCII")]; - char stringpool_str416[sizeof("WINDOWS-1252")]; - char stringpool_str418[sizeof("CSPC862LATINHEBREW")]; - char stringpool_str419[sizeof("TIS620.2529-1")]; - char stringpool_str421[sizeof("CSIBM866")]; - char stringpool_str423[sizeof("CSISOLATIN3")]; - char stringpool_str426[sizeof("MACARABIC")]; - char stringpool_str428[sizeof("CP1257")]; - char stringpool_str429[sizeof("WINDOWS-936")]; - char stringpool_str430[sizeof("MACTHAI")]; - char stringpool_str437[sizeof("JAVA")]; - char stringpool_str438[sizeof("UTF-16LE")]; - char stringpool_str439[sizeof("ISO-2022-KR")]; - char stringpool_str441[sizeof("STRK1048-2002")]; - char stringpool_str442[sizeof("GBK")]; - char stringpool_str444[sizeof("CSGB2312")]; - char stringpool_str446[sizeof("CSISO2022KR")]; - char stringpool_str448[sizeof("GREEK8")]; - char stringpool_str449[sizeof("CP367")]; - char stringpool_str451[sizeof("CN-GB-ISOIR165")]; - char stringpool_str452[sizeof("MACINTOSH")]; - char stringpool_str453[sizeof("WINDOWS-1253")]; - char stringpool_str455[sizeof("UNICODE-1-1-UTF-7")]; - char stringpool_str458[sizeof("ISO_8859-1:1987")]; - char stringpool_str460[sizeof("WINDOWS-1250")]; - char stringpool_str461[sizeof("JIS_C6226-1983")]; - char stringpool_str462[sizeof("JIS_C6220-1969-RO")]; - char stringpool_str463[sizeof("CSUNICODE11UTF7")]; - char stringpool_str465[sizeof("ISO_8859-6:1987")]; - char stringpool_str470[sizeof("CSISO14JISC6220RO")]; - char stringpool_str471[sizeof("JIS0208")]; - char stringpool_str472[sizeof("ISO8859-7")]; - char stringpool_str473[sizeof("CSMACINTOSH")]; - char stringpool_str475[sizeof("ISO-8859-7")]; - char stringpool_str476[sizeof("ISO_8859-7")]; - char stringpool_str482[sizeof("UCS-4BE")]; - char stringpool_str483[sizeof("ISO_8859-2:1987")]; - char stringpool_str489[sizeof("KOI8-T")]; - char stringpool_str494[sizeof("EUCTW")]; - char stringpool_str495[sizeof("UCS-2BE")]; - char stringpool_str497[sizeof("EUC-TW")]; - char stringpool_str498[sizeof("MS-HEBR")]; - char stringpool_str500[sizeof("ANSI_X3.4-1968")]; - char stringpool_str501[sizeof("TCVN5712-1")]; - char stringpool_str504[sizeof("ISO-IR-87")]; - char stringpool_str507[sizeof("CN-GB")]; - char stringpool_str508[sizeof("ANSI_X3.4-1986")]; - char stringpool_str512[sizeof("TIS620.2533-1")]; - char stringpool_str517[sizeof("CSISOLATINHEBREW")]; - char stringpool_str518[sizeof("UTF-32LE")]; - char stringpool_str519[sizeof("KS_C_5601-1987")]; - char stringpool_str520[sizeof("ISO_8859-7:2003")]; - char stringpool_str521[sizeof("TCVN-5712")]; - char stringpool_str523[sizeof("ISO-IR-57")]; - char stringpool_str525[sizeof("HZ-GB-2312")]; - char stringpool_str527[sizeof("ISO-2022-JP")]; - char stringpool_str528[sizeof("ISO-IR-157")]; - char stringpool_str529[sizeof("ISO-2022-JP-MS")]; - char stringpool_str530[sizeof("ISO-2022-JP-1")]; - char stringpool_str531[sizeof("CSKSC56011987")]; - char stringpool_str534[sizeof("CSISO2022JP")]; - char stringpool_str535[sizeof("ISO-IR-127")]; - char stringpool_str539[sizeof("CSISOLATINGREEK")]; - char stringpool_str545[sizeof("WINDOWS-874")]; - char stringpool_str547[sizeof("CSEUCTW")]; - char stringpool_str549[sizeof("MACCENTRALEUROPE")]; - char stringpool_str551[sizeof("CSISO159JISX02121990")]; - char stringpool_str554[sizeof("CSISO58GB231280")]; - char stringpool_str555[sizeof("ISO-2022-JP-2")]; - char stringpool_str557[sizeof("MS-ARAB")]; - char stringpool_str558[sizeof("LATIN7")]; - char stringpool_str561[sizeof("CSISO2022JP2")]; - char stringpool_str566[sizeof("WINDOWS-1257")]; - char stringpool_str567[sizeof("NEXTSTEP")]; - char stringpool_str570[sizeof("UTF-7")]; - char stringpool_str577[sizeof("CSISO57GB1988")]; - char stringpool_str581[sizeof("TIS620.2533-0")]; - char stringpool_str588[sizeof("IBM367")]; - char stringpool_str592[sizeof("GB18030:2022")]; - char stringpool_str595[sizeof("BIG5HKSCS")]; - char stringpool_str598[sizeof("BIG5-HKSCS")]; - char stringpool_str612[sizeof("MACUKRAINE")]; - char stringpool_str629[sizeof("GB18030:2005")]; - char stringpool_str633[sizeof("ISO_8859-7:1987")]; - char stringpool_str636[sizeof("GREEK")]; - char stringpool_str637[sizeof("MS-TURK")]; - char stringpool_str639[sizeof("UNICODEBIG")]; - char stringpool_str643[sizeof("UTF-16BE")]; - char stringpool_str655[sizeof("UNICODELITTLE")]; - char stringpool_str664[sizeof("EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE")]; - char stringpool_str683[sizeof("HEBREW")]; - char stringpool_str685[sizeof("MACTURKISH")]; - char stringpool_str689[sizeof("JIS_X0212")]; - char stringpool_str697[sizeof("SHIFT-JIS")]; - char stringpool_str698[sizeof("SHIFT_JIS")]; - char stringpool_str706[sizeof("JIS_X0208")]; - char stringpool_str708[sizeof("JIS_X0201")]; - char stringpool_str712[sizeof("MS_KANJI")]; - char stringpool_str720[sizeof("TCVN5712-1:1993")]; - char stringpool_str723[sizeof("UTF-32BE")]; - char stringpool_str727[sizeof("MS-GREEK")]; - char stringpool_str732[sizeof("JISX0201-1976")]; - char stringpool_str734[sizeof("MACGREEK")]; - char stringpool_str740[sizeof("CSHALFWIDTHKATAKANA")]; - char stringpool_str742[sizeof("WINBALTRIM")]; - char stringpool_str744[sizeof("JIS_X0212-1990")]; - char stringpool_str756[sizeof("BIG5-HKSCS:2008")]; - char stringpool_str757[sizeof("BIG5-HKSCS:2001")]; - char stringpool_str763[sizeof("BIG5-HKSCS:1999")]; - char stringpool_str769[sizeof("BIG5-HKSCS:2004")]; - char stringpool_str780[sizeof("JIS_X0208-1983")]; - char stringpool_str787[sizeof("JIS_X0208-1990")]; - char stringpool_str789[sizeof("CSSHIFTJIS")]; - char stringpool_str822[sizeof("JOHAB")]; - char stringpool_str827[sizeof("BIGFIVE")]; - char stringpool_str830[sizeof("BIG-FIVE")]; - char stringpool_str831[sizeof("JIS_X0212.1990-0")]; - char stringpool_str852[sizeof("CSISO87JISX0208")]; - char stringpool_str861[sizeof("CSEUCPKDFMTJAPANESE")]; - char stringpool_str875[sizeof("MACHEBREW")]; + char stringpool_str197[sizeof("CSVISCII")]; + char stringpool_str199[sizeof("862")]; + char stringpool_str200[sizeof("CP1201")]; + char stringpool_str201[sizeof("838")]; + char stringpool_str202[sizeof("MSCYRL")]; + char stringpool_str203[sizeof("CP1251")]; + char stringpool_str209[sizeof("CP10004")]; + char stringpool_str210[sizeof("CP12001")]; + char stringpool_str212[sizeof("CP1200")]; + char stringpool_str214[sizeof("MACCYRILLIC")]; + char stringpool_str215[sizeof("CP1250")]; + char stringpool_str216[sizeof("CP12000")]; + char stringpool_str217[sizeof("CP425")]; + char stringpool_str221[sizeof("1256")]; + char stringpool_str225[sizeof("CP01141")]; + char stringpool_str231[sizeof("CP01140")]; + char stringpool_str232[sizeof("CP850")]; + char stringpool_str235[sizeof("CP424")]; + char stringpool_str237[sizeof("CP01145")]; + char stringpool_str238[sizeof("CP855")]; + char stringpool_str241[sizeof("10006")]; + char stringpool_str242[sizeof("CP1154")]; + char stringpool_str248[sizeof("PT154")]; + char stringpool_str249[sizeof("1046")]; + char stringpool_str251[sizeof("CP1144")]; + char stringpool_str255[sizeof("CP01144")]; + char stringpool_str260[sizeof("CP280")]; + char stringpool_str261[sizeof("CP1161")]; + char stringpool_str262[sizeof("CP10021")]; + char stringpool_str265[sizeof("L1")]; + char stringpool_str266[sizeof("CP285")]; + char stringpool_str268[sizeof("1026")]; + char stringpool_str270[sizeof("CP1124")]; + char stringpool_str271[sizeof("L3")]; + char stringpool_str272[sizeof("L10")]; + char stringpool_str273[sizeof("CP1160")]; + char stringpool_str276[sizeof("CP1254")]; + char stringpool_str279[sizeof("1141")]; + char stringpool_str280[sizeof("CP65001")]; + char stringpool_str282[sizeof("1155")]; + char stringpool_str284[sizeof("CP284")]; + char stringpool_str285[sizeof("1140")]; + char stringpool_str286[sizeof("CP65000")]; + char stringpool_str289[sizeof("CP1112")]; + char stringpool_str290[sizeof("CP880")]; + char stringpool_str291[sizeof("1145")]; + char stringpool_str293[sizeof("CP01142")]; + char stringpool_str294[sizeof("CP852")]; + char stringpool_str296[sizeof("X0201")]; + char stringpool_str299[sizeof("CP50221")]; + char stringpool_str300[sizeof("1154")]; + char stringpool_str304[sizeof("CP1142")]; + char stringpool_str309[sizeof("1144")]; + char stringpool_str310[sizeof("1125")]; + char stringpool_str311[sizeof("CP50225")]; + char stringpool_str318[sizeof("CP861")]; + char stringpool_str322[sizeof("CP282")]; + char stringpool_str323[sizeof("CP1122")]; + char stringpool_str324[sizeof("CP860")]; + char stringpool_str327[sizeof("866")]; + char stringpool_str328[sizeof("1124")]; + char stringpool_str329[sizeof("CP1252")]; + char stringpool_str330[sizeof("CP865")]; + char stringpool_str332[sizeof("1112")]; + char stringpool_str334[sizeof("CP1164")]; + char stringpool_str347[sizeof("1142")]; + char stringpool_str348[sizeof("CP864")]; + char stringpool_str353[sizeof("CP01148")]; + char stringpool_str354[sizeof("CP858")]; + char stringpool_str361[sizeof("X0212")]; + char stringpool_str362[sizeof("1161")]; + char stringpool_str364[sizeof("UCS4")]; + char stringpool_str365[sizeof("CP16804")]; + char stringpool_str366[sizeof("1122")]; + char stringpool_str368[sizeof("1160")]; + char stringpool_str374[sizeof("1165")]; + char stringpool_str375[sizeof("CP10006")]; + char stringpool_str386[sizeof("CP862")]; + char stringpool_str387[sizeof("CP1162")]; + char stringpool_str389[sizeof("924")]; + char stringpool_str392[sizeof("1164")]; + char stringpool_str395[sizeof("646")]; + char stringpool_str398[sizeof("1158")]; + char stringpool_str402[sizeof("UCS2")]; + char stringpool_str407[sizeof("1148")]; + char stringpool_str408[sizeof("871")]; + char stringpool_str414[sizeof("870")]; + char stringpool_str418[sizeof("932")]; + char stringpool_str420[sizeof("875")]; + char stringpool_str421[sizeof("CP01146")]; + char stringpool_str422[sizeof("CP856")]; + char stringpool_str423[sizeof("CP1131")]; + char stringpool_str424[sizeof("X0208")]; + char stringpool_str427[sizeof("922")]; + char stringpool_str430[sizeof("1162")]; + char stringpool_str431[sizeof("20866")]; + char stringpool_str433[sizeof("CP866U")]; + char stringpool_str435[sizeof("CP1130")]; + char stringpool_str438[sizeof("874")]; + char stringpool_str450[sizeof("LATIN1")]; + char stringpool_str457[sizeof("LATIN10")]; + char stringpool_str461[sizeof("U16")]; + char stringpool_str462[sizeof("CPGR")]; + char stringpool_str463[sizeof("CSPC850MULTILINGUAL")]; + char stringpool_str464[sizeof("CP-GR")]; + char stringpool_str466[sizeof("1156")]; + char stringpool_str475[sizeof("1146")]; + char stringpool_str484[sizeof("CSIBM01141")]; + char stringpool_str490[sizeof("CSIBM01140")]; + char stringpool_str496[sizeof("CSIBM01145")]; + char stringpool_str502[sizeof("HP15CN")]; + char stringpool_str505[sizeof("CSIBM1125")]; + char stringpool_str506[sizeof("278")]; + char stringpool_str509[sizeof("CP950")]; + char stringpool_str510[sizeof("CP1155")]; + char stringpool_str514[sizeof("CP866")]; + char stringpool_str519[sizeof("CP1145")]; + char stringpool_str521[sizeof("CP1361")]; + char stringpool_str523[sizeof("LATIN4")]; + char stringpool_str524[sizeof("1131")]; + char stringpool_str530[sizeof("1130")]; + char stringpool_str537[sizeof("ASCII")]; + char stringpool_str538[sizeof("CP1125")]; + char stringpool_str540[sizeof("CSASCII")]; + char stringpool_str541[sizeof("CP1025")]; + char stringpool_str542[sizeof("USASCII")]; + char stringpool_str544[sizeof("CP1255")]; + char stringpool_str545[sizeof("1253")]; + char stringpool_str546[sizeof("936")]; + char stringpool_str549[sizeof("CP1132")]; + char stringpool_str551[sizeof("MSANSI")]; + char stringpool_str552[sizeof("CSIBM01142")]; + char stringpool_str553[sizeof("423")]; + char stringpool_str555[sizeof("L5")]; + char stringpool_str556[sizeof("ISOIR101")]; + char stringpool_str557[sizeof("CSIBM1161")]; + char stringpool_str558[sizeof("1166")]; + char stringpool_str559[sizeof("ISOIR110")]; + char stringpool_str561[sizeof("CP924")]; + char stringpool_str562[sizeof("ISOIR100")]; + char stringpool_str576[sizeof("LATIN2")]; + char stringpool_str577[sizeof("154")]; + char stringpool_str579[sizeof("CSISO2022CN")]; + char stringpool_str580[sizeof("CSIBM424")]; + char stringpool_str582[sizeof("ISOIR14")]; + char stringpool_str588[sizeof("ISO2022CN")]; + char stringpool_str592[sizeof("1132")]; + char stringpool_str594[sizeof("UHC")]; + char stringpool_str598[sizeof("ISOIR144")]; + char stringpool_str599[sizeof("CP922")]; + char stringpool_str602[sizeof("CP1165")]; + char stringpool_str608[sizeof("CP838")]; + char stringpool_str610[sizeof("PTCP154")]; + char stringpool_str612[sizeof("CSIBM01148")]; + char stringpool_str617[sizeof("850")]; + char stringpool_str620[sizeof("CSIBM280")]; + char stringpool_str623[sizeof("855")]; + char stringpool_str624[sizeof("51950")]; + char stringpool_str625[sizeof("CSIBM1162")]; + char stringpool_str626[sizeof("CSIBM285")]; + char stringpool_str632[sizeof("12712")]; + char stringpool_str633[sizeof("CP00924")]; + char stringpool_str638[sizeof("KSC5601")]; + char stringpool_str644[sizeof("CSIBM284")]; + char stringpool_str646[sizeof("MS874")]; + char stringpool_str651[sizeof("863")]; + char stringpool_str653[sizeof("65001")]; + char stringpool_str657[sizeof("21866")]; + char stringpool_str659[sizeof("65000")]; + char stringpool_str663[sizeof("ISOIR165")]; + char stringpool_str667[sizeof("ANSI1251")]; + char stringpool_str679[sizeof("852")]; + char stringpool_str680[sizeof("CSKZ1048")]; + char stringpool_str682[sizeof("UCS4LE")]; + char stringpool_str687[sizeof("280")]; + char stringpool_str692[sizeof("CSIBM1026")]; + char stringpool_str693[sizeof("285")]; + char stringpool_str694[sizeof("RUSCII")]; + char stringpool_str695[sizeof("KOI8U")]; + char stringpool_str696[sizeof("ISOIR148")]; + char stringpool_str697[sizeof("CP00858")]; + char stringpool_str699[sizeof("VISCII")]; + char stringpool_str701[sizeof("UCS2LE")]; + char stringpool_str706[sizeof("U32LE")]; + char stringpool_str711[sizeof("284")]; + char stringpool_str712[sizeof("U8")]; + char stringpool_str713[sizeof("L8")]; + char stringpool_str717[sizeof("880")]; + char stringpool_str725[sizeof("CP423")]; + char stringpool_str739[sizeof("858")]; + char stringpool_str741[sizeof("CYRILLICASIAN")]; + char stringpool_str742[sizeof("CYRIILLICASIAN")]; + char stringpool_str745[sizeof("CP01143")]; + char stringpool_str746[sizeof("CP853")]; + char stringpool_str747[sizeof("VISCII1.11")]; + char stringpool_str749[sizeof("282")]; + char stringpool_str758[sizeof("10029")]; + char stringpool_str764[sizeof("CP871")]; + char stringpool_str767[sizeof("JP")]; + char stringpool_str770[sizeof("CP870")]; + char stringpool_str776[sizeof("CP875")]; + char stringpool_str781[sizeof("IBM01141")]; + char stringpool_str782[sizeof("IBM500")]; + char stringpool_str783[sizeof("ISOIR126")]; + char stringpool_str785[sizeof("UTF8")]; + char stringpool_str787[sizeof("IBM01140")]; + char stringpool_str790[sizeof("1153")]; + char stringpool_str791[sizeof("LATIN5")]; + char stringpool_str793[sizeof("IBM01145")]; + char stringpool_str794[sizeof("CP874")]; + char stringpool_str796[sizeof("28605")]; + char stringpool_str799[sizeof("1143")]; + char stringpool_str801[sizeof("CSBIG5")]; + char stringpool_str802[sizeof("CSIBM500")]; + char stringpool_str805[sizeof("MS936")]; + char stringpool_str807[sizeof("856")]; + char stringpool_str810[sizeof("CP12712")]; + char stringpool_str811[sizeof("IBM01144")]; + char stringpool_str813[sizeof("869")]; + char stringpool_str818[sizeof("1123")]; + char stringpool_str820[sizeof("IBM1141")]; + char stringpool_str823[sizeof("52936")]; + char stringpool_str824[sizeof("CNBIG5")]; + char stringpool_str825[sizeof("CP932")]; + char stringpool_str826[sizeof("IBM1140")]; + char stringpool_str830[sizeof("IBM1112")]; + char stringpool_str832[sizeof("IBM1145")]; + char stringpool_str838[sizeof("CP863")]; + char stringpool_str843[sizeof("IBM850")]; + char stringpool_str847[sizeof("ISOIR166")]; + char stringpool_str849[sizeof("IBM01142")]; + char stringpool_str850[sizeof("IBM1144")]; + char stringpool_str852[sizeof("CP51950")]; + char stringpool_str854[sizeof("UTF16")]; + char stringpool_str859[sizeof("KOI8RU")]; + char stringpool_str861[sizeof("R8")]; + char stringpool_str862[sizeof("CP278")]; + char stringpool_str866[sizeof("IBM1125")]; + char stringpool_str869[sizeof("IBM1025")]; + char stringpool_str871[sizeof("IBM280")]; + char stringpool_str875[sizeof("ISOIR226")]; + char stringpool_str877[sizeof("CSIBM00924")]; + char stringpool_str882[sizeof("1163")]; + char stringpool_str883[sizeof("IBM424")]; + char stringpool_str884[sizeof("IBM1124")]; + char stringpool_str888[sizeof("IBM1142")]; + char stringpool_str889[sizeof("U7")]; + char stringpool_str890[sizeof("L7")]; + char stringpool_str891[sizeof("EUCCN")]; + char stringpool_str894[sizeof("950")]; + char stringpool_str898[sizeof("273")]; + char stringpool_str900[sizeof("775")]; + char stringpool_str901[sizeof("IBM880")]; + char stringpool_str902[sizeof("CP819")]; + char stringpool_str905[sizeof("CP1156")]; + char stringpool_str906[sizeof("54936")]; + char stringpool_str907[sizeof("CP01149")]; + char stringpool_str909[sizeof("IBM01148")]; + char stringpool_str911[sizeof("ISOIR230")]; + char stringpool_str914[sizeof("CP1146")]; + char stringpool_str916[sizeof("CNGB")]; + char stringpool_str917[sizeof("CP1046")]; + char stringpool_str920[sizeof("CSPTCP154")]; + char stringpool_str922[sizeof("IBM1122")]; + char stringpool_str923[sizeof("IBM861")]; + char stringpool_str927[sizeof("UNICODE11")]; + char stringpool_str928[sizeof("SYSTEM1125")]; + char stringpool_str932[sizeof("IBM284")]; + char stringpool_str935[sizeof("IBM860")]; + char stringpool_str936[sizeof("CP1026")]; + char stringpool_str937[sizeof("MACTHAI")]; + char stringpool_str939[sizeof("CP1256")]; + char stringpool_str940[sizeof("51932")]; + char stringpool_str941[sizeof("ISOIR138")]; + char stringpool_str944[sizeof("CP10029")]; + char stringpool_str948[sizeof("IBM1148")]; + char stringpool_str953[sizeof("CP936")]; + char stringpool_str957[sizeof("IBM852")]; + char stringpool_str960[sizeof("TCVN")]; + char stringpool_str961[sizeof("1149")]; + char stringpool_str962[sizeof("943")]; + char stringpool_str967[sizeof("CP1153")]; + char stringpool_str972[sizeof("BIG5")]; + char stringpool_str976[sizeof("CP1143")]; + char stringpool_str977[sizeof("IBM01146")]; + char stringpool_str980[sizeof("1129")]; + char stringpool_str981[sizeof("MACINTOSH")]; + char stringpool_str983[sizeof("CSPCP852")]; + char stringpool_str985[sizeof("IBM282")]; + char stringpool_str986[sizeof("UTF32")]; + char stringpool_str991[sizeof("MSEE")]; + char stringpool_str993[sizeof("KOI8R")]; + char stringpool_str995[sizeof("CP1123")]; + char stringpool_str996[sizeof("IBM864")]; + char stringpool_str997[sizeof("CP1166")]; + char stringpool_str1000[sizeof("CP869")]; + char stringpool_str1001[sizeof("CP1253")]; + char stringpool_str1004[sizeof("CSIBM01143")]; + char stringpool_str1009[sizeof("819")]; + char stringpool_str1013[sizeof("CP10081")]; + char stringpool_str1015[sizeof("ISOIR58")]; + char stringpool_str1016[sizeof("IBM1146")]; + char stringpool_str1019[sizeof("IBM1046")]; + char stringpool_str1020[sizeof("STRK10482002")]; + char stringpool_str1024[sizeof("U16LE")]; + char stringpool_str1027[sizeof("CSEUCKR")]; + char stringpool_str1030[sizeof("28591")]; + char stringpool_str1032[sizeof("CP943")]; + char stringpool_str1035[sizeof("CSHPROMAN8")]; + char stringpool_str1042[sizeof("28595")]; + char stringpool_str1044[sizeof("1133")]; + char stringpool_str1049[sizeof("IBM862")]; + char stringpool_str1053[sizeof("IBM1026")]; + char stringpool_str1059[sizeof("CP1163")]; + char stringpool_str1060[sizeof("28594")]; + char stringpool_str1063[sizeof("CP4971")]; + char stringpool_str1067[sizeof("CP28591")]; + char stringpool_str1070[sizeof("CSIBM423")]; + char stringpool_str1072[sizeof("MSKANJI")]; + char stringpool_str1076[sizeof("CP1158")]; + char stringpool_str1077[sizeof("CSIBM1163")]; + char stringpool_str1079[sizeof("CP28595")]; + char stringpool_str1081[sizeof("CP10082")]; + char stringpool_str1085[sizeof("CP1148")]; + char stringpool_str1089[sizeof("RK1048")]; + char stringpool_str1090[sizeof("TIS620")]; + char stringpool_str1092[sizeof("ARMSCII8")]; + char stringpool_str1094[sizeof("TIS6200")]; + char stringpool_str1096[sizeof("CP21866")]; + char stringpool_str1097[sizeof("CP28594")]; + char stringpool_str1098[sizeof("28592")]; + char stringpool_str1099[sizeof("CP20866")]; + char stringpool_str1102[sizeof("CSGB2312")]; + char stringpool_str1109[sizeof("IBM1155")]; + char stringpool_str1110[sizeof("CP1258")]; + char stringpool_str1112[sizeof("437")]; + char stringpool_str1113[sizeof("1257")]; + char stringpool_str1114[sizeof("IBMEUCCN")]; + char stringpool_str1116[sizeof("CCSID01141")]; + char stringpool_str1117[sizeof("CP51932")]; + char stringpool_str1120[sizeof("UCS4BE")]; + char stringpool_str1122[sizeof("CCSID01140")]; + char stringpool_str1124[sizeof("949")]; + char stringpool_str1127[sizeof("IBM1154")]; + char stringpool_str1128[sizeof("CCSID01145")]; + char stringpool_str1129[sizeof("GEORGIANPS")]; + char stringpool_str1130[sizeof("10017")]; + char stringpool_str1131[sizeof("853")]; + char stringpool_str1133[sizeof("10007")]; + char stringpool_str1135[sizeof("CP28592")]; + char stringpool_str1137[sizeof("IBM1250")]; + char stringpool_str1139[sizeof("UCS2BE")]; + char stringpool_str1141[sizeof("1047")]; + char stringpool_str1143[sizeof("IBM1255")]; + char stringpool_str1144[sizeof("U32BE")]; + char stringpool_str1146[sizeof("CCSID01144")]; + char stringpool_str1151[sizeof("IBM425")]; + char stringpool_str1155[sizeof("ISO646US")]; + char stringpool_str1158[sizeof("28598")]; + char stringpool_str1160[sizeof("DOS862")]; + char stringpool_str1161[sizeof("IBM1254")]; + char stringpool_str1166[sizeof("CSIBM01149")]; + char stringpool_str1168[sizeof("ISOIR203")]; + char stringpool_str1172[sizeof("IBM855")]; + char stringpool_str1174[sizeof("ISOCELTIC")]; + char stringpool_str1175[sizeof("ISO646CN")]; + char stringpool_str1177[sizeof("ISO10646UCS4")]; + char stringpool_str1181[sizeof("ISO2022JP1")]; + char stringpool_str1182[sizeof("CSISO2022JP")]; + char stringpool_str1183[sizeof("ISO2022JPMS")]; + char stringpool_str1184[sizeof("CCSID01142")]; + char stringpool_str1185[sizeof("GB2312")]; + char stringpool_str1186[sizeof("LATIN6")]; + char stringpool_str1190[sizeof("L9")]; + char stringpool_str1192[sizeof("CSISO2022JP2")]; + char stringpool_str1194[sizeof("CP949")]; + char stringpool_str1195[sizeof("CP28598")]; + char stringpool_str1196[sizeof("ISO10646UCS2")]; + char stringpool_str1199[sizeof("IBM1252")]; + char stringpool_str1200[sizeof("IBM285")]; + char stringpool_str1205[sizeof("ISO2022JP")]; + char stringpool_str1206[sizeof("ISO88591")]; + char stringpool_str1207[sizeof("ISO885911")]; + char stringpool_str1209[sizeof("IBM924")]; + char stringpool_str1210[sizeof("MACROMAN")]; + char stringpool_str1211[sizeof("TIS620.25291")]; + char stringpool_str1212[sizeof("CNS11643")]; + char stringpool_str1213[sizeof("ISO885910")]; + char stringpool_str1218[sizeof("ISO88595")]; + char stringpool_str1219[sizeof("ISO885915")]; + char stringpool_str1221[sizeof("CP1133")]; + char stringpool_str1222[sizeof("CSIBM278")]; + char stringpool_str1223[sizeof("GB231280")]; + char stringpool_str1225[sizeof("IBM1158")]; + char stringpool_str1226[sizeof("28596")]; + char stringpool_str1229[sizeof("CSISO2022KR")]; + char stringpool_str1230[sizeof("ECMA114")]; + char stringpool_str1233[sizeof("ISO2022JP2004")]; + char stringpool_str1236[sizeof("ISO88594")]; + char stringpool_str1237[sizeof("ISO885914")]; + char stringpool_str1238[sizeof("ISOIR109")]; + char stringpool_str1241[sizeof("ISOIR159")]; + char stringpool_str1244[sizeof("CCSID01148")]; + char stringpool_str1248[sizeof("LATIN3")]; + char stringpool_str1249[sizeof("ISO2022JP2")]; + char stringpool_str1250[sizeof("ISOIR149")]; + char stringpool_str1251[sizeof("CP51949")]; + char stringpool_str1254[sizeof("CP273")]; + char stringpool_str1256[sizeof("CP775")]; + char stringpool_str1258[sizeof("CP10017")]; + char stringpool_str1259[sizeof("IBM1258")]; + char stringpool_str1260[sizeof("CP54936")]; + char stringpool_str1262[sizeof("IBM922")]; + char stringpool_str1263[sizeof("CP28596")]; + char stringpool_str1264[sizeof("IBM865")]; + char stringpool_str1266[sizeof("NEXTSTEP")]; + char stringpool_str1267[sizeof("CP10007")]; + char stringpool_str1268[sizeof("10079")]; + char stringpool_str1272[sizeof("CSIBM905")]; + char stringpool_str1274[sizeof("ISO88592")]; + char stringpool_str1277[sizeof("HZGB2312")]; + char stringpool_str1279[sizeof("CP52936")]; + char stringpool_str1286[sizeof("JIS0208")]; + char stringpool_str1287[sizeof("ISOIR6")]; + char stringpool_str1288[sizeof("MSHEBR")]; + char stringpool_str1291[sizeof("CSISO58GB231280")]; + char stringpool_str1293[sizeof("IBM1156")]; + char stringpool_str1300[sizeof("IBM1131")]; + char stringpool_str1301[sizeof("IBM01143")]; + char stringpool_str1302[sizeof("CCSID00858")]; + char stringpool_str1304[sizeof("28603")]; + char stringpool_str1305[sizeof("XMACCYRILLIC")]; + char stringpool_str1306[sizeof("IBM1130")]; + char stringpool_str1309[sizeof("51949")]; + char stringpool_str1312[sizeof("CCSID01146")]; + char stringpool_str1313[sizeof("CP01147")]; + char stringpool_str1314[sizeof("CP857")]; + char stringpool_str1318[sizeof("CP1149")]; + char stringpool_str1319[sizeof("CSIBM855")]; + char stringpool_str1327[sizeof("IBM1256")]; + char stringpool_str1328[sizeof("ECMA118")]; + char stringpool_str1332[sizeof("ISO2022CNEXT")]; + char stringpool_str1334[sizeof("ISO88598")]; + char stringpool_str1337[sizeof("CP1129")]; + char stringpool_str1340[sizeof("IBM1143")]; + char stringpool_str1341[sizeof("HPROMAN8")]; + char stringpool_str1350[sizeof("TDS565")]; + char stringpool_str1353[sizeof("CSISO159JISX02121990")]; + char stringpool_str1357[sizeof("LATIN8")]; + char stringpool_str1358[sizeof("1157")]; + char stringpool_str1367[sizeof("1147")]; + char stringpool_str1368[sizeof("IBM1132")]; + char stringpool_str1369[sizeof("IBM871")]; + char stringpool_str1371[sizeof("CSIBM880")]; + char stringpool_str1374[sizeof("IBM1123")]; + char stringpool_str1376[sizeof("PCK")]; + char stringpool_str1377[sizeof("GB18030")]; + char stringpool_str1378[sizeof("ISO2022KR")]; + char stringpool_str1379[sizeof("UNICODEBIG")]; + char stringpool_str1380[sizeof("CSIBMTHAI")]; + char stringpool_str1381[sizeof("IBM870")]; + char stringpool_str1384[sizeof("38598")]; + char stringpool_str1388[sizeof("KSC56011989")]; + char stringpool_str1389[sizeof("CSISOLATIN1")]; + char stringpool_str1390[sizeof("TACTIS")]; + char stringpool_str1393[sizeof("CSISOLATIN10")]; + char stringpool_str1394[sizeof("CSISOLATINARABIC")]; + char stringpool_str1395[sizeof("CSISOLATIN5")]; + char stringpool_str1396[sizeof("CSISOLATINCYRILLIC")]; + char stringpool_str1398[sizeof("ATARI")]; + char stringpool_str1399[sizeof("CSIBM861")]; + char stringpool_str1400[sizeof("IBM1161")]; + char stringpool_str1401[sizeof("CSISO14JISC6220RO")]; + char stringpool_str1402[sizeof("ISO88596")]; + char stringpool_str1403[sizeof("ISO885916")]; + char stringpool_str1404[sizeof("CSISOLATIN4")]; + char stringpool_str1405[sizeof("CSIBM860")]; + char stringpool_str1406[sizeof("IBM1160")]; + char stringpool_str1407[sizeof("4971")]; + char stringpool_str1411[sizeof("CSIBM865")]; + char stringpool_str1412[sizeof("IBM1165")]; + char stringpool_str1415[sizeof("367")]; + char stringpool_str1421[sizeof("CP38598")]; + char stringpool_str1423[sizeof("CSISOLATIN2")]; + char stringpool_str1425[sizeof("UCS4INTERNAL")]; + char stringpool_str1429[sizeof("CSIBM864")]; + char stringpool_str1430[sizeof("IBM1164")]; + char stringpool_str1431[sizeof("JISX0201")]; + char stringpool_str1435[sizeof("CSIBM858")]; + char stringpool_str1437[sizeof("TIS620.25331")]; + char stringpool_str1439[sizeof("UTF16LE")]; + char stringpool_str1440[sizeof("TIS620.25330")]; + char stringpool_str1444[sizeof("UCS2INTERNAL")]; + char stringpool_str1446[sizeof("IBM905")]; + char stringpool_str1447[sizeof("KZ1048")]; + char stringpool_str1460[sizeof("MACARABIC")]; + char stringpool_str1462[sizeof("U16BE")]; + char stringpool_str1463[sizeof("IBM01149")]; + char stringpool_str1466[sizeof("277")]; + char stringpool_str1468[sizeof("IBM1162")]; + char stringpool_str1470[sizeof("XMACCE")]; + char stringpool_str1477[sizeof("UNICODE11UTF7")]; + char stringpool_str1482[sizeof("MSTURK")]; + char stringpool_str1483[sizeof("MACTURKISH")]; + char stringpool_str1487[sizeof("CSISOLATIN6")]; + char stringpool_str1488[sizeof("IBM932")]; + char stringpool_str1493[sizeof("CSUNICODE11")]; + char stringpool_str1496[sizeof("JISX0212")]; + char stringpool_str1501[sizeof("SHIFTJIS")]; + char stringpool_str1502[sizeof("IBM1149")]; + char stringpool_str1507[sizeof("CP037")]; + char stringpool_str1508[sizeof("EUCJP")]; + char stringpool_str1509[sizeof("CCSID00924")]; + char stringpool_str1511[sizeof("CSKSC56011987")]; + char stringpool_str1513[sizeof("MACGREEK")]; + char stringpool_str1514[sizeof("MSGREEK")]; + char stringpool_str1515[sizeof("JISX0212.19900")]; + char stringpool_str1519[sizeof("CP437")]; + char stringpool_str1526[sizeof("IBM921CP28603")]; + char stringpool_str1528[sizeof("IBM1168")]; + char stringpool_str1529[sizeof("C99")]; + char stringpool_str1534[sizeof("BIG5HKSCS")]; + char stringpool_str1536[sizeof("IBM1129")]; + char stringpool_str1537[sizeof("ISO646.IRV:1991")]; + char stringpool_str1539[sizeof("KOI8T")]; + char stringpool_str1542[sizeof("BIG52003")]; + char stringpool_str1543[sizeof("CSMACINTOSH")]; + char stringpool_str1550[sizeof("28593")]; + char stringpool_str1551[sizeof("CP1157")]; + char stringpool_str1557[sizeof("SHIFTJIS2004")]; + char stringpool_str1559[sizeof("JISX0208")]; + char stringpool_str1560[sizeof("CP1147")]; + char stringpool_str1562[sizeof("CNGBISOIR165")]; + char stringpool_str1563[sizeof("CP1047")]; + char stringpool_str1565[sizeof("CSIBM1047")]; + char stringpool_str1567[sizeof("IBM856")]; + char stringpool_str1569[sizeof("IBMCP1133")]; + char stringpool_str1572[sizeof("CSIBM01147")]; + char stringpool_str1575[sizeof("CSGB18030")]; + char stringpool_str1576[sizeof("ISOIR199")]; + char stringpool_str1585[sizeof("CP1257")]; + char stringpool_str1587[sizeof("CP28593")]; + char stringpool_str1590[sizeof("LATIN9")]; + char stringpool_str1591[sizeof("KSC56011987")]; + char stringpool_str1593[sizeof("MULELAO1")]; + char stringpool_str1595[sizeof("CSIBM866")]; + char stringpool_str1596[sizeof("IBM1166")]; + char stringpool_str1602[sizeof("CP367")]; + char stringpool_str1608[sizeof("IBM423")]; + char stringpool_str1612[sizeof("1137")]; + char stringpool_str1613[sizeof("ASMO708")]; + char stringpool_str1614[sizeof("CSIBM273")]; + char stringpool_str1615[sizeof("CSPC8CODEPAGE1144")]; + char stringpool_str1617[sizeof("IBM1153")]; + char stringpool_str1619[sizeof("CP297")]; + char stringpool_str1621[sizeof("DECHANZI")]; + char stringpool_str1629[sizeof("IBM853")]; + char stringpool_str1631[sizeof("CSEUCTW")]; + char stringpool_str1632[sizeof("IBM00924")]; + char stringpool_str1635[sizeof("UTF32LE")]; + char stringpool_str1636[sizeof("CCSID01143")]; + char stringpool_str1637[sizeof("DECHANYU")]; + char stringpool_str1641[sizeof("737")]; + char stringpool_str1647[sizeof("ISOIR157")]; + char stringpool_str1649[sizeof("CSISOLATIN3")]; + char stringpool_str1652[sizeof("HEBREW")]; + char stringpool_str1653[sizeof("GEORGIANACADEMY")]; + char stringpool_str1658[sizeof("MACCROATIAN")]; + char stringpool_str1659[sizeof("IBM866")]; + char stringpool_str1661[sizeof("CSWINDOWS1251")]; + char stringpool_str1664[sizeof("CSWINDOWS1250")]; + char stringpool_str1667[sizeof("CSWINDOWS1255")]; + char stringpool_str1672[sizeof("CSISO885915CP28605")]; + char stringpool_str1675[sizeof("ISOIR127")]; + char stringpool_str1676[sizeof("CSWINDOWS1254")]; + char stringpool_str1681[sizeof("EUCKR")]; + char stringpool_str1685[sizeof("IBMTHAI")]; + char stringpool_str1686[sizeof("UNICODELITTLE")]; + char stringpool_str1690[sizeof("CP10079")]; + char stringpool_str1695[sizeof("CSWINDOWS1252")]; + char stringpool_str1696[sizeof("TIS620.2533")]; + char stringpool_str1698[sizeof("CSPC8CODEPAGE1146")]; + char stringpool_str1699[sizeof("857")]; + char stringpool_str1701[sizeof("ISO2022JP3")]; + char stringpool_str1703[sizeof("IBM12712")]; + char stringpool_str1710[sizeof("IBM875")]; + char stringpool_str1712[sizeof("28599")]; + char stringpool_str1721[sizeof("IBM863")]; + char stringpool_str1723[sizeof("ELOT928")]; + char stringpool_str1724[sizeof("ROMAN8")]; + char stringpool_str1725[sizeof("CSWINDOWS1258")]; + char stringpool_str1726[sizeof("ISO88593")]; + char stringpool_str1727[sizeof("ISO885913")]; + char stringpool_str1731[sizeof("IBMEUCJP")]; + char stringpool_str1737[sizeof("IBM16804")]; + char stringpool_str1738[sizeof("IBM858")]; + char stringpool_str1739[sizeof("CSWINDOWS874")]; + char stringpool_str1745[sizeof("UTF7")]; + char stringpool_str1746[sizeof("IBM00858")]; + char stringpool_str1749[sizeof("CP28599")]; + char stringpool_str1758[sizeof("CSKOI8U")]; + char stringpool_str1759[sizeof("CSWINDOWS1256")]; + char stringpool_str1776[sizeof("GBK")]; + char stringpool_str1779[sizeof("ISOIR179")]; + char stringpool_str1791[sizeof("CSSHIFTJIS")]; + char stringpool_str1792[sizeof("ISO646JP")]; + char stringpool_str1795[sizeof("ANSIX3.41968")]; + char stringpool_str1796[sizeof("CSISO57GB1988")]; + char stringpool_str1798[sizeof("CCSID01149")]; + char stringpool_str1799[sizeof("KOREAN")]; + char stringpool_str1805[sizeof("CP1137")]; + char stringpool_str1810[sizeof("JISX02121990")]; + char stringpool_str1811[sizeof("CP0037")]; + char stringpool_str1815[sizeof("CSIBM037")]; + char stringpool_str1819[sizeof("CSUNICODE")]; + char stringpool_str1822[sizeof("CP277")]; + char stringpool_str1827[sizeof("CSIBM853")]; + char stringpool_str1829[sizeof("ANSIX3.41986")]; + char stringpool_str1832[sizeof("LATIN7")]; + char stringpool_str1835[sizeof("JAVA")]; + char stringpool_str1838[sizeof("TCVN57121")]; + char stringpool_str1843[sizeof("JISX02081990")]; + char stringpool_str1845[sizeof("CSIBM871")]; + char stringpool_str1851[sizeof("CSIBM870")]; + char stringpool_str1852[sizeof("XMACROMANIAN")]; + char stringpool_str1864[sizeof("EBCDICCPIS")]; + char stringpool_str1866[sizeof("EBCDICCPUS")]; + char stringpool_str1869[sizeof("IBM01147")]; + char stringpool_str1871[sizeof("TCVN5712")]; + char stringpool_str1874[sizeof("JISX02011976")]; + char stringpool_str1881[sizeof("EBCDICCPNL")]; + char stringpool_str1882[sizeof("EBCDICCPYU")]; + char stringpool_str1883[sizeof("UTF16BE")]; + char stringpool_str1888[sizeof("ISO88599")]; + char stringpool_str1889[sizeof("CP1097")]; + char stringpool_str1893[sizeof("ISO885910:1992")]; + char stringpool_str1902[sizeof("MACUKRAINE")]; + char stringpool_str1903[sizeof("CSISOLATINGREEK")]; + char stringpool_str1904[sizeof("IBMEUCKR")]; + char stringpool_str1908[sizeof("IBM1147")]; + char stringpool_str1910[sizeof("CSKOI8RU")]; + char stringpool_str1911[sizeof("IBM1047")]; + char stringpool_str1915[sizeof("IBM943")]; + char stringpool_str1919[sizeof("CSIBM863")]; + char stringpool_str1920[sizeof("IBM1163")]; + char stringpool_str1921[sizeof("CSWINDOWS1253")]; + char stringpool_str1925[sizeof("ISO88595:1988")]; + char stringpool_str1926[sizeof("ISO885915:1998")]; + char stringpool_str1930[sizeof("CSISOLATINHEBREW")]; + char stringpool_str1932[sizeof("MACCENTRALEUROPE")]; + char stringpool_str1934[sizeof("ISO88594:1988")]; + char stringpool_str1935[sizeof("ISO885914:1998")]; + char stringpool_str1936[sizeof("ARABIC")]; + char stringpool_str1954[sizeof("ISO885916:2001")]; + char stringpool_str1956[sizeof("IBM4971")]; + char stringpool_str1965[sizeof("IBM819")]; + char stringpool_str1969[sizeof("297")]; + char stringpool_str1975[sizeof("ISOIR57")]; + char stringpool_str1979[sizeof("CSIBM297")]; + char stringpool_str1983[sizeof("ISO88598:1988")]; + char stringpool_str1989[sizeof("SHIFTJISX0213")]; + char stringpool_str1992[sizeof("IBM838")]; + char stringpool_str2008[sizeof("EBCDICCYRILLIC")]; + char stringpool_str2020[sizeof("UCS4SWAPPED")]; + char stringpool_str2026[sizeof("XMACICELANDIC")]; + char stringpool_str2039[sizeof("UCS2SWAPPED")]; + char stringpool_str2040[sizeof("JISC62261983")]; + char stringpool_str2041[sizeof("CSUNICODE11UTF7")]; + char stringpool_str2048[sizeof("CP737")]; + char stringpool_str2051[sizeof("MACICELAND")]; + char stringpool_str2056[sizeof("CSKOI8R")]; + char stringpool_str2063[sizeof("IBM869")]; + char stringpool_str2066[sizeof("GB18030:2005")]; + char stringpool_str2069[sizeof("EUCJIS2004")]; + char stringpool_str2073[sizeof("JISC62201969RO")]; + char stringpool_str2079[sizeof("UTF32BE")]; + char stringpool_str2081[sizeof("CSIBM869")]; + char stringpool_str2082[sizeof("IBM1169")]; + char stringpool_str2085[sizeof("GB198880")]; + char stringpool_str2090[sizeof("BIGFIVE")]; + char stringpool_str2094[sizeof("GB18030:2022")]; + char stringpool_str2100[sizeof("JISX02081983")]; + char stringpool_str2101[sizeof("XMACTHAI")]; + char stringpool_str2110[sizeof("GREEK")]; + char stringpool_str2118[sizeof("28597")]; + char stringpool_str2127[sizeof("CHINESE")]; + char stringpool_str2130[sizeof("MSARAB")]; + char stringpool_str2137[sizeof("IBM273")]; + char stringpool_str2143[sizeof("CSPC8CODEPAGE437")]; + char stringpool_str2155[sizeof("CP28597")]; + char stringpool_str2171[sizeof("EBCDICCPGR")]; + char stringpool_str2179[sizeof("ISO88593:1988")]; + char stringpool_str2182[sizeof("CSIBM277")]; + char stringpool_str2183[sizeof("BIG5HKSCS:2001")]; + char stringpool_str2185[sizeof("IBM1157")]; + char stringpool_str2190[sizeof("IBM775")]; + char stringpool_str2192[sizeof("EBCDICCPES")]; + char stringpool_str2198[sizeof("BIG5HKSCS:2004")]; + char stringpool_str2204[sizeof("CCSID01147")]; + char stringpool_str2205[sizeof("CSWINDOWS1257")]; + char stringpool_str2213[sizeof("IBM857")]; + char stringpool_str2218[sizeof("EBCDICCPCH")]; + char stringpool_str2219[sizeof("IBM1257")]; + char stringpool_str2240[sizeof("XMACUKRAINIAN")]; + char stringpool_str2244[sizeof("SDECKANJI")]; + char stringpool_str2246[sizeof("IBM278")]; + char stringpool_str2247[sizeof("BIG5HKSCS:2008")]; + char stringpool_str2250[sizeof("WINDOWS1251")]; + char stringpool_str2253[sizeof("WINDOWS1250")]; + char stringpool_str2256[sizeof("WINDOWS1255")]; + char stringpool_str2261[sizeof("MACROMANIA")]; + char stringpool_str2265[sizeof("WINDOWS1254")]; + char stringpool_str2280[sizeof("CSPC862LATINHEBREW")]; + char stringpool_str2284[sizeof("WINDOWS1252")]; + char stringpool_str2294[sizeof("ISO88597")]; + char stringpool_str2295[sizeof("JOHAB")]; + char stringpool_str2314[sizeof("WINDOWS1258")]; + char stringpool_str2333[sizeof("EBCDICCPFI")]; + char stringpool_str2348[sizeof("WINDOWS1256")]; + char stringpool_str2365[sizeof("EUCTW")]; + char stringpool_str2388[sizeof("IBM1137")]; + char stringpool_str2395[sizeof("CSIBM857")]; + char stringpool_str2399[sizeof("ISO88591:1987")]; + char stringpool_str2406[sizeof("IBM037")]; + char stringpool_str2408[sizeof("CSPC775BALTIC")]; + char stringpool_str2418[sizeof("IBM437")]; + char stringpool_str2423[sizeof("XMACTURKISH")]; + char stringpool_str2433[sizeof("ISO88592:1987")]; + char stringpool_str2449[sizeof("CSISO87JISX0208")]; + char stringpool_str2459[sizeof("CCSID853")]; + char stringpool_str2483[sizeof("ISOIR87")]; + char stringpool_str2497[sizeof("ISO88596:1987")]; + char stringpool_str2501[sizeof("IBM367")]; + char stringpool_str2502[sizeof("KOKR.JOHAP92")]; + char stringpool_str2510[sizeof("WINDOWS1253")]; + char stringpool_str2514[sizeof("GREEK8")]; + char stringpool_str2517[sizeof("EUCJISX0213")]; + char stringpool_str2518[sizeof("IBM297")]; + char stringpool_str2520[sizeof("EBCDICCPSE")]; + char stringpool_str2524[sizeof("BIG5HKSCS:1999")]; + char stringpool_str2535[sizeof("MACHEBREW")]; + char stringpool_str2537[sizeof("ISO88599:1989")]; + char stringpool_str2541[sizeof("DECKANJI")]; + char stringpool_str2552[sizeof("RISCOSLATIN1")]; + char stringpool_str2562[sizeof("WINDOWS950")]; + char stringpool_str2588[sizeof("IBMEUCTW")]; + char stringpool_str2590[sizeof("EBCDICCPTR")]; + char stringpool_str2635[sizeof("EBCDICCPFR")]; + char stringpool_str2640[sizeof("WINBALTRIM")]; + char stringpool_str2647[sizeof("EBCDICCPNO")]; + char stringpool_str2652[sizeof("IBM1097")]; + char stringpool_str2657[sizeof("EBCDICES284+EURO")]; + char stringpool_str2681[sizeof("XMACCROATIAN")]; + char stringpool_str2693[sizeof("ISO88597:2003")]; + char stringpool_str2697[sizeof("EBCDICCPHE")]; + char stringpool_str2712[sizeof("EBCDICCPIT")]; + char stringpool_str2720[sizeof("DECKOREAN")]; + char stringpool_str2721[sizeof("IBM277")]; + char stringpool_str2726[sizeof("EXTENDEDUNIXCODEPACKEDFORMATFORJAPANESE")]; + char stringpool_str2732[sizeof("EBCDICCPROECE")]; + char stringpool_str2747[sizeof("TCVN57121:1993")]; + char stringpool_str2751[sizeof("EBCDICCPGB")]; + char stringpool_str2753[sizeof("EBCDICIT280+EURO")]; + char stringpool_str2775[sizeof("EBCDICGB285+EURO")]; + char stringpool_str2784[sizeof("ATARIST")]; + char stringpool_str2794[sizeof("WINDOWS1257")]; + char stringpool_str2829[sizeof("XMACARABIC")]; + char stringpool_str2831[sizeof("CSEUCPKDFMTJAPANESE")]; + char stringpool_str2839[sizeof("EBCDICIS871+EURO")]; + char stringpool_str2847[sizeof("WINDOWS874")]; + char stringpool_str2924[sizeof("EBCDICCPCA")]; + char stringpool_str2943[sizeof("ISO88597:1987")]; + char stringpool_str2947[sizeof("IBM737")]; + char stringpool_str2961[sizeof("EBCDICCPBE")]; + char stringpool_str3005[sizeof("EBCDICINTERNATIONAL500+EURO")]; + char stringpool_str3006[sizeof("WINDOWS936")]; + char stringpool_str3008[sizeof("XMACGREEK")]; + char stringpool_str3036[sizeof("EBCDICUS37+EURO")]; + char stringpool_str3137[sizeof("EBCDICSE278+EURO")]; + char stringpool_str3162[sizeof("EBCDICGREEK")]; + char stringpool_str3188[sizeof("EBCDICLATIN9EURO")]; + char stringpool_str3206[sizeof("EBCDICNO277+EURO")]; + char stringpool_str3226[sizeof("EBCDICFR297+EURO")]; + char stringpool_str3248[sizeof("EBCDICCPWT")]; + char stringpool_str3278[sizeof("EBCDICFI278+EURO")]; + char stringpool_str3315[sizeof("XMACHEBREW")]; + char stringpool_str3558[sizeof("CSHALFWIDTHKATAKANA")]; + char stringpool_str3632[sizeof("EBCDICCPDK")]; + char stringpool_str3885[sizeof("EBCDICDE273+EURO")]; + char stringpool_str4067[sizeof("EBCDICDK277+EURO")]; }; static const struct stringpool_t stringpool_contents = { - "R8", - "CN", - "L8", - "L1", - "866", - "L6", - "C99", - "L4", - "L5", - "CP819", + "MAC", "US", + "SJIS", + "1201", + "1251", + "12001", + "1200", + "1250", + "12000", + "1255", + "CN", + "425", + "10010", + "500", + "10000", "L2", - "CP866", - "CP949", - "UHC", - "862", - "PT154", + "1254", + "10005", + "424", + "10004", + "10021", + "5601", + "U32", + "1025", + "CSUCS4", + "1252", + "10081", + "1361", + "50221", + "L4", + "50225", + "861", + "860", + "865", + "1258", + "CPIS", + "864", + "16804", + "L6", + "CP500", + "CP1051", + "10082", + "CP10010", + "CP1141", + "HZ", + "CP10000", + "CP1140", + "CP10005", "CP154", - "SJIS", - "CP1258", + "CYRILLIC", + "CSVISCII", + "862", + "CP1201", + "838", + "MSCYRL", "CP1251", - "PTCP154", - "UCS-4", + "CP10004", + "CP12001", + "CP1200", + "MACCYRILLIC", + "CP1250", + "CP12000", + "CP425", + "1256", + "CP01141", + "CP01140", + "CP850", + "CP424", + "CP01145", + "CP855", + "10006", + "CP1154", + "PT154", + "1046", + "CP1144", + "CP01144", + "CP280", + "CP1161", + "CP10021", + "L1", + "CP285", + "1026", + "CP1124", "L3", + "L10", + "CP1160", + "CP1254", + "1141", + "CP65001", + "1155", + "CP284", + "1140", + "CP65000", + "CP1112", + "CP880", + "1145", + "CP01142", + "CP852", + "X0201", + "CP50221", + "1154", + "CP1142", + "1144", + "1125", + "CP50225", + "CP861", + "CP282", + "CP1122", + "CP860", + "866", + "1124", + "CP1252", + "CP865", + "1112", + "CP1164", + "1142", + "CP864", + "CP01148", + "CP858", + "X0212", + "1161", + "UCS4", + "CP16804", + "1122", + "1160", + "1165", + "CP10006", "CP862", - "HZ", - "CP1256", + "CP1162", + "924", + "1164", + "646", + "1158", + "UCS2", + "1148", + "871", + "870", + "932", + "875", + "CP01146", + "CP856", "CP1131", - "CSUCS4", - "CP1254", + "X0208", + "922", + "1162", + "20866", + "CP866U", + "CP1130", + "874", + "LATIN1", + "LATIN10", + "U16", + "CPGR", + "CSPC850MULTILINGUAL", + "CP-GR", + "1156", + "1146", + "CSIBM01141", + "CSIBM01140", + "CSIBM01145", + "HP15CN", + "CSIBM1125", + "278", + "CP950", + "CP1155", + "CP866", + "CP1145", "CP1361", - "MAC", - "RK1048", - "UCS-2", - "CP936", - "ROMAN8", + "LATIN4", + "1131", + "1130", + "ASCII", + "CP1125", + "CSASCII", + "CP1025", + "USASCII", "CP1255", - "ISO8859-8", - "ISO8859-1", - "ISO-8859-8", - "ISO_8859-8", - "ISO-8859-1", - "ISO_8859-1", - "ISO8859-11", - "CP1252", - "EUCCN", - "ISO-8859-11", - "ISO_8859-11", - "EUC-CN", - "ISO646-CN", - "ISO8859-9", - "ISO8859-6", - "ISO-8859-9", - "ISO_8859-9", - "ISO-8859-6", - "ISO_8859-6", - "ISO8859-16", - "ISO_8859-16:2001", - "ISO-8859-16", - "ISO_8859-16", - "ISO8859-4", - "ISO_8859-14:1998", - "CP932", - "ISO-8859-4", - "ISO_8859-4", - "ISO8859-14", + "1253", + "936", + "CP1132", + "MSANSI", + "CSIBM01142", + "423", + "L5", + "ISOIR101", + "CSIBM1161", + "1166", + "ISOIR110", + "CP924", + "ISOIR100", + "LATIN2", + "154", + "CSISO2022CN", + "CSIBM424", + "ISOIR14", + "ISO2022CN", + "1132", + "UHC", + "ISOIR144", + "CP922", + "CP1165", + "CP838", + "PTCP154", + "CSIBM01148", "850", - "ISO_8859-15:1998", - "ISO-8859-14", - "ISO_8859-14", - "MS-CYRL", - "ISO8859-5", - "ISO646-US", - "ISO-8859-5", - "ISO_8859-5", - "ISO8859-15", - "ISO-IR-6", - "L10", - "ISO-8859-15", - "ISO_8859-15", - "ISO-IR-148", - "ISO-IR-58", - "ISO8859-2", - "ISO-8859-2", - "ISO_8859-2", - "CP50221", - "ISO-IR-199", - "ISO-IR-14", - "IBM819", - "ISO-IR-166", - "ISO-IR-149", - "CP850", + "CSIBM280", + "855", + "51950", + "CSIBM1162", + "CSIBM285", + "12712", + "CP00924", + "KSC5601", + "CSIBM284", + "MS874", + "863", + "65001", + "21866", + "65000", + "ISOIR165", + "ANSI1251", + "852", + "CSKZ1048", + "UCS4LE", + "280", + "CSIBM1026", + "285", + "RUSCII", + "KOI8U", + "ISOIR148", + "CP00858", + "VISCII", + "UCS2LE", + "U32LE", + "284", + "U8", + "L8", + "880", + "CP423", + "858", + "CYRILLICASIAN", + "CYRIILLICASIAN", + "CP01143", + "CP853", + "VISCII1.11", + "282", + "10029", + "CP871", + "JP", + "CP870", + "CP875", + "IBM01141", + "IBM500", + "ISOIR126", + "UTF8", + "IBM01140", + "1153", + "LATIN5", + "IBM01145", + "CP874", + "28605", + "1143", + "CSBIG5", + "CSIBM500", "MS936", - "IBM866", - "ISO-IR-159", - "CP950", - "CYRILLIC", - "ISO-IR-144", + "856", + "CP12712", + "IBM01144", + "869", + "1123", + "IBM1141", + "52936", + "CNBIG5", + "CP932", + "IBM1140", + "IBM1112", + "IBM1145", + "CP863", + "IBM850", + "ISOIR166", + "IBM01142", + "IBM1144", + "CP51950", + "UTF16", + "KOI8RU", + "R8", + "CP278", + "IBM1125", + "IBM1025", + "IBM280", + "ISOIR226", + "CSIBM00924", + "1163", + "IBM424", + "IBM1124", + "IBM1142", + "U7", "L7", - "ISO-IR-126", - "GEORGIAN-PS", + "EUCCN", + "950", + "273", + "775", + "IBM880", + "CP819", + "CP1156", + "54936", + "CP01149", + "IBM01148", + "ISOIR230", + "CP1146", + "CNGB", + "CP1046", "CSPTCP154", + "IBM1122", + "IBM861", + "UNICODE11", + "SYSTEM1125", + "IBM284", + "IBM860", + "CP1026", + "MACTHAI", + "CP1256", + "51932", + "ISOIR138", + "CP10029", + "IBM1148", + "CP936", + "IBM852", + "TCVN", + "1149", + "943", + "CP1153", + "BIG5", + "CP1143", + "IBM01146", + "1129", + "MACINTOSH", + "CSPCP852", + "IBM282", + "UTF32", + "MSEE", + "KOI8R", + "CP1123", + "IBM864", + "CP1166", + "CP869", "CP1253", - "ISO-IR-165", - "HP-ROMAN8", - "LATIN8", - "LATIN1", - "MACROMAN", - "CYRILLIC-ASIAN", - "GB2312", - "ASCII", - "ECMA-118", + "CSIBM01143", + "819", + "CP10081", + "ISOIR58", + "IBM1146", + "IBM1046", + "STRK10482002", + "U16LE", + "CSEUCKR", + "28591", + "CP943", "CSHPROMAN8", - "CP1250", - "UTF-8", - "ISO-IR-138", - "CP1133", - "LATIN6", - "LATIN-9", - "ISO-IR-226", + "28595", + "1133", "IBM862", - "CSASCII", - "CP874", - "ISO-IR-101", - "ISO_8859-10:1992", - "LATIN4", - "GB_1988-80", - "MS-ANSI", - "GEORGIAN-ACADEMY", - "UTF-16", - "ECMA-114", - "ISO-IR-109", - "MULELAO-1", - "LATIN5", - "ISO8859-3", - "ARMSCII-8", - "ISO-8859-3", - "ISO_8859-3", - "ISO8859-13", - "ISO-8859-13", - "ISO_8859-13", - "TCVN", - "ISO-10646-UCS-4", - "LATIN2", - "ISO-2022-CN", - "US-ASCII", - "ELOT_928", - "ISO8859-10", - "CSISO2022CN", - "UCS-4-SWAPPED", - "ISO-8859-10", - "ISO_8859-10", - "ISO-10646-UCS-2", - "KOI8-R", - "UNICODE-1-1", - "UCS-4LE", - "UCS-2-SWAPPED", - "ISO_8859-8:1988", - "CSKOI8R", - "CSUNICODE11", - "JP", - "MACROMANIA", - "UCS-2LE", - "ISO_8859-4:1988", - "ISO_8859-9:1989", - "ISO-IR-110", - "CSISOLATIN1", - "ISO_8859-5:1988", - "KZ-1048", + "IBM1026", + "CP1163", + "28594", + "CP4971", + "CP28591", + "CSIBM423", + "MSKANJI", + "CP1158", + "CSIBM1163", + "CP28595", + "CP10082", + "CP1148", + "RK1048", "TIS620", - "TIS-620", - "EUCKR", - "MACCYRILLIC", - "EUC-KR", - "CSISOLATIN6", - "CSKZ1048", + "ARMSCII8", + "TIS6200", + "CP21866", + "CP28594", + "28592", + "CP20866", + "CSGB2312", + "IBM1155", + "CP1258", + "437", + "1257", + "IBMEUCCN", + "CCSID01141", + "CP51932", + "UCS4BE", + "CCSID01140", + "949", + "IBM1154", + "CCSID01145", + "GEORGIANPS", + "10017", + "853", + "10007", + "CP28592", + "IBM1250", + "UCS2BE", + "1047", + "IBM1255", + "U32BE", + "CCSID01144", + "IBM425", + "ISO646US", + "28598", + "DOS862", + "IBM1254", + "CSIBM01149", + "ISOIR203", + "IBM855", + "ISOCELTIC", + "ISO646CN", + "ISO10646UCS4", + "ISO2022JP1", + "CSISO2022JP", + "ISO2022JPMS", + "CCSID01142", + "GB2312", + "LATIN6", + "L9", + "CSISO2022JP2", + "CP949", + "CP28598", + "ISO10646UCS2", + "IBM1252", + "IBM285", + "ISO2022JP", + "ISO88591", + "ISO885911", + "IBM924", + "MACROMAN", + "TIS620.25291", + "CNS11643", + "ISO885910", + "ISO88595", + "ISO885915", + "CP1133", + "CSIBM278", + "GB231280", + "IBM1158", + "28596", + "CSISO2022KR", + "ECMA114", + "ISO2022JP2004", + "ISO88594", + "ISO885914", + "ISOIR109", + "ISOIR159", + "CCSID01148", + "LATIN3", + "ISO2022JP2", + "ISOIR149", + "CP51949", + "CP273", + "CP775", + "CP10017", + "IBM1258", + "CP54936", + "IBM922", + "CP28596", + "IBM865", + "NEXTSTEP", + "CP10007", + "10079", + "CSIBM905", + "ISO88592", + "HZGB2312", + "CP52936", + "JIS0208", + "ISOIR6", + "MSHEBR", + "CSISO58GB231280", + "IBM1156", + "IBM1131", + "IBM01143", + "CCSID00858", + "28603", + "XMACCYRILLIC", + "IBM1130", + "51949", + "CCSID01146", + "CP01147", + "CP857", + "CP1149", + "CSIBM855", + "IBM1256", + "ECMA118", + "ISO2022CNEXT", + "ISO88598", + "CP1129", + "IBM1143", + "HPROMAN8", + "TDS565", + "CSISO159JISX02121990", + "LATIN8", + "1157", + "1147", + "IBM1132", + "IBM871", + "CSIBM880", + "IBM1123", + "PCK", + "GB18030", + "ISO2022KR", + "UNICODEBIG", + "CSIBMTHAI", + "IBM870", + "38598", + "KSC56011989", + "CSISOLATIN1", + "TACTIS", + "CSISOLATIN10", "CSISOLATINARABIC", + "CSISOLATIN5", "CSISOLATINCYRILLIC", - "BIG5", - "KOREAN", - "MACCROATIAN", - "BIG-5", + "ATARI", + "CSIBM861", + "IBM1161", + "CSISO14JISC6220RO", + "ISO88596", + "ISO885916", "CSISOLATIN4", - "IBM850", - "X0212", - "ARABIC", - "KSC_5601", - "LATIN3", - "CSISOLATIN5", - "UTF-32", - "VISCII", - "GB_2312-80", - "X0208", - "ISO_8859-3:1988", - "X0201", - "ISO-IR-179", - "GB18030", + "CSIBM860", + "IBM1160", + "4971", + "CSIBM865", + "IBM1165", + "367", + "CP38598", "CSISOLATIN2", - "KS_C_5601-1989", - "LATIN10", - "KOI8-U", - "KOI8-RU", - "CSEUCKR", - "ASMO-708", - "CSUNICODE", - "ISO-IR-100", - "ISO-2022-CN-EXT", - "UCS-4-INTERNAL", - "MACICELAND", - "CHINESE", - "IBM-CP1133", - "ISO-IR-203", - "MS-EE", - "TIS620-0", - "UCS-2-INTERNAL", - "VISCII1.1-1", - "ISO-CELTIC", - "WINDOWS-1258", - "WINDOWS-1251", - "CSBIG5", - "CN-BIG5", - "EUCJP", - "WINDOWS-1256", - "EUC-JP", - "ISO646-JP", - "WINDOWS-1254", - "CSPC850MULTILINGUAL", - "WINDOWS-1255", - "ISO_646.IRV:1991", - "CSVISCII", - "WINDOWS-1252", - "CSPC862LATINHEBREW", - "TIS620.2529-1", - "CSIBM866", - "CSISOLATIN3", + "UCS4INTERNAL", + "CSIBM864", + "IBM1164", + "JISX0201", + "CSIBM858", + "TIS620.25331", + "UTF16LE", + "TIS620.25330", + "UCS2INTERNAL", + "IBM905", + "KZ1048", "MACARABIC", + "U16BE", + "IBM01149", + "277", + "IBM1162", + "XMACCE", + "UNICODE11UTF7", + "MSTURK", + "MACTURKISH", + "CSISOLATIN6", + "IBM932", + "CSUNICODE11", + "JISX0212", + "SHIFTJIS", + "IBM1149", + "CP037", + "EUCJP", + "CCSID00924", + "CSKSC56011987", + "MACGREEK", + "MSGREEK", + "JISX0212.19900", + "CP437", + "IBM921CP28603", + "IBM1168", + "C99", + "BIG5HKSCS", + "IBM1129", + "ISO646.IRV:1991", + "KOI8T", + "BIG52003", + "CSMACINTOSH", + "28593", + "CP1157", + "SHIFTJIS2004", + "JISX0208", + "CP1147", + "CNGBISOIR165", + "CP1047", + "CSIBM1047", + "IBM856", + "IBMCP1133", + "CSIBM01147", + "CSGB18030", + "ISOIR199", "CP1257", - "WINDOWS-936", - "MACTHAI", - "JAVA", - "UTF-16LE", - "ISO-2022-KR", - "STRK1048-2002", - "GBK", - "CSGB2312", - "CSISO2022KR", - "GREEK8", + "CP28593", + "LATIN9", + "KSC56011987", + "MULELAO1", + "CSIBM866", + "IBM1166", "CP367", - "CN-GB-ISOIR165", - "MACINTOSH", - "WINDOWS-1253", - "UNICODE-1-1-UTF-7", - "ISO_8859-1:1987", - "WINDOWS-1250", - "JIS_C6226-1983", - "JIS_C6220-1969-RO", - "CSUNICODE11UTF7", - "ISO_8859-6:1987", - "CSISO14JISC6220RO", - "JIS0208", - "ISO8859-7", - "CSMACINTOSH", - "ISO-8859-7", - "ISO_8859-7", - "UCS-4BE", - "ISO_8859-2:1987", - "KOI8-T", - "EUCTW", - "UCS-2BE", - "EUC-TW", - "MS-HEBR", - "ANSI_X3.4-1968", - "TCVN5712-1", - "ISO-IR-87", - "CN-GB", - "ANSI_X3.4-1986", - "TIS620.2533-1", - "CSISOLATINHEBREW", - "UTF-32LE", - "KS_C_5601-1987", - "ISO_8859-7:2003", - "TCVN-5712", - "ISO-IR-57", - "HZ-GB-2312", - "ISO-2022-JP", - "ISO-IR-157", - "ISO-2022-JP-MS", - "ISO-2022-JP-1", - "CSKSC56011987", - "CSISO2022JP", - "ISO-IR-127", - "CSISOLATINGREEK", - "WINDOWS-874", + "IBM423", + "1137", + "ASMO708", + "CSIBM273", + "CSPC8CODEPAGE1144", + "IBM1153", + "CP297", + "DECHANZI", + "IBM853", "CSEUCTW", - "MACCENTRALEUROPE", - "CSISO159JISX02121990", - "CSISO58GB231280", - "ISO-2022-JP-2", - "MS-ARAB", - "LATIN7", - "CSISO2022JP2", - "WINDOWS-1257", - "NEXTSTEP", - "UTF-7", + "IBM00924", + "UTF32LE", + "CCSID01143", + "DECHANYU", + "737", + "ISOIR157", + "CSISOLATIN3", + "HEBREW", + "GEORGIANACADEMY", + "MACCROATIAN", + "IBM866", + "CSWINDOWS1251", + "CSWINDOWS1250", + "CSWINDOWS1255", + "CSISO885915CP28605", + "ISOIR127", + "CSWINDOWS1254", + "EUCKR", + "IBMTHAI", + "UNICODELITTLE", + "CP10079", + "CSWINDOWS1252", + "TIS620.2533", + "CSPC8CODEPAGE1146", + "857", + "ISO2022JP3", + "IBM12712", + "IBM875", + "28599", + "IBM863", + "ELOT928", + "ROMAN8", + "CSWINDOWS1258", + "ISO88593", + "ISO885913", + "IBMEUCJP", + "IBM16804", + "IBM858", + "CSWINDOWS874", + "UTF7", + "IBM00858", + "CP28599", + "CSKOI8U", + "CSWINDOWS1256", + "GBK", + "ISOIR179", + "CSSHIFTJIS", + "ISO646JP", + "ANSIX3.41968", "CSISO57GB1988", - "TIS620.2533-0", - "IBM367", - "GB18030:2022", - "BIG5HKSCS", - "BIG5-HKSCS", + "CCSID01149", + "KOREAN", + "CP1137", + "JISX02121990", + "CP0037", + "CSIBM037", + "CSUNICODE", + "CP277", + "CSIBM853", + "ANSIX3.41986", + "LATIN7", + "JAVA", + "TCVN57121", + "JISX02081990", + "CSIBM871", + "CSIBM870", + "XMACROMANIAN", + "EBCDICCPIS", + "EBCDICCPUS", + "IBM01147", + "TCVN5712", + "JISX02011976", + "EBCDICCPNL", + "EBCDICCPYU", + "UTF16BE", + "ISO88599", + "CP1097", + "ISO885910:1992", "MACUKRAINE", + "CSISOLATINGREEK", + "IBMEUCKR", + "IBM1147", + "CSKOI8RU", + "IBM1047", + "IBM943", + "CSIBM863", + "IBM1163", + "CSWINDOWS1253", + "ISO88595:1988", + "ISO885915:1998", + "CSISOLATINHEBREW", + "MACCENTRALEUROPE", + "ISO88594:1988", + "ISO885914:1998", + "ARABIC", + "ISO885916:2001", + "IBM4971", + "IBM819", + "297", + "ISOIR57", + "CSIBM297", + "ISO88598:1988", + "SHIFTJISX0213", + "IBM838", + "EBCDICCYRILLIC", + "UCS4SWAPPED", + "XMACICELANDIC", + "UCS2SWAPPED", + "JISC62261983", + "CSUNICODE11UTF7", + "CP737", + "MACICELAND", + "CSKOI8R", + "IBM869", "GB18030:2005", - "ISO_8859-7:1987", + "EUCJIS2004", + "JISC62201969RO", + "UTF32BE", + "CSIBM869", + "IBM1169", + "GB198880", + "BIGFIVE", + "GB18030:2022", + "JISX02081983", + "XMACTHAI", "GREEK", - "MS-TURK", - "UNICODEBIG", - "UTF-16BE", - "UNICODELITTLE", - "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", - "HEBREW", - "MACTURKISH", - "JIS_X0212", - "SHIFT-JIS", - "SHIFT_JIS", - "JIS_X0208", - "JIS_X0201", - "MS_KANJI", - "TCVN5712-1:1993", - "UTF-32BE", - "MS-GREEK", - "JISX0201-1976", - "MACGREEK", - "CSHALFWIDTHKATAKANA", - "WINBALTRIM", - "JIS_X0212-1990", - "BIG5-HKSCS:2008", - "BIG5-HKSCS:2001", - "BIG5-HKSCS:1999", - "BIG5-HKSCS:2004", - "JIS_X0208-1983", - "JIS_X0208-1990", - "CSSHIFTJIS", + "28597", + "CHINESE", + "MSARAB", + "IBM273", + "CSPC8CODEPAGE437", + "CP28597", + "EBCDICCPGR", + "ISO88593:1988", + "CSIBM277", + "BIG5HKSCS:2001", + "IBM1157", + "IBM775", + "EBCDICCPES", + "BIG5HKSCS:2004", + "CCSID01147", + "CSWINDOWS1257", + "IBM857", + "EBCDICCPCH", + "IBM1257", + "XMACUKRAINIAN", + "SDECKANJI", + "IBM278", + "BIG5HKSCS:2008", + "WINDOWS1251", + "WINDOWS1250", + "WINDOWS1255", + "MACROMANIA", + "WINDOWS1254", + "CSPC862LATINHEBREW", + "WINDOWS1252", + "ISO88597", "JOHAB", - "BIGFIVE", - "BIG-FIVE", - "JIS_X0212.1990-0", + "WINDOWS1258", + "EBCDICCPFI", + "WINDOWS1256", + "EUCTW", + "IBM1137", + "CSIBM857", + "ISO88591:1987", + "IBM037", + "CSPC775BALTIC", + "IBM437", + "XMACTURKISH", + "ISO88592:1987", "CSISO87JISX0208", + "CCSID853", + "ISOIR87", + "ISO88596:1987", + "IBM367", + "KOKR.JOHAP92", + "WINDOWS1253", + "GREEK8", + "EUCJISX0213", + "IBM297", + "EBCDICCPSE", + "BIG5HKSCS:1999", + "MACHEBREW", + "ISO88599:1989", + "DECKANJI", + "RISCOSLATIN1", + "WINDOWS950", + "IBMEUCTW", + "EBCDICCPTR", + "EBCDICCPFR", + "WINBALTRIM", + "EBCDICCPNO", + "IBM1097", + "EBCDICES284+EURO", + "XMACCROATIAN", + "ISO88597:2003", + "EBCDICCPHE", + "EBCDICCPIT", + "DECKOREAN", + "IBM277", + "EXTENDEDUNIXCODEPACKEDFORMATFORJAPANESE", + "EBCDICCPROECE", + "TCVN57121:1993", + "EBCDICCPGB", + "EBCDICIT280+EURO", + "EBCDICGB285+EURO", + "ATARIST", + "WINDOWS1257", + "XMACARABIC", "CSEUCPKDFMTJAPANESE", - "MACHEBREW" + "EBCDICIS871+EURO", + "WINDOWS874", + "EBCDICCPCA", + "ISO88597:1987", + "IBM737", + "EBCDICCPBE", + "EBCDICINTERNATIONAL500+EURO", + "WINDOWS936", + "XMACGREEK", + "EBCDICUS37+EURO", + "EBCDICSE278+EURO", + "EBCDICGREEK", + "EBCDICLATIN9EURO", + "EBCDICNO277+EURO", + "EBCDICFR297+EURO", + "EBCDICCPWT", + "EBCDICFI278+EURO", + "XMACHEBREW", + "CSHALFWIDTHKATAKANA", + "EBCDICCPDK", + "EBCDICDE273+EURO", + "EBCDICDK277+EURO" }; #define stringpool ((const char *) &stringpool_contents) static const struct alias aliases[] = { - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 227 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str7, ei_hp_roman8}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 288 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str16, ei_iso646_cn}, {-1}, {-1}, {-1}, {-1}, -#line 151 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str21, ei_iso8859_14}, -#line 60 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str22, ei_iso8859_1}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 207 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str28, ei_cp866}, -#line 134 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str29, ei_iso8859_10}, - {-1}, {-1}, -#line 51 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str32, ei_c99}, +#line 355 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str4, ei_mac_roman}, {-1}, +#line 21 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str6, ei_ascii}, #line 84 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str34, ei_iso8859_4}, + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str7, ei_sjis}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 126 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str40, ei_iso8859_9}, -#line 57 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str41, ei_iso8859_1}, +#line 38 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str22, ei_ucs2be}, + {-1}, {-1}, +#line 296 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str25, ei_cp1251}, +#line 47 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str26, ei_ucs4be}, + {-1}, +#line 42 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str28, ei_ucs2le}, + {-1}, {-1}, +#line 290 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str31, ei_cp1250}, +#line 51 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str32, ei_ucs4le}, {-1}, {-1}, {-1}, {-1}, -#line 21 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str46, ei_ascii}, -#line 68 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str47, ei_iso8859_2}, +#line 319 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str37, ei_cp1255}, +#line 475 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str38, ei_iso646_cn}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 646 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str45, ei_ebcdic425}, {-1}, {-1}, -#line 205 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str50, ei_cp866}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 355 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str60, ei_cp949}, +#line 374 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str48, ei_mac_romania}, +#line 652 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str49, ei_ebcdic500}, + {-1}, +#line 358 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str51, ei_mac_roman}, {-1}, {-1}, -#line 356 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str63, ei_cp949}, -#line 203 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str64, ei_cp862}, +#line 178 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str54, ei_iso8859_2}, +#line 313 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str55, ei_cp1254}, {-1}, -#line 234 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str66, ei_pt154}, +#line 394 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str57, ei_mac_hebrew}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 236 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str72, ei_pt154}, -#line 307 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str73, ei_sjis}, +#line 643 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str63, ei_ebcdic424}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 195 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str76, ei_cp1258}, +#line 398 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str75, ei_mac_arabic}, +#line 402 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str76, ei_mac_thai}, +#line 147 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str77, ei_euc_kr}, {-1}, -#line 174 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str78, ei_cp1251}, +#line 59 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str79, ei_utf32}, + {-1}, {-1}, {-1}, {-1}, +#line 691 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str84, ei_ebcdic1025}, + {-1}, {-1}, {-1}, {-1}, +#line 45 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str89, ei_ucs4}, + {-1}, {-1}, {-1}, +#line 302 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str93, ei_cp1252}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, +#line 390 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str106, ei_mac_turkish}, {-1}, -#line 235 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str80, ei_pt154}, - {-1}, {-1}, -#line 33 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str83, ei_ucs4}, -#line 76 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str84, ei_iso8859_3}, +#line 156 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str108, ei_johab}, + {-1}, {-1}, {-1}, {-1}, +#line 98 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str113, ei_iso2022_jpms}, + {-1}, {-1}, {-1}, {-1}, +#line 194 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str118, ei_iso8859_4}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 160 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str125, ei_iso2022_kr}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 558 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str131, ei_cp861}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 554 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str137, ei_cp860}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 571 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str143, ei_cp865}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 336 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str153, ei_cp1258}, {-1}, -#line 201 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str86, ei_cp862}, - {-1}, {-1}, -#line 334 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str89, ei_hz}, +#line 560 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str155, ei_cp861}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 569 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str161, ei_cp864}, + {-1}, {-1}, {-1}, {-1}, +#line 840 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str166, ei_ebcdic16804}, +#line 246 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str167, ei_iso8859_10}, + {-1}, {-1}, {-1}, +#line 651 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str171, ei_ebcdic500}, +#line 407 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str172, ei_hp_roman8}, + {-1}, +#line 370 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str174, ei_mac_croatian}, + {-1}, +#line 373 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str176, ei_mac_romania}, + {-1}, +#line 734 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str178, ei_ebcdic1141}, {-1}, {-1}, -#line 189 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str92, ei_cp1256}, +#line 121 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str181, ei_hz}, + {-1}, {-1}, {-1}, +#line 357 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str185, ei_mac_roman}, {-1}, {-1}, {-1}, {-1}, -#line 209 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str97, ei_cp1131}, +#line 726 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str190, ei_ebcdic1140}, +#line 393 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str191, ei_mac_hebrew}, +#line 419 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str192, ei_pt154}, {-1}, {-1}, -#line 35 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str100, ei_ucs4}, +#line 201 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str195, ei_iso8859_5}, {-1}, -#line 183 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str102, ei_cp1254}, +#line 444 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str197, ei_viscii}, {-1}, -#line 358 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str104, ei_johab}, -#line 212 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str105, ei_mac_roman}, +#line 342 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str199, ei_cp862}, +#line 37 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str200, ei_ucs2be}, +#line 657 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str201, ei_ebcdic838}, +#line 293 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str202, ei_cp1251}, +#line 295 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str203, ei_cp1251}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 397 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str209, ei_mac_arabic}, +#line 48 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str210, ei_ucs4be}, {-1}, -#line 239 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str107, ei_rk1048}, +#line 41 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str212, ei_ucs2le}, {-1}, -#line 24 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str109, ei_ucs2}, - {-1}, {-1}, +#line 375 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str214, ei_mac_cyrillic}, +#line 285 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str215, ei_cp1250}, +#line 50 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str216, ei_ucs4le}, +#line 645 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str217, ei_ebcdic425}, + {-1}, {-1}, {-1}, #line 325 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str112, ei_cp936}, -#line 226 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str113, ei_hp_roman8}, -#line 186 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str114, ei_cp1255}, + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str221, ei_cp1256}, + {-1}, {-1}, {-1}, +#line 731 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str225, ei_ebcdic1141}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 120 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str120, ei_iso8859_8}, - {-1}, -#line 62 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str122, ei_iso8859_1}, -#line 114 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str123, ei_iso8859_8}, -#line 115 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str124, ei_iso8859_8}, -#line 53 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str125, ei_iso8859_1}, -#line 54 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str126, ei_iso8859_1}, -#line 139 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str127, ei_iso8859_11}, -#line 177 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str128, ei_cp1252}, -#line 319 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str129, ei_euc_cn}, -#line 137 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str130, ei_iso8859_11}, -#line 138 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str131, ei_iso8859_11}, -#line 318 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str132, ei_euc_cn}, -#line 286 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str133, ei_iso646_cn}, -#line 128 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str134, ei_iso8859_9}, +#line 723 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str231, ei_ebcdic1140}, +#line 340 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str232, ei_cp850}, + {-1}, {-1}, +#line 642 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str235, ei_ebcdic424}, {-1}, -#line 102 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str136, ei_iso8859_6}, -#line 121 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str137, ei_iso8859_9}, -#line 122 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str138, ei_iso8859_9}, -#line 94 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str139, ei_iso8859_6}, -#line 95 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str140, ei_iso8859_6}, -#line 166 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str141, ei_iso8859_16}, +#line 765 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str237, ei_ebcdic1145}, +#line 541 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str238, ei_cp855}, + {-1}, {-1}, +#line 386 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str241, ei_mac_greek}, +#line 806 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str242, ei_ebcdic1154}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 413 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str248, ei_pt154}, +#line 499 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str249, ei_cp1046}, {-1}, -#line 162 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str143, ei_iso8859_16}, -#line 160 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str144, ei_iso8859_16}, -#line 161 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str145, ei_iso8859_16}, -#line 86 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str146, ei_iso8859_4}, -#line 148 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str147, ei_iso8859_14}, -#line 310 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str148, ei_cp932}, -#line 79 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str149, ei_iso8859_4}, -#line 80 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str150, ei_iso8859_4}, -#line 153 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str151, ei_iso8859_14}, -#line 199 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str152, ei_cp850}, -#line 156 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str153, ei_iso8859_15}, -#line 146 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str154, ei_iso8859_14}, -#line 147 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str155, ei_iso8859_14}, -#line 176 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str156, ei_cp1251}, +#line 760 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str251, ei_ebcdic1144}, + {-1}, {-1}, {-1}, +#line 757 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str255, ei_ebcdic1144}, + {-1}, {-1}, {-1}, {-1}, +#line 614 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str260, ei_ebcdic280}, +#line 508 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str261, ei_cp1161}, +#line 401 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str262, ei_mac_thai}, + {-1}, {-1}, +#line 168 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str265, ei_iso8859_1}, +#line 625 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str266, ei_ebcdic285}, {-1}, -#line 93 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str158, ei_iso8859_5}, +#line 695 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str268, ei_ebcdic1026}, {-1}, -#line 14 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str160, ei_ascii}, -#line 87 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str161, ei_iso8859_5}, -#line 88 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str162, ei_iso8859_5}, -#line 159 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str163, ei_iso8859_15}, -#line 16 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str164, ei_ascii}, -#line 165 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str165, ei_iso8859_16}, -#line 154 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str166, ei_iso8859_15}, -#line 155 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str167, ei_iso8859_15}, - {-1}, {-1}, -#line 124 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str170, ei_iso8859_9}, -#line 291 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str171, ei_gb2312}, -#line 70 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str172, ei_iso8859_2}, +#line 501 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str270, ei_cp1124}, +#line 186 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str271, ei_iso8859_3}, +#line 272 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str272, ei_iso8859_16}, +#line 821 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str273, ei_ebcdic1160}, {-1}, {-1}, -#line 63 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str175, ei_iso8859_2}, -#line 64 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str176, ei_iso8859_2}, -#line 317 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str177, ei_iso2022_jpms}, -#line 149 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str178, ei_iso8859_14}, -#line 264 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str179, ei_iso646_jp}, -#line 58 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str180, ei_iso8859_1}, -#line 252 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str181, ei_tis620}, +#line 312 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str276, ei_cp1254}, {-1}, {-1}, -#line 298 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str184, ei_ksc5601}, -#line 197 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str185, ei_cp850}, - {-1}, -#line 326 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str187, ei_cp936}, +#line 735 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str279, ei_ebcdic1141}, +#line 28 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str280, ei_utf8}, {-1}, -#line 206 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str189, ei_cp866}, -#line 283 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str190, ei_jisx0212}, +#line 810 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str282, ei_ebcdic1155}, {-1}, -#line 345 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str192, ei_cp950}, +#line 622 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str284, ei_ebcdic284}, +#line 727 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str285, ei_ebcdic1140}, +#line 68 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str286, ei_utf7}, {-1}, {-1}, -#line 91 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str195, ei_iso8859_5}, -#line 90 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str196, ei_iso8859_5}, -#line 144 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str197, ei_iso8859_13}, +#line 703 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str289, ei_ebcdic1112}, +#line 676 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str290, ei_ebcdic880}, +#line 769 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str291, ei_ebcdic1145}, {-1}, -#line 107 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str199, ei_iso8859_7}, -#line 232 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str200, ei_georgian_ps}, -#line 238 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str201, ei_pt154}, -#line 180 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str202, ei_cp1253}, -#line 293 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str203, ei_isoir165}, -#line 225 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str204, ei_hp_roman8}, +#line 739 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str293, ei_ebcdic1142}, +#line 532 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str294, ei_cp852}, {-1}, -#line 150 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str206, ei_iso8859_14}, +#line 456 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str296, ei_jisx0201}, + {-1}, {-1}, +#line 97 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str299, ei_iso2022_jpms}, +#line 807 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str300, ei_ebcdic1154}, + {-1}, {-1}, {-1}, +#line 743 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str304, ei_ebcdic1142}, + {-1}, {-1}, {-1}, {-1}, +#line 761 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str309, ei_ebcdic1144}, +#line 581 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str310, ei_cp1125}, +#line 159 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str311, ei_iso2022_kr}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 559 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str318, ei_cp861}, + {-1}, {-1}, {-1}, +#line 618 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str322, ei_ebcdic282}, +#line 706 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str323, ei_ebcdic1122}, +#line 556 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str324, ei_cp860}, + {-1}, {-1}, +#line 347 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str327, ei_cp866}, +#line 502 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str328, ei_cp1124}, +#line 301 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str329, ei_cp1252}, +#line 573 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str330, ei_cp865}, {-1}, -#line 59 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str208, ei_iso8859_1}, -#line 210 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str209, ei_mac_roman}, +#line 704 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str332, ei_ebcdic1112}, {-1}, -#line 237 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str211, ei_pt154}, -#line 320 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str212, ei_euc_cn}, -#line 13 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str213, ei_ascii}, -#line 108 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str214, ei_iso8859_7}, -#line 228 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str215, ei_hp_roman8}, -#line 171 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str216, ei_cp1250}, +#line 824 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str334, ei_ebcdic1164}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, +#line 744 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str347, ei_ebcdic1142}, +#line 568 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str348, ei_cp864}, + {-1}, {-1}, {-1}, {-1}, +#line 789 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str353, ei_ebcdic1148}, +#line 549 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str354, ei_cp858}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 469 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str361, ei_jisx0212}, +#line 509 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str362, ei_cp1161}, {-1}, -#line 23 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str218, ei_utf8}, +#line 43 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str364, ei_ucs4}, +#line 839 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str365, ei_ebcdic16804}, +#line 707 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str366, ei_ebcdic1122}, {-1}, -#line 117 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str220, ei_iso8859_8}, -#line 244 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str221, ei_cp1133}, -#line 133 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str222, ei_iso8859_10}, -#line 158 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str223, ei_iso8859_15}, -#line 163 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str224, ei_iso8859_16}, -#line 202 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str225, ei_cp862}, -#line 22 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str226, ei_ascii}, +#line 822 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str368, ei_ebcdic1160}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 828 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str374, ei_ebcdic1165}, +#line 385 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str375, ei_mac_greek}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 253 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str228, ei_cp874}, -#line 66 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str229, ei_iso8859_2}, -#line 131 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str230, ei_iso8859_10}, +#line 345 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str386, ei_cp862}, +#line 512 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str387, ei_cp1162}, {-1}, -#line 83 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str232, ei_iso8859_4}, -#line 285 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str233, ei_iso646_cn}, +#line 688 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str389, ei_ebcdic924}, {-1}, {-1}, -#line 179 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str236, ei_cp1252}, -#line 231 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str237, ei_georgian_academy}, - {-1}, -#line 38 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str239, ei_utf16}, -#line 98 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str240, ei_iso8859_6}, -#line 74 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str241, ei_iso8859_3}, +#line 825 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str392, ei_ebcdic1164}, + {-1}, {-1}, +#line 25 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str395, ei_ascii}, + {-1}, {-1}, +#line 819 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str398, ei_ebcdic1158}, + {-1}, {-1}, {-1}, +#line 30 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str402, ei_ucs2}, + {-1}, {-1}, {-1}, {-1}, +#line 793 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str407, ei_ebcdic1148}, +#line 668 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str408, ei_ebcdic871}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 663 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str414, ei_ebcdic870}, + {-1}, {-1}, {-1}, +#line 90 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str418, ei_cp932}, {-1}, -#line 243 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str243, ei_mulelao}, -#line 125 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str244, ei_iso8859_9}, +#line 672 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str420, ei_ebcdic875}, +#line 773 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str421, ei_ebcdic1146}, +#line 489 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str422, ei_cp856}, +#line 351 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str423, ei_cp1131}, +#line 462 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str424, ei_jisx0208}, + {-1}, {-1}, +#line 493 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str427, ei_cp922}, + {-1}, {-1}, +#line 513 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str430, ei_cp1162}, +#line 277 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str431, ei_koi8_r}, {-1}, -#line 78 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str246, ei_iso8859_3}, +#line 585 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str433, ei_cp1125}, {-1}, -#line 230 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str248, ei_armscii_8}, -#line 71 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str249, ei_iso8859_3}, -#line 72 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str250, ei_iso8859_3}, -#line 145 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str251, ei_iso8859_13}, +#line 712 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str435, ei_ebcdic1130}, {-1}, {-1}, -#line 140 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str254, ei_iso8859_13}, -#line 141 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str255, ei_iso8859_13}, -#line 258 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str256, ei_tcvn}, -#line 34 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str257, ei_ucs4}, -#line 67 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str258, ei_iso8859_2}, -#line 331 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str259, ei_iso2022_cn}, +#line 441 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str438, ei_cp874}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 12 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str262, ei_ascii}, +#line 167 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str450, ei_iso8859_1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 271 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str457, ei_iso8859_16}, + {-1}, {-1}, {-1}, +#line 53 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str461, ei_utf16}, +#line 576 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str462, ei_cp869}, +#line 339 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str463, ei_cp850}, +#line 579 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str464, ei_cp869}, {-1}, -#line 109 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str264, ei_iso8859_7}, -#line 136 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str265, ei_iso8859_10}, -#line 332 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str266, ei_iso2022_cn}, -#line 50 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str267, ei_ucs4swapped}, -#line 129 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str268, ei_iso8859_10}, -#line 130 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str269, ei_iso8859_10}, -#line 25 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str270, ei_ucs2}, - {-1}, {-1}, -#line 167 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str273, ei_koi8_r}, -#line 29 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str274, ei_ucs2be}, - {-1}, {-1}, -#line 37 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str277, ei_ucs4le}, +#line 813 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str466, ei_ebcdic1156}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 777 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str475, ei_ebcdic1146}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 733 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str484, ei_ebcdic1141}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 725 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str490, ei_ebcdic1140}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 767 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str496, ei_ebcdic1145}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 105 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str502, ei_euc_cn}, {-1}, {-1}, -#line 48 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str280, ei_ucs2swapped}, -#line 116 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str281, ei_iso8859_8}, - {-1}, -#line 168 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str283, ei_koi8_r}, -#line 30 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str284, ei_ucs2be}, - {-1}, -#line 265 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str286, ei_iso646_jp}, +#line 583 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str505, ei_cp1125}, +#line 610 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str506, ei_ebcdic278}, {-1}, {-1}, -#line 217 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str289, ei_mac_romania}, -#line 31 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str290, ei_ucs2le}, +#line 136 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str509, ei_cp950}, +#line 809 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str510, ei_ebcdic1155}, {-1}, {-1}, {-1}, -#line 81 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str294, ei_iso8859_4}, -#line 123 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str295, ei_iso8859_9}, - {-1}, {-1}, -#line 82 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str298, ei_iso8859_4}, -#line 61 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str299, ei_iso8859_1}, -#line 89 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str300, ei_iso8859_5}, - {-1}, {-1}, -#line 241 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str303, ei_rk1048}, -#line 247 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str304, ei_tis620}, - {-1}, {-1}, -#line 246 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str307, ei_tis620}, +#line 349 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str514, ei_cp866}, + {-1}, {-1}, {-1}, {-1}, +#line 768 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str519, ei_ebcdic1145}, {-1}, -#line 353 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str309, ei_euc_kr}, +#line 155 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str521, ei_johab}, {-1}, -#line 218 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str311, ei_mac_cyrillic}, +#line 193 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str523, ei_iso8859_4}, #line 352 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str312, ei_euc_kr}, -#line 135 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str313, ei_iso8859_10}, -#line 242 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str314, ei_rk1048}, -#line 101 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str315, ei_iso8859_6}, -#line 92 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str316, ei_iso8859_5}, + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str524, ei_cp1131}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 713 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str530, ei_ebcdic1130}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 14 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str537, ei_ascii}, +#line 586 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str538, ei_cp1125}, {-1}, -#line 339 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str318, ei_ces_big5}, -#line 300 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str319, ei_ksc5601}, -#line 216 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str320, ei_mac_croatian}, -#line 340 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str321, ei_ces_big5}, +#line 22 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str540, ei_ascii}, +#line 690 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str541, ei_ebcdic1025}, +#line 13 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str542, ei_ascii}, {-1}, -#line 85 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str323, ei_iso8859_4}, -#line 198 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str324, ei_cp850}, +#line 318 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str544, ei_cp1255}, +#line 307 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str545, ei_cp1253}, +#line 111 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str546, ei_cp936}, + {-1}, {-1}, +#line 715 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str549, ei_ebcdic1132}, {-1}, -#line 282 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str326, ei_jisx0212}, +#line 300 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str551, ei_cp1252}, +#line 742 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str552, ei_ebcdic1142}, +#line 638 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str553, ei_ebcdic423}, {-1}, -#line 100 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str328, ei_iso8859_6}, -#line 295 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str329, ei_ksc5601}, - {-1}, {-1}, -#line 75 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str332, ei_iso8859_3}, - {-1}, {-1}, -#line 127 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str335, ei_iso8859_9}, +#line 238 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str555, ei_iso8859_9}, +#line 176 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str556, ei_iso8859_2}, +#line 507 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str557, ei_cp1161}, +#line 831 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str558, ei_ebcdic1166}, +#line 192 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str559, ei_iso8859_4}, {-1}, -#line 41 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str337, ei_utf32}, -#line 255 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str338, ei_viscii}, - {-1}, {-1}, -#line 290 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str341, ei_gb2312}, +#line 687 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str561, ei_ebcdic924}, +#line 165 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str562, ei_iso8859_1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, +#line 177 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str576, ei_iso8859_2}, +#line 420 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str577, ei_pt154}, {-1}, -#line 275 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str343, ei_jisx0208}, -#line 73 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str344, ei_iso8859_3}, -#line 269 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str345, ei_jisx0201}, +#line 119 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str579, ei_iso2022_cn}, +#line 641 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str580, ei_ebcdic424}, {-1}, -#line 142 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str347, ei_iso8859_13}, -#line 328 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str348, ei_gb18030_2005}, -#line 69 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str349, ei_iso8859_2}, -#line 297 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str350, ei_ksc5601}, -#line 164 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str351, ei_iso8859_16}, +#line 451 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str582, ei_iso646_jp}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 118 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str588, ei_iso2022_cn}, + {-1}, {-1}, {-1}, +#line 716 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str592, ei_ebcdic1132}, {-1}, -#line 169 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str353, ei_koi8_u}, +#line 150 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str594, ei_cp949}, + {-1}, {-1}, {-1}, +#line 200 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str598, ei_iso8859_5}, +#line 492 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str599, ei_cp922}, {-1}, {-1}, -#line 170 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str356, ei_koi8_ru}, +#line 827 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str602, ei_ebcdic1165}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 354 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str362, ei_euc_kr}, +#line 656 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str608, ei_ebcdic838}, {-1}, -#line 99 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str364, ei_iso8859_6}, +#line 414 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str610, ei_pt154}, {-1}, -#line 26 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str366, ei_ucs2}, -#line 56 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str367, ei_iso8859_1}, -#line 333 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str368, ei_iso2022_cn_ext}, +#line 791 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str612, ei_ebcdic1148}, + {-1}, {-1}, {-1}, {-1}, +#line 338 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str617, ei_cp850}, + {-1}, {-1}, +#line 613 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str620, ei_ebcdic280}, + {-1}, {-1}, +#line 539 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str623, ei_cp855}, +#line 130 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str624, ei_euc_tw}, +#line 511 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str625, ei_cp1162}, +#line 627 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str626, ei_ebcdic285}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 837 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str632, ei_ebcdic12712}, +#line 684 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str633, ei_ebcdic924}, + {-1}, {-1}, {-1}, {-1}, +#line 482 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str638, ei_ksc5601}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 621 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str644, ei_ebcdic284}, {-1}, -#line 49 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str370, ei_ucs4internal}, +#line 439 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str646, ei_cp874}, + {-1}, {-1}, {-1}, {-1}, +#line 563 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str651, ei_cp863}, {-1}, -#line 215 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str372, ei_mac_iceland}, +#line 29 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str653, ei_utf8}, + {-1}, {-1}, {-1}, +#line 284 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str657, ei_koi8_ru}, {-1}, -#line 323 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str374, ei_euc_cn}, +#line 69 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str659, ei_utf7}, + {-1}, {-1}, {-1}, +#line 480 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str663, ei_isoir165}, + {-1}, {-1}, {-1}, +#line 294 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str667, ei_cp1251}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 245 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str377, ei_cp1133}, -#line 157 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str378, ei_iso8859_15}, -#line 173 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str379, ei_cp1250}, +#line 530 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str679, ei_cp852}, +#line 424 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str680, ei_rk1048}, {-1}, -#line 248 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str381, ei_tis620}, +#line 49 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str682, ei_ucs4le}, + {-1}, {-1}, {-1}, {-1}, +#line 615 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str687, ei_ebcdic280}, + {-1}, {-1}, {-1}, {-1}, +#line 693 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str692, ei_ebcdic1026}, +#line 628 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str693, ei_ebcdic285}, +#line 584 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str694, ei_cp1125}, +#line 278 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str695, ei_koi8_u}, +#line 236 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str696, ei_iso8859_9}, +#line 551 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str697, ei_cp858}, {-1}, -#line 47 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str383, ei_ucs2internal}, +#line 442 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str699, ei_viscii}, {-1}, -#line 256 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str385, ei_viscii}, +#line 39 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str701, ei_ucs2le}, + {-1}, {-1}, {-1}, {-1}, +#line 63 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str706, ei_utf32le}, + {-1}, {-1}, {-1}, {-1}, +#line 623 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str711, ei_ebcdic284}, +#line 27 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str712, ei_utf8}, +#line 259 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str713, ei_iso8859_14}, {-1}, {-1}, {-1}, -#line 152 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str389, ei_iso8859_14}, -#line 196 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str390, ei_cp1258}, -#line 175 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str391, ei_cp1251}, -#line 344 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str392, ei_ces_big5}, +#line 677 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str717, ei_ebcdic880}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 637 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str725, ei_ebcdic423}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, +#line 547 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str739, ei_cp858}, + {-1}, +#line 415 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str741, ei_pt154}, +#line 418 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str742, ei_pt154}, {-1}, {-1}, -#line 343 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str395, ei_ces_big5}, +#line 748 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str745, ei_ebcdic1143}, +#line 537 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str746, ei_cp853}, +#line 443 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str747, ei_viscii}, {-1}, -#line 302 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str397, ei_euc_jp}, -#line 190 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str398, ei_cp1256}, +#line 617 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str749, ei_ebcdic282}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 362 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str758, ei_mac_centraleurope}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 667 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str764, ei_ebcdic871}, + {-1}, {-1}, +#line 452 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str767, ei_iso646_jp}, + {-1}, {-1}, +#line 659 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str770, ei_ebcdic870}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 671 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str776, ei_ebcdic875}, + {-1}, {-1}, {-1}, {-1}, +#line 729 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str781, ei_ebcdic1141}, +#line 647 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str782, ei_ebcdic500}, +#line 217 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str783, ei_iso8859_7}, {-1}, -#line 301 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str400, ei_euc_jp}, -#line 263 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str401, ei_iso646_jp}, +#line 26 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str785, ei_utf8}, {-1}, -#line 184 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str403, ei_cp1254}, +#line 721 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str787, ei_ebcdic1140}, {-1}, {-1}, -#line 200 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str406, ei_cp850}, - {-1}, {-1}, -#line 187 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str409, ei_cp1255}, -#line 15 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str410, ei_ascii}, +#line 804 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str790, ei_ebcdic1153}, +#line 237 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str791, ei_iso8859_9}, {-1}, -#line 257 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str412, ei_viscii}, - {-1}, {-1}, {-1}, -#line 178 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str416, ei_cp1252}, +#line 763 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str793, ei_ebcdic1145}, +#line 440 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str794, ei_cp874}, {-1}, -#line 204 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str418, ei_cp862}, -#line 249 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str419, ei_tis620}, +#line 267 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str796, ei_iso8859_15}, + {-1}, {-1}, +#line 753 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str799, ei_ebcdic1143}, {-1}, -#line 208 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str421, ei_cp866}, +#line 134 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str801, ei_ces_big5}, +#line 650 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str802, ei_ebcdic500}, + {-1}, {-1}, +#line 108 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str805, ei_cp936}, {-1}, -#line 77 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str423, ei_iso8859_3}, +#line 490 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str807, ei_cp856}, {-1}, {-1}, -#line 223 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str426, ei_mac_arabic}, +#line 836 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str810, ei_ebcdic12712}, +#line 755 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str811, ei_ebcdic1144}, {-1}, -#line 192 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str428, ei_cp1257}, -#line 327 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str429, ei_cp936}, -#line 224 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str430, ei_mac_thai}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 52 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str437, ei_java}, -#line 40 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str438, ei_utf16le}, -#line 359 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str439, ei_iso2022_kr}, +#line 575 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str813, ei_cp869}, + {-1}, {-1}, {-1}, {-1}, +#line 710 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str818, ei_ebcdic1123}, {-1}, -#line 240 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str441, ei_rk1048}, -#line 324 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str442, ei_ces_gbk}, +#line 728 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str820, ei_ebcdic1141}, + {-1}, {-1}, +#line 124 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str823, ei_hz}, +#line 133 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str824, ei_ces_big5}, +#line 89 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str825, ei_cp932}, +#line 720 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str826, ei_ebcdic1140}, + {-1}, {-1}, {-1}, +#line 702 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str830, ei_ebcdic1112}, {-1}, -#line 322 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str444, ei_euc_cn}, +#line 762 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str832, ei_ebcdic1145}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 565 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str838, ei_cp863}, + {-1}, {-1}, {-1}, {-1}, +#line 337 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str843, ei_cp850}, + {-1}, {-1}, {-1}, +#line 434 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str847, ei_tis620}, {-1}, -#line 360 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str446, ei_iso2022_kr}, +#line 737 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str849, ei_ebcdic1142}, +#line 754 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str850, ei_ebcdic1144}, {-1}, -#line 110 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str448, ei_iso8859_7}, -#line 19 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str449, ei_ascii}, +#line 129 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str852, ei_euc_tw}, {-1}, -#line 294 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str451, ei_isoir165}, -#line 211 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str452, ei_mac_roman}, -#line 181 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str453, ei_cp1253}, +#line 52 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str854, ei_utf16}, + {-1}, {-1}, {-1}, {-1}, +#line 280 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str859, ei_koi8_ru}, {-1}, -#line 45 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str455, ei_utf7}, +#line 405 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str861, ei_hp_roman8}, +#line 609 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str862, ei_ebcdic278}, + {-1}, {-1}, {-1}, +#line 580 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str866, ei_cp1125}, {-1}, {-1}, -#line 55 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str458, ei_iso8859_1}, +#line 689 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str869, ei_ebcdic1025}, {-1}, -#line 172 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str460, ei_cp1250}, -#line 277 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str461, ei_jisx0208}, -#line 262 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str462, ei_iso646_jp}, -#line 46 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str463, ei_utf7}, +#line 611 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str871, ei_ebcdic280}, + {-1}, {-1}, {-1}, +#line 270 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str875, ei_iso8859_16}, {-1}, -#line 96 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str465, ei_iso8859_6}, +#line 686 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str877, ei_ebcdic924}, {-1}, {-1}, {-1}, {-1}, -#line 266 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str470, ei_iso646_jp}, -#line 274 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str471, ei_jisx0208}, -#line 113 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str472, ei_iso8859_7}, -#line 213 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str473, ei_mac_roman}, +#line 517 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str882, ei_cp1163}, +#line 639 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str883, ei_ebcdic424}, +#line 500 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str884, ei_cp1124}, + {-1}, {-1}, {-1}, +#line 736 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str888, ei_ebcdic1142}, +#line 67 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str889, ei_utf7}, +#line 252 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str890, ei_iso8859_13}, +#line 99 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str891, ei_euc_cn}, + {-1}, {-1}, +#line 137 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str894, ei_cp950}, + {-1}, {-1}, {-1}, +#line 598 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str898, ei_ebcdic273}, {-1}, -#line 103 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str475, ei_iso8859_7}, -#line 104 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str476, ei_iso8859_7}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 36 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str482, ei_ucs4be}, -#line 65 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str483, ei_iso8859_2}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 233 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str489, ei_koi8_t}, - {-1}, {-1}, {-1}, {-1}, -#line 337 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str494, ei_euc_tw}, -#line 27 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str495, ei_ucs2be}, +#line 528 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str900, ei_cp775}, +#line 673 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str901, ei_ebcdic880}, +#line 170 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str902, ei_iso8859_1}, + {-1}, {-1}, +#line 812 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str905, ei_ebcdic1156}, +#line 117 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str906, ei_gb18030_2022}, +#line 797 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str907, ei_ebcdic1149}, {-1}, -#line 336 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str497, ei_euc_tw}, -#line 188 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str498, ei_cp1255}, +#line 787 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str909, ei_ebcdic1148}, {-1}, -#line 17 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str500, ei_ascii}, -#line 260 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str501, ei_tcvn}, +#line 849 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str911, ei_tds565}, {-1}, {-1}, -#line 276 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str504, ei_jisx0208}, +#line 776 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str914, ei_ebcdic1146}, + {-1}, +#line 101 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str916, ei_euc_cn}, +#line 498 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str917, ei_cp1046}, {-1}, {-1}, -#line 321 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str507, ei_euc_cn}, -#line 18 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str508, ei_ascii}, +#line 416 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str920, ei_pt154}, + {-1}, +#line 705 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str922, ei_ebcdic1122}, +#line 557 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str923, ei_cp861}, {-1}, {-1}, {-1}, +#line 35 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str927, ei_ucs2be}, +#line 582 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str928, ei_cp1125}, + {-1}, {-1}, {-1}, +#line 619 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str932, ei_ebcdic284}, + {-1}, {-1}, +#line 553 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str935, ei_cp860}, +#line 694 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str936, ei_ebcdic1026}, +#line 399 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str937, ei_mac_thai}, + {-1}, +#line 324 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str939, ei_cp1256}, +#line 82 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str940, ei_euc_jp}, +#line 227 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str941, ei_iso8859_8}, + {-1}, {-1}, +#line 361 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str944, ei_mac_centraleurope}, + {-1}, {-1}, {-1}, +#line 786 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str948, ei_ebcdic1148}, + {-1}, {-1}, {-1}, {-1}, +#line 110 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str953, ei_cp936}, + {-1}, {-1}, {-1}, +#line 529 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str957, ei_cp852}, + {-1}, {-1}, +#line 445 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str960, ei_tcvn}, +#line 801 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str961, ei_ebcdic1149}, +#line 496 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str962, ei_cp943}, + {-1}, {-1}, {-1}, {-1}, +#line 803 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str967, ei_ebcdic1153}, + {-1}, {-1}, {-1}, {-1}, +#line 131 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str972, ei_ces_big5}, + {-1}, {-1}, {-1}, +#line 752 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str976, ei_ebcdic1143}, +#line 771 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str977, ei_ebcdic1146}, + {-1}, {-1}, +#line 505 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str980, ei_cp1129}, +#line 354 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str981, ei_mac_roman}, + {-1}, +#line 531 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str983, ei_cp852}, + {-1}, +#line 616 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str985, ei_ebcdic282}, +#line 58 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str986, ei_utf32}, + {-1}, {-1}, {-1}, {-1}, +#line 289 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str991, ei_cp1250}, + {-1}, +#line 274 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str993, ei_koi8_r}, + {-1}, +#line 709 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str995, ei_ebcdic1123}, +#line 566 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str996, ei_cp864}, +#line 830 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str997, ei_ebcdic1166}, + {-1}, {-1}, +#line 578 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1000, ei_cp869}, +#line 306 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1001, ei_cp1253}, + {-1}, {-1}, +#line 751 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1004, ei_ebcdic1143}, + {-1}, {-1}, {-1}, {-1}, +#line 171 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1009, ei_iso8859_1}, + {-1}, {-1}, {-1}, +#line 389 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1013, ei_mac_turkish}, + {-1}, +#line 478 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1015, ei_gb2312}, +#line 770 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1016, ei_ebcdic1146}, + {-1}, {-1}, +#line 497 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1019, ei_cp1046}, +#line 422 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1020, ei_rk1048}, + {-1}, {-1}, {-1}, +#line 57 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1024, ei_utf16le}, + {-1}, {-1}, +#line 144 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1027, ei_euc_kr}, + {-1}, {-1}, +#line 173 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1030, ei_iso8859_1}, + {-1}, +#line 495 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1032, ei_cp943}, + {-1}, {-1}, +#line 406 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1035, ei_hp_roman8}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 204 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1042, ei_iso8859_5}, + {-1}, +#line 428 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1044, ei_cp1133}, + {-1}, {-1}, {-1}, {-1}, +#line 341 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1049, ei_cp862}, + {-1}, {-1}, {-1}, +#line 692 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1053, ei_ebcdic1026}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 516 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1059, ei_cp1163}, +#line 197 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1060, ei_iso8859_4}, + {-1}, {-1}, +#line 833 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1063, ei_ebcdic4971}, + {-1}, {-1}, {-1}, +#line 172 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1067, ei_iso8859_1}, + {-1}, {-1}, +#line 636 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1070, ei_ebcdic423}, + {-1}, +#line 85 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1072, ei_sjis}, + {-1}, {-1}, {-1}, +#line 818 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1076, ei_ebcdic1158}, +#line 515 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1077, ei_cp1163}, + {-1}, +#line 203 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1079, ei_iso8859_5}, + {-1}, +#line 369 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1081, ei_mac_croatian}, + {-1}, {-1}, {-1}, +#line 792 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1085, ei_ebcdic1148}, + {-1}, {-1}, {-1}, +#line 421 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1089, ei_rk1048}, +#line 429 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1090, ei_tis620}, + {-1}, +#line 409 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1092, ei_armscii_8}, + {-1}, +#line 430 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1094, ei_tis620}, + {-1}, +#line 283 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1096, ei_koi8_ru}, +#line 196 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1097, ei_iso8859_4}, +#line 181 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1098, ei_iso8859_2}, +#line 276 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1099, ei_koi8_r}, + {-1}, {-1}, +#line 102 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1102, ei_euc_cn}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 808 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1109, ei_ebcdic1155}, +#line 335 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1110, ei_cp1258}, + {-1}, +#line 519 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1112, ei_cp437}, +#line 331 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1113, ei_cp1257}, +#line 104 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1114, ei_euc_cn}, + {-1}, +#line 730 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1116, ei_ebcdic1141}, +#line 81 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1117, ei_euc_jp}, + {-1}, {-1}, +#line 46 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1120, ei_ucs4be}, + {-1}, +#line 722 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1122, ei_ebcdic1140}, + {-1}, +#line 152 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1124, ei_cp949}, + {-1}, {-1}, +#line 805 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1127, ei_ebcdic1154}, +#line 764 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1128, ei_ebcdic1145}, +#line 411 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1129, ei_georgian_ps}, +#line 382 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1130, ei_mac_ukraine}, +#line 534 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1131, ei_cp853}, + {-1}, +#line 378 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1133, ei_mac_cyrillic}, + {-1}, +#line 180 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1135, ei_iso8859_2}, + {-1}, +#line 288 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1137, ei_cp1250}, + {-1}, +#line 33 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1139, ei_ucs2be}, + {-1}, +#line 699 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1141, ei_ebcdic1047}, + {-1}, +#line 317 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1143, ei_cp1255}, +#line 61 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1144, ei_utf32be}, + {-1}, +#line 756 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1146, ei_ebcdic1144}, + {-1}, {-1}, {-1}, {-1}, +#line 644 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1151, ei_ebcdic425}, + {-1}, {-1}, {-1}, +#line 15 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1155, ei_ascii}, + {-1}, {-1}, +#line 231 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1158, ei_iso8859_8}, + {-1}, +#line 344 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1160, ei_cp862}, +#line 310 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1161, ei_cp1254}, + {-1}, {-1}, {-1}, {-1}, +#line 799 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1166, ei_ebcdic1149}, + {-1}, +#line 263 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1168, ei_iso8859_15}, + {-1}, {-1}, {-1}, +#line 538 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1172, ei_cp855}, + {-1}, +#line 260 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1174, ei_iso8859_14}, +#line 473 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1175, ei_iso646_cn}, + {-1}, +#line 44 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1177, ei_ucs4}, + {-1}, {-1}, {-1}, +#line 93 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1181, ei_iso2022_jp1}, +#line 92 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1182, ei_iso2022_jp}, +#line 96 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1183, ei_iso2022_jpms}, +#line 738 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1184, ei_ebcdic1142}, +#line 100 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1185, ei_euc_cn}, +#line 245 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1186, ei_iso8859_10}, + {-1}, {-1}, {-1}, +#line 265 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1190, ei_iso8859_15}, + {-1}, +#line 95 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1192, ei_iso2022_jp2}, + {-1}, +#line 151 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1194, ei_cp949}, +#line 230 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1195, ei_iso8859_8}, +#line 31 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1196, ei_ucs2}, + {-1}, {-1}, +#line 299 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1199, ei_cp1252}, +#line 624 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1200, ei_ebcdic285}, + {-1}, {-1}, {-1}, {-1}, +#line 91 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1205, ei_iso2022_jp}, +#line 163 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1206, ei_iso8859_1}, +#line 248 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1207, ei_iso8859_11}, + {-1}, +#line 681 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1209, ei_ebcdic924}, +#line 353 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1210, ei_mac_roman}, +#line 431 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1211, ei_tis620}, +#line 128 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1212, ei_euc_tw}, +#line 242 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1213, ei_iso8859_10}, + {-1}, {-1}, {-1}, {-1}, +#line 198 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1218, ei_iso8859_5}, +#line 261 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1219, ei_iso8859_15}, + {-1}, +#line 427 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1221, ei_cp1133}, +#line 608 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1222, ei_ebcdic278}, +#line 477 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1223, ei_gb2312}, + {-1}, +#line 817 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1225, ei_ebcdic1158}, +#line 213 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1226, ei_iso8859_6}, + {-1}, {-1}, +#line 158 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1229, ei_iso2022_kr}, +#line 208 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1230, ei_iso8859_6}, + {-1}, {-1}, +#line 846 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1233, ei_iso2022_jp3}, + {-1}, {-1}, +#line 190 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1236, ei_iso8859_4}, +#line 255 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1237, ei_iso8859_14}, +#line 184 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1238, ei_iso8859_3}, + {-1}, {-1}, +#line 470 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1241, ei_jisx0212}, + {-1}, {-1}, +#line 788 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1244, ei_ebcdic1148}, + {-1}, {-1}, {-1}, +#line 185 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1248, ei_iso8859_3}, +#line 94 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1249, ei_iso2022_jp2}, +#line 485 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1250, ei_ksc5601}, +#line 148 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1251, ei_euc_kr}, + {-1}, {-1}, +#line 597 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1254, ei_ebcdic273}, + {-1}, +#line 527 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1256, ei_cp775}, + {-1}, +#line 381 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1258, ei_mac_ukraine}, +#line 334 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1259, ei_cp1258}, +#line 116 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1260, ei_gb18030_2022}, + {-1}, +#line 491 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1262, ei_cp922}, +#line 212 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1263, ei_iso8859_6}, +#line 570 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1264, ei_cp865}, + {-1}, +#line 408 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1266, ei_nextstep}, +#line 377 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1267, ei_mac_cyrillic}, +#line 366 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1268, ei_mac_iceland}, + {-1}, {-1}, {-1}, +#line 680 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1272, ei_ebcdic905}, + {-1}, +#line 174 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1274, ei_iso8859_2}, + {-1}, {-1}, +#line 122 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1277, ei_hz}, + {-1}, +#line 123 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1279, ei_hz}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 461 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1286, ei_jisx0208}, +#line 17 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1287, ei_ascii}, +#line 316 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1288, ei_cp1255}, + {-1}, {-1}, +#line 479 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1291, ei_gb2312}, + {-1}, +#line 811 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1293, ei_ebcdic1156}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 350 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1300, ei_cp1131}, +#line 746 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1301, ei_ebcdic1143}, +#line 550 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1302, ei_cp858}, + {-1}, +#line 254 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1304, ei_iso8859_13}, +#line 376 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1305, ei_mac_cyrillic}, +#line 711 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1306, ei_ebcdic1130}, + {-1}, {-1}, +#line 149 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1309, ei_euc_kr}, + {-1}, {-1}, +#line 772 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1312, ei_ebcdic1146}, +#line 781 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1313, ei_ebcdic1147}, +#line 545 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1314, ei_cp857}, + {-1}, {-1}, {-1}, +#line 800 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1318, ei_ebcdic1149}, +#line 540 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1319, ei_cp855}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 322 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1327, ei_cp1256}, +#line 218 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1328, ei_iso8859_7}, + {-1}, {-1}, {-1}, +#line 120 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1332, ei_iso2022_cn_ext}, + {-1}, +#line 225 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1334, ei_iso8859_8}, + {-1}, {-1}, +#line 504 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1337, ei_cp1129}, + {-1}, {-1}, +#line 745 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1340, ei_ebcdic1143}, +#line 403 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1341, ei_hp_roman8}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 848 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1350, ei_tds565}, + {-1}, {-1}, +#line 471 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1353, ei_jisx0212}, + {-1}, {-1}, {-1}, +#line 258 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1357, ei_iso8859_14}, +#line 816 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1358, ei_ebcdic1157}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 785 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1367, ei_ebcdic1147}, +#line 714 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1368, ei_ebcdic1132}, +#line 664 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1369, ei_ebcdic871}, + {-1}, +#line 675 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1371, ei_ebcdic880}, + {-1}, {-1}, +#line 708 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1374, ei_ebcdic1123}, + {-1}, +#line 87 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1376, ei_sjis}, +#line 113 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1377, ei_gb18030_2022}, +#line 157 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1378, ei_iso2022_kr}, +#line 34 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1379, ei_ucs2be}, +#line 655 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1380, ei_ebcdic838}, +#line 658 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1381, ei_ebcdic870}, + {-1}, {-1}, +#line 233 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1384, ei_iso8859_8}, + {-1}, {-1}, {-1}, +#line 484 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1388, ei_ksc5601}, +#line 169 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1389, ei_iso8859_1}, +#line 435 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1390, ei_tis620}, + {-1}, {-1}, +#line 273 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1393, ei_iso8859_16}, +#line 211 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1394, ei_iso8859_6}, +#line 239 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1395, ei_iso8859_9}, +#line 202 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1396, ei_iso8859_5}, + {-1}, +#line 851 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1398, ei_atarist}, +#line 561 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1399, ei_cp861}, +#line 506 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1400, ei_cp1161}, +#line 453 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1401, ei_iso646_jp}, +#line 205 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1402, ei_iso8859_6}, +#line 268 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1403, ei_iso8859_16}, +#line 195 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1404, ei_iso8859_4}, +#line 555 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1405, ei_cp860}, +#line 820 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1406, ei_ebcdic1160}, +#line 834 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1407, ei_ebcdic4971}, + {-1}, {-1}, {-1}, +#line 572 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1411, ei_cp865}, +#line 826 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1412, ei_ebcdic1165}, + {-1}, {-1}, +#line 23 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1415, ei_ascii}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 232 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1421, ei_iso8859_8}, + {-1}, +#line 179 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1423, ei_iso8859_2}, + {-1}, +#line 72 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1425, ei_ucs4internal}, + {-1}, {-1}, {-1}, +#line 567 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1429, ei_cp864}, +#line 823 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1430, ei_ebcdic1164}, +#line 454 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1431, ei_jisx0201}, + {-1}, {-1}, {-1}, +#line 552 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1435, ei_cp858}, + {-1}, +#line 433 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1437, ei_tis620}, + {-1}, +#line 56 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1439, ei_utf16le}, +#line 432 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1440, ei_tis620}, + {-1}, {-1}, {-1}, +#line 70 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1444, ei_ucs2internal}, + {-1}, +#line 678 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1446, ei_ebcdic905}, +#line 423 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1447, ei_rk1048}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, +#line 395 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1460, ei_mac_arabic}, + {-1}, +#line 55 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1462, ei_utf16be}, +#line 795 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1463, ei_ebcdic1149}, + {-1}, {-1}, +#line 604 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1466, ei_ebcdic277}, + {-1}, +#line 510 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1468, ei_cp1162}, + {-1}, +#line 360 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1470, ei_mac_centraleurope}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 65 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1477, ei_utf7}, + {-1}, {-1}, {-1}, {-1}, +#line 311 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1482, ei_cp1254}, +#line 387 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1483, ei_mac_turkish}, + {-1}, {-1}, {-1}, +#line 247 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1487, ei_iso8859_10}, +#line 88 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1488, ei_cp932}, + {-1}, {-1}, {-1}, {-1}, +#line 36 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1493, ei_ucs2be}, + {-1}, {-1}, +#line 466 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1496, ei_jisx0212}, + {-1}, {-1}, {-1}, {-1}, +#line 83 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1501, ei_sjis}, +#line 794 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1502, ei_ebcdic1149}, + {-1}, {-1}, {-1}, {-1}, +#line 593 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1507, ei_ebcdic037}, +#line 76 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1508, ei_euc_jp}, +#line 683 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1509, ei_ebcdic924}, + {-1}, +#line 486 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1511, ei_ksc5601}, + {-1}, +#line 383 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1513, ei_mac_greek}, +#line 305 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1514, ei_cp1253}, +#line 467 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1515, ei_jisx0212}, + {-1}, {-1}, {-1}, +#line 521 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1519, ei_cp437}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 253 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1526, ei_iso8859_13}, + {-1}, +#line 282 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1528, ei_koi8_ru}, +#line 74 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1529, ei_c99}, + {-1}, {-1}, {-1}, {-1}, +#line 141 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1534, ei_big5hkscs2008}, + {-1}, +#line 503 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1536, ei_cp1129}, +#line 16 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1537, ei_ascii}, + {-1}, +#line 412 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1539, ei_koi8_t}, + {-1}, {-1}, +#line 847 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1542, ei_big5_2003}, +#line 356 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1543, ei_mac_roman}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 189 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1550, ei_iso8859_3}, +#line 815 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1551, ei_ebcdic1157}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 844 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1557, ei_shift_jisx0213}, + {-1}, +#line 458 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1559, ei_jisx0208}, +#line 784 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1560, ei_ebcdic1147}, + {-1}, +#line 481 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1562, ei_isoir165}, +#line 698 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1563, ei_ebcdic1047}, + {-1}, +#line 697 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1565, ei_ebcdic1047}, + {-1}, +#line 488 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1567, ei_cp856}, + {-1}, +#line 426 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1569, ei_cp1133}, + {-1}, {-1}, +#line 783 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1572, ei_ebcdic1147}, + {-1}, {-1}, +#line 114 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1575, ei_gb18030_2022}, +#line 257 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1576, ei_iso8859_14}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 330 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1585, ei_cp1257}, + {-1}, +#line 188 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1587, ei_iso8859_3}, + {-1}, {-1}, +#line 264 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1590, ei_iso8859_15}, +#line 483 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1591, ei_ksc5601}, + {-1}, +#line 425 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1593, ei_mulelao}, + {-1}, +#line 348 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1595, ei_cp866}, +#line 829 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1596, ei_ebcdic1166}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 24 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1602, ei_ascii}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 634 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1608, ei_ebcdic423}, + {-1}, {-1}, {-1}, +#line 719 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1612, ei_ebcdic1137}, +#line 209 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1613, ei_iso8859_6}, +#line 596 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1614, ei_ebcdic273}, +#line 759 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1615, ei_ebcdic1144}, + {-1}, +#line 802 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1617, ei_ebcdic1153}, + {-1}, +#line 632 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1619, ei_ebcdic297}, + {-1}, +#line 106 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1621, ei_euc_cn}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 533 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1629, ei_cp853}, + {-1}, +#line 126 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1631, ei_euc_tw}, +#line 682 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1632, ei_ebcdic924}, + {-1}, {-1}, +#line 62 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1635, ei_utf32le}, +#line 747 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1636, ei_ebcdic1143}, +#line 162 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1637, ei_dec_hanyu}, + {-1}, {-1}, {-1}, +#line 524 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1641, ei_cp737}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 244 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1647, ei_iso8859_10}, + {-1}, +#line 187 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1649, ei_iso8859_3}, + {-1}, {-1}, +#line 228 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1652, ei_iso8859_8}, +#line 410 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1653, ei_georgian_academy}, + {-1}, {-1}, {-1}, {-1}, +#line 367 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1658, ei_mac_croatian}, +#line 346 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1659, ei_cp866}, + {-1}, +#line 292 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1661, ei_cp1251}, + {-1}, {-1}, +#line 286 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1664, ei_cp1250}, + {-1}, {-1}, +#line 315 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1667, ei_cp1255}, + {-1}, {-1}, {-1}, {-1}, +#line 266 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1672, ei_iso8859_15}, + {-1}, {-1}, +#line 207 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1675, ei_iso8859_6}, +#line 309 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1676, ei_cp1254}, + {-1}, {-1}, {-1}, {-1}, +#line 143 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1681, ei_euc_kr}, + {-1}, {-1}, {-1}, +#line 654 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1685, ei_ebcdic838}, +#line 40 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1686, ei_ucs2le}, + {-1}, {-1}, {-1}, +#line 365 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1690, ei_mac_iceland}, + {-1}, {-1}, {-1}, {-1}, +#line 298 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1695, ei_cp1252}, +#line 436 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1696, ei_tis620}, + {-1}, +#line 775 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1698, ei_ebcdic1146}, +#line 543 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1699, ei_cp857}, + {-1}, +#line 845 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1701, ei_iso2022_jp3}, + {-1}, +#line 835 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1703, ei_ebcdic12712}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 669 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1710, ei_ebcdic875}, + {-1}, +#line 241 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1712, ei_iso8859_9}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 562 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1721, ei_cp863}, + {-1}, +#line 219 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1723, ei_iso8859_7}, +#line 404 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1724, ei_hp_roman8}, +#line 333 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1725, ei_cp1258}, +#line 182 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1726, ei_iso8859_3}, +#line 249 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1727, ei_iso8859_13}, + {-1}, {-1}, {-1}, +#line 79 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1731, ei_euc_jp}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 838 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1737, ei_ebcdic16804}, +#line 546 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1738, ei_cp858}, +#line 438 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1739, ei_cp874}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 64 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1745, ei_utf7}, +#line 548 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1746, ei_cp858}, + {-1}, {-1}, +#line 240 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1749, ei_iso8859_9}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 279 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1758, ei_koi8_u}, +#line 321 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1759, ei_cp1256}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 107 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1776, ei_ces_gbk}, + {-1}, {-1}, +#line 250 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1779, ei_iso8859_13}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, +#line 86 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1791, ei_sjis}, +#line 450 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1792, ei_iso646_jp}, + {-1}, {-1}, +#line 18 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1795, ei_ascii}, +#line 476 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1796, ei_iso646_cn}, + {-1}, +#line 796 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1798, ei_ebcdic1149}, +#line 487 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1799, ei_ksc5601}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 718 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1805, ei_ebcdic1137}, + {-1}, {-1}, {-1}, {-1}, +#line 468 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1810, ei_jisx0212}, +#line 594 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1811, ei_ebcdic037}, + {-1}, {-1}, {-1}, +#line 592 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1815, ei_ebcdic037}, + {-1}, {-1}, {-1}, +#line 32 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1819, ei_ucs2}, + {-1}, {-1}, +#line 603 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1822, ei_ebcdic277}, + {-1}, {-1}, {-1}, {-1}, +#line 536 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1827, ei_cp853}, + {-1}, +#line 19 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1829, ei_ascii}, + {-1}, {-1}, #line 251 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str512, ei_tis620}, + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1832, ei_iso8859_13}, + {-1}, {-1}, +#line 75 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1835, ei_java}, + {-1}, {-1}, +#line 447 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1838, ei_tcvn}, {-1}, {-1}, {-1}, {-1}, -#line 119 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str517, ei_iso8859_8}, -#line 43 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str518, ei_utf32le}, -#line 296 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str519, ei_ksc5601}, -#line 106 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str520, ei_iso8859_7}, -#line 259 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str521, ei_tcvn}, +#line 460 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1843, ei_jisx0208}, {-1}, -#line 287 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str523, ei_iso646_cn}, +#line 666 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1845, ei_ebcdic871}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 662 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1851, ei_ebcdic870}, +#line 372 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1852, ei_mac_romania}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, +#line 665 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1864, ei_ebcdic871}, {-1}, -#line 335 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str525, ei_hz}, +#line 588 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1866, ei_ebcdic037}, + {-1}, {-1}, +#line 779 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1869, ei_ebcdic1147}, {-1}, -#line 311 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str527, ei_iso2022_jp}, +#line 446 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1871, ei_tcvn}, + {-1}, {-1}, +#line 455 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1874, ei_jisx0201}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 591 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1881, ei_ebcdic037}, +#line 661 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1882, ei_ebcdic870}, +#line 54 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1883, ei_utf16be}, + {-1}, {-1}, {-1}, {-1}, +#line 234 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1888, ei_iso8859_9}, +#line 701 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1889, ei_ebcdic1097}, + {-1}, {-1}, {-1}, +#line 243 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1893, ei_iso8859_10}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 379 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1902, ei_mac_ukraine}, +#line 222 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1903, ei_iso8859_7}, +#line 145 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1904, ei_euc_kr}, + {-1}, {-1}, {-1}, +#line 778 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1908, ei_ebcdic1147}, + {-1}, +#line 281 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1910, ei_koi8_ru}, +#line 696 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1911, ei_ebcdic1047}, + {-1}, {-1}, {-1}, +#line 494 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1915, ei_cp943}, + {-1}, {-1}, {-1}, +#line 564 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1919, ei_cp863}, +#line 514 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1920, ei_cp1163}, +#line 304 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1921, ei_cp1253}, + {-1}, {-1}, {-1}, +#line 199 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1925, ei_iso8859_5}, +#line 262 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1926, ei_iso8859_15}, + {-1}, {-1}, {-1}, +#line 229 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1930, ei_iso8859_8}, + {-1}, +#line 359 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1932, ei_mac_centraleurope}, + {-1}, +#line 191 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1934, ei_iso8859_4}, +#line 256 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1935, ei_iso8859_14}, +#line 210 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1936, ei_iso8859_6}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 269 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1954, ei_iso8859_16}, + {-1}, +#line 832 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1956, ei_ebcdic4971}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 166 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1965, ei_iso8859_1}, + {-1}, {-1}, {-1}, +#line 633 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1969, ei_ebcdic297}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 474 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1975, ei_iso646_cn}, + {-1}, {-1}, {-1}, +#line 631 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1979, ei_ebcdic297}, + {-1}, {-1}, {-1}, +#line 226 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1983, ei_iso8859_8}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 843 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1989, ei_shift_jisx0213}, + {-1}, {-1}, +#line 653 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1992, ei_ebcdic838}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 674 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2008, ei_ebcdic880}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, +#line 73 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2020, ei_ucs4swapped}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 364 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2026, ei_mac_iceland}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, +#line 71 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2039, ei_ucs2swapped}, +#line 464 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2040, ei_jisx0208}, +#line 66 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2041, ei_utf7}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 523 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2048, ei_cp737}, + {-1}, {-1}, +#line 363 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2051, ei_mac_iceland}, + {-1}, {-1}, {-1}, {-1}, +#line 275 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2056, ei_koi8_r}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 574 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2063, ei_cp869}, + {-1}, {-1}, +#line 112 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2066, ei_gb18030_2005}, + {-1}, {-1}, +#line 842 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2069, ei_euc_jisx0213}, + {-1}, {-1}, {-1}, +#line 449 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2073, ei_iso646_jp}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 60 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2079, ei_utf32be}, + {-1}, +#line 577 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2081, ei_cp869}, +#line 417 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2082, ei_pt154}, + {-1}, {-1}, +#line 472 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2085, ei_iso646_cn}, + {-1}, {-1}, {-1}, {-1}, #line 132 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str528, ei_iso8859_10}, -#line 316 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str529, ei_iso2022_jpms}, -#line 313 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str530, ei_iso2022_jp1}, -#line 299 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str531, ei_ksc5601}, + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2090, ei_ces_big5}, + {-1}, {-1}, {-1}, +#line 115 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2094, ei_gb18030_2022}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 459 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2100, ei_jisx0208}, +#line 400 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2101, ei_mac_thai}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 221 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2110, ei_iso8859_7}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 224 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2118, ei_iso8859_7}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 103 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2127, ei_euc_cn}, + {-1}, {-1}, +#line 323 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2130, ei_cp1256}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 595 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2137, ei_ebcdic273}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 520 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2143, ei_cp437}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, +#line 223 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2155, ei_iso8859_7}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 635 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2171, ei_ebcdic423}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 183 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2179, ei_iso8859_3}, + {-1}, {-1}, +#line 602 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2182, ei_ebcdic277}, +#line 139 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2183, ei_big5hkscs2001}, + {-1}, +#line 814 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2185, ei_ebcdic1157}, + {-1}, {-1}, {-1}, {-1}, +#line 525 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2190, ei_cp775}, + {-1}, +#line 620 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2192, ei_ebcdic284}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 140 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2198, ei_big5hkscs2004}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 780 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2204, ei_ebcdic1147}, +#line 327 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2205, ei_cp1257}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 542 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2213, ei_cp857}, + {-1}, {-1}, {-1}, {-1}, +#line 649 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2218, ei_ebcdic500}, +#line 329 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2219, ei_cp1257}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, +#line 380 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2240, ei_mac_ukraine}, + {-1}, {-1}, {-1}, +#line 80 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2244, ei_euc_jp}, + {-1}, +#line 605 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2246, ei_ebcdic278}, +#line 142 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2247, ei_big5hkscs2008}, + {-1}, {-1}, +#line 291 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2250, ei_cp1251}, + {-1}, {-1}, +#line 287 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2253, ei_cp1250}, + {-1}, {-1}, +#line 314 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2256, ei_cp1255}, + {-1}, {-1}, {-1}, {-1}, +#line 371 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2261, ei_mac_romania}, + {-1}, {-1}, {-1}, +#line 308 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2265, ei_cp1254}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 343 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2280, ei_cp862}, + {-1}, {-1}, {-1}, +#line 297 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2284, ei_cp1252}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 214 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2294, ei_iso8859_7}, +#line 153 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2295, ei_johab}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 332 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2314, ei_cp1258}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 606 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2333, ei_ebcdic278}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 320 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2348, ei_cp1256}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 125 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2365, ei_euc_tw}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, +#line 717 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2388, ei_ebcdic1137}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 544 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2395, ei_cp857}, + {-1}, {-1}, {-1}, +#line 164 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2399, ei_iso8859_1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 587 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2406, ei_ebcdic037}, + {-1}, +#line 526 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2408, ei_cp775}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 518 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2418, ei_cp437}, + {-1}, {-1}, {-1}, {-1}, +#line 388 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2423, ei_mac_turkish}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 175 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2433, ei_iso8859_2}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 465 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2449, ei_jisx0208}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 535 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2459, ei_cp853}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 463 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2483, ei_jisx0208}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, +#line 206 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2497, ei_iso8859_6}, + {-1}, {-1}, {-1}, +#line 20 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2501, ei_ascii}, +#line 154 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2502, ei_johab}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 303 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2510, ei_cp1253}, + {-1}, {-1}, {-1}, +#line 220 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2514, ei_iso8859_7}, {-1}, {-1}, -#line 312 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str534, ei_iso2022_jp}, -#line 97 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str535, ei_iso8859_6}, +#line 841 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2517, ei_euc_jisx0213}, +#line 629 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2518, ei_ebcdic297}, + {-1}, +#line 607 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2520, ei_ebcdic278}, {-1}, {-1}, {-1}, -#line 112 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str539, ei_iso8859_7}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 254 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str545, ei_cp874}, +#line 138 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2524, ei_big5hkscs1999}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 338 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str547, ei_euc_tw}, +#line 391 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2535, ei_mac_hebrew}, {-1}, -#line 214 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str549, ei_mac_centraleurope}, +#line 235 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2537, ei_iso8859_9}, + {-1}, {-1}, {-1}, +#line 161 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2541, ei_dec_kanji}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 284 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str551, ei_jisx0212}, - {-1}, {-1}, -#line 292 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str554, ei_gb2312}, -#line 314 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str555, ei_iso2022_jp2}, +#line 852 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2552, ei_riscos1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 135 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2562, ei_cp950}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 127 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2588, ei_euc_tw}, {-1}, -#line 191 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str557, ei_cp1256}, -#line 143 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str558, ei_iso8859_13}, - {-1}, {-1}, -#line 315 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str561, ei_iso2022_jp2}, +#line 679 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2590, ei_ebcdic905}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 630 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2635, ei_ebcdic297}, {-1}, {-1}, {-1}, {-1}, -#line 193 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str566, ei_cp1257}, -#line 229 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str567, ei_nextstep}, - {-1}, {-1}, -#line 44 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str570, ei_utf7}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 289 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str577, ei_iso646_cn}, - {-1}, {-1}, {-1}, -#line 250 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str581, ei_tis620}, +#line 328 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2640, ei_cp1257}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 20 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str588, ei_ascii}, - {-1}, {-1}, {-1}, -#line 330 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str592, ei_gb18030_2022}, - {-1}, {-1}, -#line 350 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str595, ei_big5hkscs2008}, +#line 601 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2647, ei_ebcdic277}, + {-1}, {-1}, {-1}, {-1}, +#line 700 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2652, ei_ebcdic1097}, + {-1}, {-1}, {-1}, {-1}, +#line 766 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2657, ei_ebcdic1145}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 368 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2681, ei_mac_croatian}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 349 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str598, ei_big5hkscs2008}, +#line 216 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2693, ei_iso8859_7}, + {-1}, {-1}, {-1}, +#line 640 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2697, ei_ebcdic424}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 612 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2712, ei_ebcdic280}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 146 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2720, ei_euc_kr}, +#line 599 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2721, ei_ebcdic277}, {-1}, {-1}, {-1}, {-1}, -#line 219 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str612, ei_mac_ukraine}, +#line 77 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2726, ei_euc_jp}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 660 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2732, ei_ebcdic870}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 329 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str629, ei_gb18030_2005}, + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 448 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2747, ei_tcvn}, {-1}, {-1}, {-1}, -#line 105 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str633, ei_iso8859_7}, - {-1}, {-1}, -#line 111 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str636, ei_iso8859_7}, -#line 185 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str637, ei_cp1254}, +#line 626 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2751, ei_ebcdic285}, {-1}, -#line 28 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str639, ei_ucs2be}, - {-1}, {-1}, {-1}, -#line 39 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str643, ei_utf16be}, +#line 758 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2753, ei_ebcdic1144}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, -#line 32 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str655, ei_ucs2le}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, +#line 774 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2775, ei_ebcdic1146}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 303 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str664, ei_euc_jp}, +#line 850 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2784, ei_atarist}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 326 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2794, ei_cp1257}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 118 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str683, ei_iso8859_8}, - {-1}, -#line 221 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str685, ei_mac_turkish}, - {-1}, {-1}, {-1}, -#line 279 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str689, ei_jisx0212}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 306 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str697, ei_sjis}, -#line 305 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str698, ei_sjis}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 271 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str706, ei_jisx0208}, +#line 396 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2829, ei_mac_arabic}, {-1}, -#line 267 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str708, ei_jisx0201}, - {-1}, {-1}, {-1}, -#line 308 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str712, ei_sjis}, +#line 78 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2831, ei_euc_jp}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 261 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str720, ei_tcvn}, - {-1}, {-1}, -#line 42 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str723, ei_utf32be}, +#line 798 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2839, ei_ebcdic1149}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 437 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2847, ei_cp874}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, +#line 589 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2924, ei_ebcdic037}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 215 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2943, ei_iso8859_7}, {-1}, {-1}, {-1}, -#line 182 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str727, ei_cp1253}, +#line 522 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2947, ei_cp737}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 268 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str732, ei_jisx0201}, - {-1}, -#line 220 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str734, ei_mac_greek}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 270 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str740, ei_jisx0201}, - {-1}, -#line 194 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str742, ei_cp1257}, +#line 648 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str2961, ei_ebcdic500}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 790 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3005, ei_ebcdic1148}, +#line 109 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3006, ei_cp936}, {-1}, -#line 281 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str744, ei_jisx0212}, +#line 384 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3008, ei_mac_greek}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 724 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3036, ei_ebcdic1140}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, -#line 351 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str756, ei_big5hkscs2008}, -#line 347 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str757, ei_big5hkscs2001}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 346 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str763, ei_big5hkscs1999}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 348 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str769, ei_big5hkscs2004}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 272 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str780, ei_jisx0208}, +#line 750 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3137, ei_ebcdic1143}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 273 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str787, ei_jisx0208}, +#line 670 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3162, ei_ebcdic875}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 685 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3188, ei_ebcdic924}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 741 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3206, ei_ebcdic1142}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 309 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str789, ei_sjis}, +#line 782 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3226, ei_ebcdic1147}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, +#line 590 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3248, ei_ebcdic037}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 357 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str822, ei_johab}, - {-1}, {-1}, {-1}, {-1}, -#line 342 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str827, ei_ces_big5}, - {-1}, {-1}, -#line 341 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str830, ei_ces_big5}, -#line 280 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str831, ei_jisx0212}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 278 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str852, ei_jisx0208}, +#line 749 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3278, ei_ebcdic1143}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 392 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3315, ei_mac_hebrew}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 304 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str861, ei_euc_jp}, +#line 457 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3558, ei_jisx0201}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, -#line 222 "lib/generated/aliases.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str875, ei_mac_hebrew} + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, +#line 600 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3632, ei_ebcdic277}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, +#line 732 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3885, ei_ebcdic1141}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {-1}, +#line 740 "lib/generated/aliases.gperf" + {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str4067, ei_ebcdic1142} }; const struct alias * -HashPool::aliases_lookup (const char *str, size_t len) +aliases_lookup (register const char *str, register size_t len) { if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { - unsigned int key = aliases_hash (str, len); + register unsigned int key = aliases_hash (str, len); if (key <= MAX_HASH_VALUE) { - int o = aliases[key].name; + register int o = aliases[key].name; if (o >= 0) { - const char *s = o + stringpool; + register const char *s = o + stringpool; if (*str == *s && !strcmp (str + 1, s + 1)) return &aliases[key]; diff --git a/lib/generated/aliases_aix.h b/lib/generated/aliases_aix.h deleted file mode 100644 index 5cbc77fd..00000000 --- a/lib/generated/aliases_aix.h +++ /dev/null @@ -1,18 +0,0 @@ - S(aix_0, "CP856", ei_cp856 ) - S(aix_1, "CP922", ei_cp922 ) - S(aix_2, "CP943", ei_cp943 ) - S(aix_3, "CP1046", ei_cp1046 ) - S(aix_4, "CP1124", ei_cp1124 ) - S(aix_5, "CP1129", ei_cp1129 ) - S(aix_6, "CP1161", ei_cp1161 ) - S(aix_7, "IBM1161", ei_cp1161 ) - S(aix_8, "IBM-1161", ei_cp1161 ) - S(aix_9, "CSIBM1161", ei_cp1161 ) - S(aix_10, "CP1162", ei_cp1162 ) - S(aix_11, "IBM1162", ei_cp1162 ) - S(aix_12, "IBM-1162", ei_cp1162 ) - S(aix_13, "CSIBM1162", ei_cp1162 ) - S(aix_14, "CP1163", ei_cp1163 ) - S(aix_15, "IBM1163", ei_cp1163 ) - S(aix_16, "IBM-1163", ei_cp1163 ) - S(aix_17, "CSIBM1163", ei_cp1163 ) diff --git a/lib/generated/aliases_aix_sysaix.h b/lib/generated/aliases_aix_sysaix.h deleted file mode 100644 index b7dc5841..00000000 --- a/lib/generated/aliases_aix_sysaix.h +++ /dev/null @@ -1,24 +0,0 @@ - S(aix_0, "CP856", ei_cp856 ) - S(aix_1, "IBM-856", ei_cp856 ) - S(aix_2, "CP922", ei_cp922 ) - S(aix_3, "IBM-922", ei_cp922 ) - S(aix_4, "CP943", ei_cp943 ) - S(aix_5, "IBM-943", ei_cp943 ) - S(aix_6, "CP1046", ei_cp1046 ) - S(aix_7, "IBM-1046", ei_cp1046 ) - S(aix_8, "CP1124", ei_cp1124 ) - S(aix_9, "IBM-1124", ei_cp1124 ) - S(aix_10, "CP1129", ei_cp1129 ) - S(aix_11, "IBM-1129", ei_cp1129 ) - S(aix_12, "CP1161", ei_cp1161 ) - S(aix_13, "IBM1161", ei_cp1161 ) - S(aix_14, "IBM-1161", ei_cp1161 ) - S(aix_15, "CSIBM1161", ei_cp1161 ) - S(aix_16, "CP1162", ei_cp1162 ) - S(aix_17, "IBM1162", ei_cp1162 ) - S(aix_18, "IBM-1162", ei_cp1162 ) - S(aix_19, "CSIBM1162", ei_cp1162 ) - S(aix_20, "CP1163", ei_cp1163 ) - S(aix_21, "IBM1163", ei_cp1163 ) - S(aix_22, "IBM-1163", ei_cp1163 ) - S(aix_23, "CSIBM1163", ei_cp1163 ) diff --git a/lib/generated/aliases_dos.h b/lib/generated/aliases_dos.h deleted file mode 100644 index bdff437c..00000000 --- a/lib/generated/aliases_dos.h +++ /dev/null @@ -1,49 +0,0 @@ - S(dos_0, "CP437", ei_cp437 ) - S(dos_1, "IBM437", ei_cp437 ) - S(dos_2, "437", ei_cp437 ) - S(dos_3, "CSPC8CODEPAGE437", ei_cp437 ) - S(dos_4, "CP737", ei_cp737 ) - S(dos_5, "IBM737", ei_cp737 ) - S(dos_6, "CP775", ei_cp775 ) - S(dos_7, "IBM775", ei_cp775 ) - S(dos_8, "CSPC775BALTIC", ei_cp775 ) - S(dos_9, "CP852", ei_cp852 ) - S(dos_10, "IBM852", ei_cp852 ) - S(dos_11, "852", ei_cp852 ) - S(dos_12, "CSPCP852", ei_cp852 ) - S(dos_13, "CP853", ei_cp853 ) - S(dos_14, "CP855", ei_cp855 ) - S(dos_15, "IBM855", ei_cp855 ) - S(dos_16, "855", ei_cp855 ) - S(dos_17, "CSIBM855", ei_cp855 ) - S(dos_18, "CP857", ei_cp857 ) - S(dos_19, "IBM857", ei_cp857 ) - S(dos_20, "857", ei_cp857 ) - S(dos_21, "CSIBM857", ei_cp857 ) - S(dos_22, "CP858", ei_cp858 ) - S(dos_23, "CP860", ei_cp860 ) - S(dos_24, "IBM860", ei_cp860 ) - S(dos_25, "860", ei_cp860 ) - S(dos_26, "CSIBM860", ei_cp860 ) - S(dos_27, "CP861", ei_cp861 ) - S(dos_28, "IBM861", ei_cp861 ) - S(dos_29, "861", ei_cp861 ) - S(dos_30, "CP-IS", ei_cp861 ) - S(dos_31, "CSIBM861", ei_cp861 ) - S(dos_32, "CP863", ei_cp863 ) - S(dos_33, "IBM863", ei_cp863 ) - S(dos_34, "863", ei_cp863 ) - S(dos_35, "CSIBM863", ei_cp863 ) - S(dos_36, "CP864", ei_cp864 ) - S(dos_37, "IBM864", ei_cp864 ) - S(dos_38, "CSIBM864", ei_cp864 ) - S(dos_39, "CP865", ei_cp865 ) - S(dos_40, "IBM865", ei_cp865 ) - S(dos_41, "865", ei_cp865 ) - S(dos_42, "CSIBM865", ei_cp865 ) - S(dos_43, "CP869", ei_cp869 ) - S(dos_44, "IBM869", ei_cp869 ) - S(dos_45, "869", ei_cp869 ) - S(dos_46, "CP-GR", ei_cp869 ) - S(dos_47, "CSIBM869", ei_cp869 ) - S(dos_48, "CP1125", ei_cp1125 ) diff --git a/lib/generated/aliases_extra.h b/lib/generated/aliases_extra.h deleted file mode 100644 index 9a54e16a..00000000 --- a/lib/generated/aliases_extra.h +++ /dev/null @@ -1,12 +0,0 @@ - S(extra_0, "EUC-JISX0213", ei_euc_jisx0213 ) - S(extra_1, "EUC-JIS-2004", ei_euc_jisx0213 ) - S(extra_2, "SHIFT_JISX0213", ei_shift_jisx0213 ) - S(extra_3, "SHIFT_JIS-2004", ei_shift_jisx0213 ) - S(extra_4, "ISO-2022-JP-3", ei_iso2022_jp3 ) - S(extra_5, "ISO-2022-JP-2004", ei_iso2022_jp3 ) - S(extra_6, "BIG5-2003", ei_big5_2003 ) - S(extra_7, "TDS565", ei_tds565 ) - S(extra_8, "ISO-IR-230", ei_tds565 ) - S(extra_9, "ATARIST", ei_atarist ) - S(extra_10, "ATARI", ei_atarist ) - S(extra_11, "RISCOS-LATIN1", ei_riscos1 ) diff --git a/lib/generated/aliases_osf1.h b/lib/generated/aliases_osf1.h deleted file mode 100644 index 9e4f6854..00000000 --- a/lib/generated/aliases_osf1.h +++ /dev/null @@ -1,2 +0,0 @@ - S(osf1_0, "DEC-KANJI", ei_dec_kanji ) - S(osf1_1, "DEC-HANYU", ei_dec_hanyu ) diff --git a/lib/generated/aliases_osf1_sysosf1.h b/lib/generated/aliases_osf1_sysosf1.h deleted file mode 100644 index b1f802d2..00000000 --- a/lib/generated/aliases_osf1_sysosf1.h +++ /dev/null @@ -1,4 +0,0 @@ - S(osf1_0, "DEC-KANJI", ei_dec_kanji ) - S(osf1_1, "DECKANJI", ei_dec_kanji ) - S(osf1_2, "DEC-HANYU", ei_dec_hanyu ) - S(osf1_3, "DECHANYU", ei_dec_hanyu ) diff --git a/lib/generated/aliases_sysaix.h b/lib/generated/aliases_sysaix.h deleted file mode 100644 index 6d531c57..00000000 --- a/lib/generated/aliases_sysaix.h +++ /dev/null @@ -1,1792 +0,0 @@ -/* C++ code produced by gperf version 3.1 */ -/* Command-line: gperf -L C++ -Z HashPool -m 10 lib/generated/aliases_sysaix.gperf */ -/* Computed positions: -k'1,3-11,$' */ - -#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ - && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ - && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ - && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ - && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ - && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ - && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ - && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ - && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ - && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ - && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ - && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ - && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ - && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ - && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ - && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ - && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ - && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ - && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ - && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ - && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ - && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ - && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) -/* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." -#endif - -#line 1 "lib/generated/aliases_sysaix.gperf" -struct alias { int name; unsigned int encoding_index; }; - -#define TOTAL_KEYWORDS 358 -#define MIN_WORD_LENGTH 2 -#define MAX_WORD_LENGTH 45 -#define MIN_HASH_VALUE 16 -#define MAX_HASH_VALUE 1046 -/* maximum key range = 1031, duplicates = 0 */ - -class HashPool -{ -private: - static inline unsigned int aliases_hash (const char *str, size_t len); -public: - static const struct alias *aliases_lookup (const char *str, size_t len); -}; - -inline unsigned int -HashPool::aliases_hash (const char *str, size_t len) -{ - static const unsigned short asso_values[] = - { - 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, - 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, - 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, - 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, - 1047, 1047, 1047, 1047, 1047, 5, 133, 1047, 97, 7, - 33, 130, 15, 17, 5, 205, 23, 25, 326, 1047, - 1047, 1047, 1047, 1047, 1047, 165, 130, 11, 17, 135, - 163, 104, 10, 6, 233, 31, 9, 154, 8, 6, - 124, 1047, 5, 5, 28, 218, 9, 204, 241, 5, - 7, 1047, 1047, 1047, 1047, 6, 1047, 1047, 1047, 1047, - 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, - 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, - 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047 - }; - unsigned int hval = len; - - switch (hval) - { - default: - hval += asso_values[static_cast(str[10])]; - /*FALLTHROUGH*/ - case 10: - hval += asso_values[static_cast(str[9])]; - /*FALLTHROUGH*/ - case 9: - hval += asso_values[static_cast(str[8])]; - /*FALLTHROUGH*/ - case 8: - hval += asso_values[static_cast(str[7])]; - /*FALLTHROUGH*/ - case 7: - hval += asso_values[static_cast(str[6])]; - /*FALLTHROUGH*/ - case 6: - hval += asso_values[static_cast(str[5])]; - /*FALLTHROUGH*/ - case 5: - hval += asso_values[static_cast(str[4])]; - /*FALLTHROUGH*/ - case 4: - hval += asso_values[static_cast(str[3])]; - /*FALLTHROUGH*/ - case 3: - hval += asso_values[static_cast(str[2])]; - /*FALLTHROUGH*/ - case 2: - case 1: - hval += asso_values[static_cast(str[0])]; - break; - } - return hval + asso_values[static_cast(str[len - 1])]; -} - -struct stringpool_t - { - char stringpool_str16[sizeof("L6")]; - char stringpool_str18[sizeof("L1")]; - char stringpool_str19[sizeof("HZ")]; - char stringpool_str21[sizeof("CN")]; - char stringpool_str25[sizeof("SJIS")]; - char stringpool_str26[sizeof("L4")]; - char stringpool_str28[sizeof("L5")]; - char stringpool_str30[sizeof("R8")]; - char stringpool_str34[sizeof("L8")]; - char stringpool_str36[sizeof("866")]; - char stringpool_str44[sizeof("L2")]; - char stringpool_str49[sizeof("VISCII")]; - char stringpool_str51[sizeof("ISO-IR-6")]; - char stringpool_str54[sizeof("CP866")]; - char stringpool_str57[sizeof("TCVN")]; - char stringpool_str64[sizeof("C99")]; - char stringpool_str65[sizeof("ISO-IR-166")]; - char stringpool_str67[sizeof("LATIN6")]; - char stringpool_str68[sizeof("CSVISCII")]; - char stringpool_str70[sizeof("CP154")]; - char stringpool_str71[sizeof("LATIN1")]; - char stringpool_str76[sizeof("CYRILLIC")]; - char stringpool_str78[sizeof("ISO646-CN")]; - char stringpool_str79[sizeof("ISO-IR-14")]; - char stringpool_str81[sizeof("KOI8-R")]; - char stringpool_str84[sizeof("CP1256")]; - char stringpool_str87[sizeof("LATIN4")]; - char stringpool_str88[sizeof("CP1251")]; - char stringpool_str89[sizeof("ISO-IR-165")]; - char stringpool_str91[sizeof("LATIN5")]; - char stringpool_str92[sizeof("862")]; - char stringpool_str93[sizeof("ISO-IR-126")]; - char stringpool_str94[sizeof("CSKOI8R")]; - char stringpool_str95[sizeof("ISO-IR-144")]; - char stringpool_str96[sizeof("CP819")]; - char stringpool_str103[sizeof("LATIN8")]; - char stringpool_str104[sizeof("CP1254")]; - char stringpool_str105[sizeof("ISO-IR-58")]; - char stringpool_str106[sizeof("CP949")]; - char stringpool_str108[sizeof("CP1255")]; - char stringpool_str110[sizeof("CP862")]; - char stringpool_str111[sizeof("ISO-IR-148")]; - char stringpool_str113[sizeof("LATIN-9")]; - char stringpool_str115[sizeof("ISO-IR-149")]; - char stringpool_str117[sizeof("ISO-IR-159")]; - char stringpool_str119[sizeof("ISO-IR-226")]; - char stringpool_str120[sizeof("CP1258")]; - char stringpool_str123[sizeof("LATIN2")]; - char stringpool_str124[sizeof("ISO8859-6")]; - char stringpool_str125[sizeof("ISO-IR-199")]; - char stringpool_str127[sizeof("KOI8-T")]; - char stringpool_str128[sizeof("ISO8859-1")]; - char stringpool_str130[sizeof("ISO-8859-6")]; - char stringpool_str131[sizeof("ISO_8859-6")]; - char stringpool_str132[sizeof("ISO8859-16")]; - char stringpool_str134[sizeof("ISO-8859-1")]; - char stringpool_str135[sizeof("ISO_8859-1")]; - char stringpool_str136[sizeof("ISO8859-11")]; - char stringpool_str138[sizeof("ISO-8859-16")]; - char stringpool_str139[sizeof("ISO_8859-16")]; - char stringpool_str140[sizeof("CP1252")]; - char stringpool_str141[sizeof("L3")]; - char stringpool_str142[sizeof("ISO-8859-11")]; - char stringpool_str143[sizeof("ISO_8859-11")]; - char stringpool_str144[sizeof("ISO8859-4")]; - char stringpool_str146[sizeof("ISO_8859-16:2001")]; - char stringpool_str148[sizeof("ISO8859-5")]; - char stringpool_str150[sizeof("ISO-8859-4")]; - char stringpool_str151[sizeof("ISO_8859-4")]; - char stringpool_str152[sizeof("ISO8859-14")]; - char stringpool_str154[sizeof("ISO-8859-5")]; - char stringpool_str155[sizeof("ISO_8859-5")]; - char stringpool_str156[sizeof("ISO8859-15")]; - char stringpool_str158[sizeof("ISO-8859-14")]; - char stringpool_str159[sizeof("ISO_8859-14")]; - char stringpool_str160[sizeof("ISO8859-8")]; - char stringpool_str161[sizeof("ISO-IR-101")]; - char stringpool_str162[sizeof("ISO-8859-15")]; - char stringpool_str163[sizeof("ISO_8859-15")]; - char stringpool_str164[sizeof("ISO8859-9")]; - char stringpool_str166[sizeof("ISO-8859-8")]; - char stringpool_str167[sizeof("ISO_8859-8")]; - char stringpool_str169[sizeof("GBK")]; - char stringpool_str170[sizeof("ISO-8859-9")]; - char stringpool_str171[sizeof("ISO_8859-9")]; - char stringpool_str172[sizeof("ISO_8859-14:1998")]; - char stringpool_str173[sizeof("CP1361")]; - char stringpool_str174[sizeof("ISO_8859-15:1998")]; - char stringpool_str175[sizeof("CP1131")]; - char stringpool_str176[sizeof("RK1048")]; - char stringpool_str178[sizeof("EUCCN")]; - char stringpool_str179[sizeof("MAC")]; - char stringpool_str180[sizeof("ISO8859-2")]; - char stringpool_str181[sizeof("CP936")]; - char stringpool_str183[sizeof("PT154")]; - char stringpool_str184[sizeof("EUC-CN")]; - char stringpool_str186[sizeof("ISO-8859-2")]; - char stringpool_str187[sizeof("ISO_8859-2")]; - char stringpool_str189[sizeof("KSC_5601")]; - char stringpool_str192[sizeof("EUCKR")]; - char stringpool_str197[sizeof("ISO-IR-109")]; - char stringpool_str198[sizeof("EUC-KR")]; - char stringpool_str199[sizeof("ASCII")]; - char stringpool_str204[sizeof("IBM866")]; - char stringpool_str205[sizeof("MS-CYRL")]; - char stringpool_str206[sizeof("L10")]; - char stringpool_str208[sizeof("KZ-1048")]; - char stringpool_str212[sizeof("CP50221")]; - char stringpool_str214[sizeof("VISCII1.1-1")]; - char stringpool_str216[sizeof("L7")]; - char stringpool_str217[sizeof("CSASCII")]; - char stringpool_str219[sizeof("ISO_646.IRV:1991")]; - char stringpool_str220[sizeof("850")]; - char stringpool_str222[sizeof("CSKZ1048")]; - char stringpool_str225[sizeof("US")]; - char stringpool_str226[sizeof("ISO-IR-138")]; - char stringpool_str231[sizeof("KS_C_5601-1989")]; - char stringpool_str237[sizeof("CP932")]; - char stringpool_str238[sizeof("ISO-CELTIC")]; - char stringpool_str243[sizeof("UHC")]; - char stringpool_str244[sizeof("IBM-921")]; - char stringpool_str246[sizeof("IBM819")]; - char stringpool_str247[sizeof("MACINTOSH")]; - char stringpool_str249[sizeof("MACCYRILLIC")]; - char stringpool_str250[sizeof("CP850")]; - char stringpool_str251[sizeof("ISO-IR-110")]; - char stringpool_str252[sizeof("CP950")]; - char stringpool_str254[sizeof("CYRILLIC-ASIAN")]; - char stringpool_str256[sizeof("ISO-2022-CN")]; - char stringpool_str259[sizeof("LATIN10")]; - char stringpool_str260[sizeof("IBM862")]; - char stringpool_str262[sizeof("CSISO2022CN")]; - char stringpool_str263[sizeof("UCS-4")]; - char stringpool_str264[sizeof("ISO_8859-10:1992")]; - char stringpool_str265[sizeof("CSISOLATIN6")]; - char stringpool_str268[sizeof("CP1250")]; - char stringpool_str269[sizeof("CSISOLATIN1")]; - char stringpool_str270[sizeof("ISO-2022-KR")]; - char stringpool_str271[sizeof("TIS620")]; - char stringpool_str272[sizeof("BIG5")]; - char stringpool_str274[sizeof("CP874")]; - char stringpool_str276[sizeof("CSISO2022KR")]; - char stringpool_str277[sizeof("TIS-620")]; - char stringpool_str278[sizeof("BIG-5")]; - char stringpool_str279[sizeof("ISO646-US")]; - char stringpool_str280[sizeof("ISO-2022-CN-EXT")]; - char stringpool_str281[sizeof("CSUCS4")]; - char stringpool_str284[sizeof("CSISOLATINCYRILLIC")]; - char stringpool_str285[sizeof("CSISOLATIN4")]; - char stringpool_str287[sizeof("ELOT_928")]; - char stringpool_str289[sizeof("CSISOLATIN5")]; - char stringpool_str291[sizeof("CSBIG5")]; - char stringpool_str296[sizeof("IBM-1252")]; - char stringpool_str297[sizeof("CN-BIG5")]; - char stringpool_str299[sizeof("UCS-2")]; - char stringpool_str305[sizeof("ISO-IR-179")]; - char stringpool_str314[sizeof("CN-GB-ISOIR165")]; - char stringpool_str316[sizeof("ISO8859-10")]; - char stringpool_str317[sizeof("LATIN3")]; - char stringpool_str320[sizeof("PTCP154")]; - char stringpool_str321[sizeof("CSISOLATIN2")]; - char stringpool_str322[sizeof("ISO-8859-10")]; - char stringpool_str323[sizeof("ISO_8859-10")]; - char stringpool_str324[sizeof("MS936")]; - char stringpool_str327[sizeof("BIG5HKSCS")]; - char stringpool_str328[sizeof("CSISO14JISC6220RO")]; - char stringpool_str331[sizeof("IBM-1131")]; - char stringpool_str333[sizeof("BIG5-HKSCS")]; - char stringpool_str334[sizeof("CP1253")]; - char stringpool_str336[sizeof("TCVN5712-1")]; - char stringpool_str341[sizeof("ISO-IR-100")]; - char stringpool_str346[sizeof("GB2312")]; - char stringpool_str347[sizeof("CSIBM866")]; - char stringpool_str352[sizeof("X0212")]; - char stringpool_str354[sizeof("TCVN-5712")]; - char stringpool_str356[sizeof("MS-ANSI")]; - char stringpool_str358[sizeof("KOREAN")]; - char stringpool_str359[sizeof("JP")]; - char stringpool_str361[sizeof("CSPTCP154")]; - char stringpool_str364[sizeof("STRK1048-2002")]; - char stringpool_str374[sizeof("ISO8859-3")]; - char stringpool_str375[sizeof("TIS620-0")]; - char stringpool_str380[sizeof("ISO-8859-3")]; - char stringpool_str381[sizeof("ISO_8859-3")]; - char stringpool_str382[sizeof("ISO8859-13")]; - char stringpool_str384[sizeof("ROMAN8")]; - char stringpool_str385[sizeof("CN-GB")]; - char stringpool_str387[sizeof("MACTHAI")]; - char stringpool_str388[sizeof("ISO-8859-13")]; - char stringpool_str389[sizeof("ISO_8859-13")]; - char stringpool_str390[sizeof("X0201")]; - char stringpool_str393[sizeof("IBM-932")]; - char stringpool_str394[sizeof("CSISOLATINGREEK")]; - char stringpool_str399[sizeof("ISO-10646-UCS-4")]; - char stringpool_str400[sizeof("IBM850")]; - char stringpool_str406[sizeof("IBM-850")]; - char stringpool_str407[sizeof("ARMSCII-8")]; - char stringpool_str408[sizeof("HP-ROMAN8")]; - char stringpool_str409[sizeof("UTF-16")]; - char stringpool_str411[sizeof("KS_C_5601-1987")]; - char stringpool_str417[sizeof("ISO-10646-UCS-2")]; - char stringpool_str420[sizeof("GB_1988-80")]; - char stringpool_str421[sizeof("CP1133")]; - char stringpool_str422[sizeof("X0208")]; - char stringpool_str423[sizeof("CSEUCKR")]; - char stringpool_str425[sizeof("CSMACINTOSH")]; - char stringpool_str429[sizeof("TIS620.2529-1")]; - char stringpool_str430[sizeof("US-ASCII")]; - char stringpool_str433[sizeof("ISO-IR-203")]; - char stringpool_str434[sizeof("CSKSC56011987")]; - char stringpool_str435[sizeof("UNICODE-1-1")]; - char stringpool_str436[sizeof("CSISOLATINARABIC")]; - char stringpool_str437[sizeof("UTF-8")]; - char stringpool_str438[sizeof("CSISO159JISX02121990")]; - char stringpool_str441[sizeof("GREEK")]; - char stringpool_str442[sizeof("CHINESE")]; - char stringpool_str444[sizeof("CSUNICODE11")]; - char stringpool_str451[sizeof("MS-HEBR")]; - char stringpool_str453[sizeof("UCS-4-INTERNAL")]; - char stringpool_str457[sizeof("GREEK8")]; - char stringpool_str458[sizeof("JIS_C6220-1969-RO")]; - char stringpool_str465[sizeof("SHIFT-JIS")]; - char stringpool_str466[sizeof("SHIFT_JIS")]; - char stringpool_str467[sizeof("LATIN7")]; - char stringpool_str469[sizeof("ISO-IR-57")]; - char stringpool_str471[sizeof("UCS-2-INTERNAL")]; - char stringpool_str474[sizeof("CSISOLATINHEBREW")]; - char stringpool_str475[sizeof("ISO-IR-87")]; - char stringpool_str477[sizeof("ISO-IR-157")]; - char stringpool_str479[sizeof("MS-TURK")]; - char stringpool_str482[sizeof("CSSHIFTJIS")]; - char stringpool_str484[sizeof("CP1257")]; - char stringpool_str487[sizeof("JIS_C6226-1983")]; - char stringpool_str488[sizeof("MACTURKISH")]; - char stringpool_str489[sizeof("CSGB2312")]; - char stringpool_str490[sizeof("ISO_8859-4:1988")]; - char stringpool_str492[sizeof("ISO_8859-5:1988")]; - char stringpool_str493[sizeof("ISO-IR-127")]; - char stringpool_str494[sizeof("ARABIC")]; - char stringpool_str498[sizeof("ISO_8859-8:1988")]; - char stringpool_str500[sizeof("HZ-GB-2312")]; - char stringpool_str502[sizeof("ISO_8859-9:1989")]; - char stringpool_str506[sizeof("MULELAO-1")]; - char stringpool_str507[sizeof("KOI8-U")]; - char stringpool_str511[sizeof("ECMA-114")]; - char stringpool_str513[sizeof("KOI8-RU")]; - char stringpool_str515[sizeof("CSISOLATIN3")]; - char stringpool_str518[sizeof("JIS0208")]; - char stringpool_str519[sizeof("MACROMAN")]; - char stringpool_str523[sizeof("WINDOWS-1256")]; - char stringpool_str524[sizeof("ISO8859-7")]; - char stringpool_str525[sizeof("WINDOWS-1251")]; - char stringpool_str527[sizeof("ECMA-118")]; - char stringpool_str529[sizeof("UCS-4LE")]; - char stringpool_str530[sizeof("ISO-8859-7")]; - char stringpool_str531[sizeof("ISO_8859-7")]; - char stringpool_str532[sizeof("ISO646-JP")]; - char stringpool_str533[sizeof("WINDOWS-1254")]; - char stringpool_str535[sizeof("WINDOWS-1255")]; - char stringpool_str539[sizeof("CSHPROMAN8")]; - char stringpool_str541[sizeof("WINDOWS-1258")]; - char stringpool_str543[sizeof("MACICELAND")]; - char stringpool_str545[sizeof("GB_2312-80")]; - char stringpool_str547[sizeof("UCS-2LE")]; - char stringpool_str548[sizeof("GEORGIAN-PS")]; - char stringpool_str551[sizeof("WINDOWS-1252")]; - char stringpool_str552[sizeof("CSISO57GB1988")]; - char stringpool_str556[sizeof("CSUNICODE")]; - char stringpool_str561[sizeof("CP367")]; - char stringpool_str562[sizeof("GB18030")]; - char stringpool_str565[sizeof("IBM-EUCCN")]; - char stringpool_str569[sizeof("MS-EE")]; - char stringpool_str576[sizeof("JAVA")]; - char stringpool_str577[sizeof("CSISO58GB231280")]; - char stringpool_str578[sizeof("MACCROATIAN")]; - char stringpool_str579[sizeof("IBM-EUCKR")]; - char stringpool_str587[sizeof("EUCTW")]; - char stringpool_str588[sizeof("UTF-32")]; - char stringpool_str593[sizeof("EUC-TW")]; - char stringpool_str594[sizeof("ISO-2022-JP-MS")]; - char stringpool_str595[sizeof("ISO-2022-JP-1")]; - char stringpool_str600[sizeof("GEORGIAN-ACADEMY")]; - char stringpool_str605[sizeof("ISO_8859-3:1988")]; - char stringpool_str608[sizeof("MS-GREEK")]; - char stringpool_str612[sizeof("UNICODELITTLE")]; - char stringpool_str614[sizeof("MACGREEK")]; - char stringpool_str615[sizeof("WINDOWS-1250")]; - char stringpool_str617[sizeof("MS_KANJI")]; - char stringpool_str621[sizeof("ISO-2022-JP-2")]; - char stringpool_str625[sizeof("WINDOWS-936")]; - char stringpool_str626[sizeof("CSISO2022JP2")]; - char stringpool_str631[sizeof("TIS620.2533-1")]; - char stringpool_str632[sizeof("EUCJP")]; - char stringpool_str637[sizeof("CSPC862LATINHEBREW")]; - char stringpool_str638[sizeof("EUC-JP")]; - char stringpool_str639[sizeof("UNICODE-1-1-UTF-7")]; - char stringpool_str646[sizeof("CSUNICODE11UTF7")]; - char stringpool_str648[sizeof("WINDOWS-1253")]; - char stringpool_str650[sizeof("UCS-4BE")]; - char stringpool_str662[sizeof("ISO_8859-6:1987")]; - char stringpool_str664[sizeof("ISO_8859-1:1987")]; - char stringpool_str666[sizeof("BIG5-HKSCS:2001")]; - char stringpool_str667[sizeof("MACARABIC")]; - char stringpool_str668[sizeof("UCS-2BE")]; - char stringpool_str673[sizeof("JOHAB")]; - char stringpool_str674[sizeof("BIG5-HKSCS:2004")]; - char stringpool_str682[sizeof("BIG5-HKSCS:2008")]; - char stringpool_str684[sizeof("BIG5-HKSCS:1999")]; - char stringpool_str685[sizeof("UTF-16LE")]; - char stringpool_str686[sizeof("ASMO-708")]; - char stringpool_str689[sizeof("BIGFIVE")]; - char stringpool_str690[sizeof("ISO_8859-2:1987")]; - char stringpool_str694[sizeof("HEBREW")]; - char stringpool_str695[sizeof("BIG-FIVE")]; - char stringpool_str697[sizeof("JIS_X0212")]; - char stringpool_str701[sizeof("NEXTSTEP")]; - char stringpool_str710[sizeof("ISO-2022-JP")]; - char stringpool_str711[sizeof("IBM367")]; - char stringpool_str714[sizeof("IBM-CP1133")]; - char stringpool_str716[sizeof("CSISO2022JP")]; - char stringpool_str718[sizeof("WINDOWS-874")]; - char stringpool_str720[sizeof("CSPC850MULTILINGUAL")]; - char stringpool_str721[sizeof("TIS620.2533-0")]; - char stringpool_str723[sizeof("WINDOWS-1257")]; - char stringpool_str732[sizeof("ANSI_X3.4-1986")]; - char stringpool_str735[sizeof("JIS_X0201")]; - char stringpool_str747[sizeof("UNICODEBIG")]; - char stringpool_str750[sizeof("ANSI_X3.4-1968")]; - char stringpool_str761[sizeof("MS-ARAB")]; - char stringpool_str767[sizeof("JIS_X0208")]; - char stringpool_str768[sizeof("JISX0201-1976")]; - char stringpool_str778[sizeof("JIS_X0212-1990")]; - char stringpool_str779[sizeof("CSISO87JISX0208")]; - char stringpool_str787[sizeof("ISO_8859-7:2003")]; - char stringpool_str790[sizeof("TCVN5712-1:1993")]; - char stringpool_str801[sizeof("UTF-7")]; - char stringpool_str806[sizeof("UTF-16BE")]; - char stringpool_str807[sizeof("CSHALFWIDTHKATAKANA")]; - char stringpool_str812[sizeof("MACCENTRALEUROPE")]; - char stringpool_str818[sizeof("CSEUCTW")]; - char stringpool_str836[sizeof("UTF-32LE")]; - char stringpool_str849[sizeof("MACROMANIA")]; - char stringpool_str858[sizeof("JIS_X0208-1990")]; - char stringpool_str862[sizeof("ISO_8859-7:1987")]; - char stringpool_str873[sizeof("WINBALTRIM")]; - char stringpool_str878[sizeof("MACUKRAINE")]; - char stringpool_str887[sizeof("EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE")]; - char stringpool_str891[sizeof("JIS_X0208-1983")]; - char stringpool_str900[sizeof("UCS-4-SWAPPED")]; - char stringpool_str908[sizeof("JIS_X0212.1990-0")]; - char stringpool_str918[sizeof("UCS-2-SWAPPED")]; - char stringpool_str957[sizeof("UTF-32BE")]; - char stringpool_str974[sizeof("IBM-EUCTW")]; - char stringpool_str992[sizeof("GB18030:2022")]; - char stringpool_str997[sizeof("MACHEBREW")]; - char stringpool_str1019[sizeof("IBM-EUCJP")]; - char stringpool_str1040[sizeof("GB18030:2005")]; - char stringpool_str1046[sizeof("CSEUCPKDFMTJAPANESE")]; - }; -static const struct stringpool_t stringpool_contents = - { - "L6", - "L1", - "HZ", - "CN", - "SJIS", - "L4", - "L5", - "R8", - "L8", - "866", - "L2", - "VISCII", - "ISO-IR-6", - "CP866", - "TCVN", - "C99", - "ISO-IR-166", - "LATIN6", - "CSVISCII", - "CP154", - "LATIN1", - "CYRILLIC", - "ISO646-CN", - "ISO-IR-14", - "KOI8-R", - "CP1256", - "LATIN4", - "CP1251", - "ISO-IR-165", - "LATIN5", - "862", - "ISO-IR-126", - "CSKOI8R", - "ISO-IR-144", - "CP819", - "LATIN8", - "CP1254", - "ISO-IR-58", - "CP949", - "CP1255", - "CP862", - "ISO-IR-148", - "LATIN-9", - "ISO-IR-149", - "ISO-IR-159", - "ISO-IR-226", - "CP1258", - "LATIN2", - "ISO8859-6", - "ISO-IR-199", - "KOI8-T", - "ISO8859-1", - "ISO-8859-6", - "ISO_8859-6", - "ISO8859-16", - "ISO-8859-1", - "ISO_8859-1", - "ISO8859-11", - "ISO-8859-16", - "ISO_8859-16", - "CP1252", - "L3", - "ISO-8859-11", - "ISO_8859-11", - "ISO8859-4", - "ISO_8859-16:2001", - "ISO8859-5", - "ISO-8859-4", - "ISO_8859-4", - "ISO8859-14", - "ISO-8859-5", - "ISO_8859-5", - "ISO8859-15", - "ISO-8859-14", - "ISO_8859-14", - "ISO8859-8", - "ISO-IR-101", - "ISO-8859-15", - "ISO_8859-15", - "ISO8859-9", - "ISO-8859-8", - "ISO_8859-8", - "GBK", - "ISO-8859-9", - "ISO_8859-9", - "ISO_8859-14:1998", - "CP1361", - "ISO_8859-15:1998", - "CP1131", - "RK1048", - "EUCCN", - "MAC", - "ISO8859-2", - "CP936", - "PT154", - "EUC-CN", - "ISO-8859-2", - "ISO_8859-2", - "KSC_5601", - "EUCKR", - "ISO-IR-109", - "EUC-KR", - "ASCII", - "IBM866", - "MS-CYRL", - "L10", - "KZ-1048", - "CP50221", - "VISCII1.1-1", - "L7", - "CSASCII", - "ISO_646.IRV:1991", - "850", - "CSKZ1048", - "US", - "ISO-IR-138", - "KS_C_5601-1989", - "CP932", - "ISO-CELTIC", - "UHC", - "IBM-921", - "IBM819", - "MACINTOSH", - "MACCYRILLIC", - "CP850", - "ISO-IR-110", - "CP950", - "CYRILLIC-ASIAN", - "ISO-2022-CN", - "LATIN10", - "IBM862", - "CSISO2022CN", - "UCS-4", - "ISO_8859-10:1992", - "CSISOLATIN6", - "CP1250", - "CSISOLATIN1", - "ISO-2022-KR", - "TIS620", - "BIG5", - "CP874", - "CSISO2022KR", - "TIS-620", - "BIG-5", - "ISO646-US", - "ISO-2022-CN-EXT", - "CSUCS4", - "CSISOLATINCYRILLIC", - "CSISOLATIN4", - "ELOT_928", - "CSISOLATIN5", - "CSBIG5", - "IBM-1252", - "CN-BIG5", - "UCS-2", - "ISO-IR-179", - "CN-GB-ISOIR165", - "ISO8859-10", - "LATIN3", - "PTCP154", - "CSISOLATIN2", - "ISO-8859-10", - "ISO_8859-10", - "MS936", - "BIG5HKSCS", - "CSISO14JISC6220RO", - "IBM-1131", - "BIG5-HKSCS", - "CP1253", - "TCVN5712-1", - "ISO-IR-100", - "GB2312", - "CSIBM866", - "X0212", - "TCVN-5712", - "MS-ANSI", - "KOREAN", - "JP", - "CSPTCP154", - "STRK1048-2002", - "ISO8859-3", - "TIS620-0", - "ISO-8859-3", - "ISO_8859-3", - "ISO8859-13", - "ROMAN8", - "CN-GB", - "MACTHAI", - "ISO-8859-13", - "ISO_8859-13", - "X0201", - "IBM-932", - "CSISOLATINGREEK", - "ISO-10646-UCS-4", - "IBM850", - "IBM-850", - "ARMSCII-8", - "HP-ROMAN8", - "UTF-16", - "KS_C_5601-1987", - "ISO-10646-UCS-2", - "GB_1988-80", - "CP1133", - "X0208", - "CSEUCKR", - "CSMACINTOSH", - "TIS620.2529-1", - "US-ASCII", - "ISO-IR-203", - "CSKSC56011987", - "UNICODE-1-1", - "CSISOLATINARABIC", - "UTF-8", - "CSISO159JISX02121990", - "GREEK", - "CHINESE", - "CSUNICODE11", - "MS-HEBR", - "UCS-4-INTERNAL", - "GREEK8", - "JIS_C6220-1969-RO", - "SHIFT-JIS", - "SHIFT_JIS", - "LATIN7", - "ISO-IR-57", - "UCS-2-INTERNAL", - "CSISOLATINHEBREW", - "ISO-IR-87", - "ISO-IR-157", - "MS-TURK", - "CSSHIFTJIS", - "CP1257", - "JIS_C6226-1983", - "MACTURKISH", - "CSGB2312", - "ISO_8859-4:1988", - "ISO_8859-5:1988", - "ISO-IR-127", - "ARABIC", - "ISO_8859-8:1988", - "HZ-GB-2312", - "ISO_8859-9:1989", - "MULELAO-1", - "KOI8-U", - "ECMA-114", - "KOI8-RU", - "CSISOLATIN3", - "JIS0208", - "MACROMAN", - "WINDOWS-1256", - "ISO8859-7", - "WINDOWS-1251", - "ECMA-118", - "UCS-4LE", - "ISO-8859-7", - "ISO_8859-7", - "ISO646-JP", - "WINDOWS-1254", - "WINDOWS-1255", - "CSHPROMAN8", - "WINDOWS-1258", - "MACICELAND", - "GB_2312-80", - "UCS-2LE", - "GEORGIAN-PS", - "WINDOWS-1252", - "CSISO57GB1988", - "CSUNICODE", - "CP367", - "GB18030", - "IBM-EUCCN", - "MS-EE", - "JAVA", - "CSISO58GB231280", - "MACCROATIAN", - "IBM-EUCKR", - "EUCTW", - "UTF-32", - "EUC-TW", - "ISO-2022-JP-MS", - "ISO-2022-JP-1", - "GEORGIAN-ACADEMY", - "ISO_8859-3:1988", - "MS-GREEK", - "UNICODELITTLE", - "MACGREEK", - "WINDOWS-1250", - "MS_KANJI", - "ISO-2022-JP-2", - "WINDOWS-936", - "CSISO2022JP2", - "TIS620.2533-1", - "EUCJP", - "CSPC862LATINHEBREW", - "EUC-JP", - "UNICODE-1-1-UTF-7", - "CSUNICODE11UTF7", - "WINDOWS-1253", - "UCS-4BE", - "ISO_8859-6:1987", - "ISO_8859-1:1987", - "BIG5-HKSCS:2001", - "MACARABIC", - "UCS-2BE", - "JOHAB", - "BIG5-HKSCS:2004", - "BIG5-HKSCS:2008", - "BIG5-HKSCS:1999", - "UTF-16LE", - "ASMO-708", - "BIGFIVE", - "ISO_8859-2:1987", - "HEBREW", - "BIG-FIVE", - "JIS_X0212", - "NEXTSTEP", - "ISO-2022-JP", - "IBM367", - "IBM-CP1133", - "CSISO2022JP", - "WINDOWS-874", - "CSPC850MULTILINGUAL", - "TIS620.2533-0", - "WINDOWS-1257", - "ANSI_X3.4-1986", - "JIS_X0201", - "UNICODEBIG", - "ANSI_X3.4-1968", - "MS-ARAB", - "JIS_X0208", - "JISX0201-1976", - "JIS_X0212-1990", - "CSISO87JISX0208", - "ISO_8859-7:2003", - "TCVN5712-1:1993", - "UTF-7", - "UTF-16BE", - "CSHALFWIDTHKATAKANA", - "MACCENTRALEUROPE", - "CSEUCTW", - "UTF-32LE", - "MACROMANIA", - "JIS_X0208-1990", - "ISO_8859-7:1987", - "WINBALTRIM", - "MACUKRAINE", - "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", - "JIS_X0208-1983", - "UCS-4-SWAPPED", - "JIS_X0212.1990-0", - "UCS-2-SWAPPED", - "UTF-32BE", - "IBM-EUCTW", - "GB18030:2022", - "MACHEBREW", - "IBM-EUCJP", - "GB18030:2005", - "CSEUCPKDFMTJAPANESE" - }; -#define stringpool ((const char *) &stringpool_contents) - -static const struct alias aliases[] = - { - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 134 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str16, ei_iso8859_10}, - {-1}, -#line 60 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str18, ei_iso8859_1}, -#line 341 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str19, ei_hz}, - {-1}, -#line 292 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str21, ei_iso646_cn}, - {-1}, {-1}, {-1}, -#line 312 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str25, ei_sjis}, -#line 84 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str26, ei_iso8859_4}, - {-1}, -#line 126 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str28, ei_iso8859_9}, - {-1}, -#line 231 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str30, ei_hp_roman8}, - {-1}, {-1}, {-1}, -#line 152 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str34, ei_iso8859_14}, - {-1}, -#line 210 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str36, ei_cp866}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 68 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str44, ei_iso8859_2}, - {-1}, {-1}, {-1}, {-1}, -#line 259 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str49, ei_viscii}, - {-1}, -#line 16 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str51, ei_ascii}, - {-1}, {-1}, -#line 208 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str54, ei_cp866}, - {-1}, {-1}, -#line 262 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str57, ei_tcvn}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 51 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str64, ei_c99}, -#line 256 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str65, ei_tis620}, - {-1}, -#line 133 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str67, ei_iso8859_10}, -#line 261 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str68, ei_viscii}, - {-1}, -#line 240 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str70, ei_pt154}, -#line 59 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str71, ei_iso8859_1}, - {-1}, {-1}, {-1}, {-1}, -#line 91 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str76, ei_iso8859_5}, - {-1}, -#line 290 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str78, ei_iso646_cn}, -#line 268 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str79, ei_iso646_jp}, - {-1}, -#line 168 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str81, ei_koi8_r}, - {-1}, {-1}, -#line 191 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str84, ei_cp1256}, - {-1}, {-1}, -#line 83 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str87, ei_iso8859_4}, -#line 175 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str88, ei_cp1251}, -#line 297 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str89, ei_isoir165}, - {-1}, -#line 125 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str91, ei_iso8859_9}, -#line 206 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str92, ei_cp862}, -#line 107 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str93, ei_iso8859_7}, -#line 169 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str94, ei_koi8_r}, -#line 90 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str95, ei_iso8859_5}, -#line 57 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str96, ei_iso8859_1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 151 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str103, ei_iso8859_14}, -#line 185 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str104, ei_cp1254}, -#line 295 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str105, ei_gb2312}, -#line 364 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str106, ei_cp949}, - {-1}, -#line 188 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str108, ei_cp1255}, - {-1}, -#line 204 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str110, ei_cp862}, -#line 124 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str111, ei_iso8859_9}, - {-1}, -#line 159 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str113, ei_iso8859_15}, - {-1}, -#line 302 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str115, ei_ksc5601}, - {-1}, -#line 287 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str117, ei_jisx0212}, - {-1}, -#line 164 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str119, ei_iso8859_16}, -#line 197 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str120, ei_cp1258}, - {-1}, {-1}, -#line 67 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str123, ei_iso8859_2}, -#line 102 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str124, ei_iso8859_6}, -#line 150 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str125, ei_iso8859_14}, - {-1}, -#line 237 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str127, ei_koi8_t}, -#line 62 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str128, ei_iso8859_1}, - {-1}, -#line 94 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str130, ei_iso8859_6}, -#line 95 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str131, ei_iso8859_6}, -#line 167 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str132, ei_iso8859_16}, - {-1}, -#line 53 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str134, ei_iso8859_1}, -#line 54 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str135, ei_iso8859_1}, -#line 139 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str136, ei_iso8859_11}, - {-1}, -#line 161 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str138, ei_iso8859_16}, -#line 162 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str139, ei_iso8859_16}, -#line 178 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str140, ei_cp1252}, -#line 76 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str141, ei_iso8859_3}, -#line 137 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str142, ei_iso8859_11}, -#line 138 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str143, ei_iso8859_11}, -#line 86 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str144, ei_iso8859_4}, - {-1}, -#line 163 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str146, ei_iso8859_16}, - {-1}, -#line 93 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str148, ei_iso8859_5}, - {-1}, -#line 79 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str150, ei_iso8859_4}, -#line 80 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str151, ei_iso8859_4}, -#line 154 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str152, ei_iso8859_14}, - {-1}, -#line 87 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str154, ei_iso8859_5}, -#line 88 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str155, ei_iso8859_5}, -#line 160 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str156, ei_iso8859_15}, - {-1}, -#line 147 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str158, ei_iso8859_14}, -#line 148 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str159, ei_iso8859_14}, -#line 120 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str160, ei_iso8859_8}, -#line 66 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str161, ei_iso8859_2}, -#line 155 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str162, ei_iso8859_15}, -#line 156 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str163, ei_iso8859_15}, -#line 128 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str164, ei_iso8859_9}, - {-1}, -#line 114 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str166, ei_iso8859_8}, -#line 115 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str167, ei_iso8859_8}, - {-1}, -#line 331 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str169, ei_ces_gbk}, -#line 121 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str170, ei_iso8859_9}, -#line 122 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str171, ei_iso8859_9}, -#line 149 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str172, ei_iso8859_14}, -#line 367 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str173, ei_johab}, -#line 157 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str174, ei_iso8859_15}, -#line 212 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str175, ei_cp1131}, -#line 243 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str176, ei_rk1048}, - {-1}, -#line 325 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str178, ei_euc_cn}, -#line 216 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str179, ei_mac_roman}, -#line 70 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str180, ei_iso8859_2}, -#line 332 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str181, ei_cp936}, - {-1}, -#line 238 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str183, ei_pt154}, -#line 324 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str184, ei_euc_cn}, - {-1}, -#line 63 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str186, ei_iso8859_2}, -#line 64 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str187, ei_iso8859_2}, - {-1}, -#line 299 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str189, ei_ksc5601}, - {-1}, {-1}, -#line 361 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str192, ei_euc_kr}, - {-1}, {-1}, {-1}, {-1}, -#line 74 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str197, ei_iso8859_3}, -#line 360 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str198, ei_euc_kr}, -#line 13 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str199, ei_ascii}, - {-1}, {-1}, {-1}, {-1}, -#line 209 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str204, ei_cp866}, -#line 177 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str205, ei_cp1251}, -#line 166 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str206, ei_iso8859_16}, - {-1}, -#line 245 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str208, ei_rk1048}, - {-1}, {-1}, {-1}, -#line 323 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str212, ei_iso2022_jpms}, - {-1}, -#line 260 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str214, ei_viscii}, - {-1}, -#line 144 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str216, ei_iso8859_13}, -#line 22 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str217, ei_ascii}, - {-1}, -#line 15 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str219, ei_ascii}, -#line 201 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str220, ei_cp850}, - {-1}, -#line 246 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str222, ei_rk1048}, - {-1}, {-1}, -#line 21 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str225, ei_ascii}, -#line 117 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str226, ei_iso8859_8}, - {-1}, {-1}, {-1}, {-1}, -#line 301 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str231, ei_ksc5601}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 315 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str237, ei_cp932}, -#line 153 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str238, ei_iso8859_14}, - {-1}, {-1}, {-1}, {-1}, -#line 365 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str243, ei_cp949}, -#line 146 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str244, ei_iso8859_13}, - {-1}, -#line 58 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str246, ei_iso8859_1}, -#line 215 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str247, ei_mac_roman}, - {-1}, -#line 222 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str249, ei_mac_cyrillic}, -#line 199 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str250, ei_cp850}, -#line 82 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str251, ei_iso8859_4}, -#line 353 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str252, ei_cp950}, - {-1}, -#line 241 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str254, ei_pt154}, - {-1}, -#line 338 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str256, ei_iso2022_cn}, - {-1}, {-1}, -#line 165 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str259, ei_iso8859_16}, -#line 205 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str260, ei_cp862}, - {-1}, -#line 339 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str262, ei_iso2022_cn}, -#line 33 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str263, ei_ucs4}, -#line 131 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str264, ei_iso8859_10}, -#line 135 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str265, ei_iso8859_10}, - {-1}, {-1}, -#line 172 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str268, ei_cp1250}, -#line 61 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str269, ei_iso8859_1}, -#line 368 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str270, ei_iso2022_kr}, -#line 251 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str271, ei_tis620}, -#line 347 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str272, ei_ces_big5}, - {-1}, -#line 257 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str274, ei_cp874}, - {-1}, -#line 369 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str276, ei_iso2022_kr}, -#line 250 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str277, ei_tis620}, -#line 348 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str278, ei_ces_big5}, -#line 14 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str279, ei_ascii}, -#line 340 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str280, ei_iso2022_cn_ext}, -#line 35 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str281, ei_ucs4}, - {-1}, {-1}, -#line 92 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str284, ei_iso8859_5}, -#line 85 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str285, ei_iso8859_4}, - {-1}, -#line 109 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str287, ei_iso8859_7}, - {-1}, -#line 127 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str289, ei_iso8859_9}, - {-1}, -#line 352 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str291, ei_ces_big5}, - {-1}, {-1}, {-1}, {-1}, -#line 181 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str296, ei_cp1252}, -#line 351 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str297, ei_ces_big5}, - {-1}, -#line 24 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str299, ei_ucs2}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 142 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str305, ei_iso8859_13}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 298 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str314, ei_isoir165}, - {-1}, -#line 136 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str316, ei_iso8859_10}, -#line 75 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str317, ei_iso8859_3}, - {-1}, {-1}, -#line 239 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str320, ei_pt154}, -#line 69 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str321, ei_iso8859_2}, -#line 129 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str322, ei_iso8859_10}, -#line 130 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str323, ei_iso8859_10}, -#line 333 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str324, ei_cp936}, - {-1}, {-1}, -#line 358 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str327, ei_big5hkscs2008}, -#line 270 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str328, ei_iso646_jp}, - {-1}, {-1}, -#line 213 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str331, ei_cp1131}, - {-1}, -#line 357 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str333, ei_big5hkscs2008}, -#line 182 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str334, ei_cp1253}, - {-1}, -#line 264 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str336, ei_tcvn}, - {-1}, {-1}, {-1}, {-1}, -#line 56 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str341, ei_iso8859_1}, - {-1}, {-1}, {-1}, {-1}, -#line 326 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str346, ei_euc_cn}, -#line 211 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str347, ei_cp866}, - {-1}, {-1}, {-1}, {-1}, -#line 286 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str352, ei_jisx0212}, - {-1}, -#line 263 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str354, ei_tcvn}, - {-1}, -#line 180 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str356, ei_cp1252}, - {-1}, -#line 304 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str358, ei_ksc5601}, -#line 269 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str359, ei_iso646_jp}, - {-1}, -#line 242 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str361, ei_pt154}, - {-1}, {-1}, -#line 244 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str364, ei_rk1048}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 78 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str374, ei_iso8859_3}, -#line 252 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str375, ei_tis620}, - {-1}, {-1}, {-1}, {-1}, -#line 71 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str380, ei_iso8859_3}, -#line 72 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str381, ei_iso8859_3}, -#line 145 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str382, ei_iso8859_13}, - {-1}, -#line 230 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str384, ei_hp_roman8}, -#line 327 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str385, ei_euc_cn}, - {-1}, -#line 228 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str387, ei_mac_thai}, -#line 140 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str388, ei_iso8859_13}, -#line 141 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str389, ei_iso8859_13}, -#line 273 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str390, ei_jisx0201}, - {-1}, {-1}, -#line 316 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str393, ei_cp932}, -#line 112 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str394, ei_iso8859_7}, - {-1}, {-1}, {-1}, {-1}, -#line 34 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str399, ei_ucs4}, -#line 200 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str400, ei_cp850}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 203 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str406, ei_cp850}, -#line 234 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str407, ei_armscii_8}, -#line 229 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str408, ei_hp_roman8}, -#line 38 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str409, ei_utf16}, - {-1}, -#line 300 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str411, ei_ksc5601}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 25 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str417, ei_ucs2}, - {-1}, {-1}, -#line 289 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str420, ei_iso646_cn}, -#line 248 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str421, ei_cp1133}, -#line 279 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str422, ei_jisx0208}, -#line 362 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str423, ei_euc_kr}, - {-1}, -#line 217 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str425, ei_mac_roman}, - {-1}, {-1}, {-1}, -#line 253 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str429, ei_tis620}, -#line 12 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str430, ei_ascii}, - {-1}, {-1}, -#line 158 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str433, ei_iso8859_15}, -#line 303 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str434, ei_ksc5601}, -#line 29 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str435, ei_ucs2be}, -#line 101 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str436, ei_iso8859_6}, -#line 23 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str437, ei_utf8}, -#line 288 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str438, ei_jisx0212}, - {-1}, {-1}, -#line 111 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str441, ei_iso8859_7}, -#line 329 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str442, ei_euc_cn}, - {-1}, -#line 30 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str444, ei_ucs2be}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 190 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str451, ei_cp1255}, - {-1}, -#line 49 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str453, ei_ucs4internal}, - {-1}, {-1}, {-1}, -#line 110 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str457, ei_iso8859_7}, -#line 266 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str458, ei_iso646_jp}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 311 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str465, ei_sjis}, -#line 310 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str466, ei_sjis}, -#line 143 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str467, ei_iso8859_13}, - {-1}, -#line 291 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str469, ei_iso646_cn}, - {-1}, -#line 47 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str471, ei_ucs2internal}, - {-1}, {-1}, -#line 119 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str474, ei_iso8859_8}, -#line 280 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str475, ei_jisx0208}, - {-1}, -#line 132 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str477, ei_iso8859_10}, - {-1}, -#line 187 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str479, ei_cp1254}, - {-1}, {-1}, -#line 314 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str482, ei_sjis}, - {-1}, -#line 194 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str484, ei_cp1257}, - {-1}, {-1}, -#line 281 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str487, ei_jisx0208}, -#line 225 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str488, ei_mac_turkish}, -#line 328 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str489, ei_euc_cn}, -#line 81 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str490, ei_iso8859_4}, - {-1}, -#line 89 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str492, ei_iso8859_5}, -#line 97 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str493, ei_iso8859_6}, -#line 100 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str494, ei_iso8859_6}, - {-1}, {-1}, {-1}, -#line 116 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str498, ei_iso8859_8}, - {-1}, -#line 342 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str500, ei_hz}, - {-1}, -#line 123 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str502, ei_iso8859_9}, - {-1}, {-1}, {-1}, -#line 247 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str506, ei_mulelao}, -#line 170 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str507, ei_koi8_u}, - {-1}, {-1}, {-1}, -#line 98 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str511, ei_iso8859_6}, - {-1}, -#line 171 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str513, ei_koi8_ru}, - {-1}, -#line 77 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str515, ei_iso8859_3}, - {-1}, {-1}, -#line 278 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str518, ei_jisx0208}, -#line 214 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str519, ei_mac_roman}, - {-1}, {-1}, {-1}, -#line 192 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str523, ei_cp1256}, -#line 113 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str524, ei_iso8859_7}, -#line 176 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str525, ei_cp1251}, - {-1}, -#line 108 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str527, ei_iso8859_7}, - {-1}, -#line 37 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str529, ei_ucs4le}, -#line 103 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str530, ei_iso8859_7}, -#line 104 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str531, ei_iso8859_7}, -#line 267 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str532, ei_iso646_jp}, -#line 186 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str533, ei_cp1254}, - {-1}, -#line 189 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str535, ei_cp1255}, - {-1}, {-1}, {-1}, -#line 232 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str539, ei_hp_roman8}, - {-1}, -#line 198 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str541, ei_cp1258}, - {-1}, -#line 219 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str543, ei_mac_iceland}, - {-1}, -#line 294 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str545, ei_gb2312}, - {-1}, -#line 31 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str547, ei_ucs2le}, -#line 236 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str548, ei_georgian_ps}, - {-1}, {-1}, -#line 179 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str551, ei_cp1252}, -#line 293 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str552, ei_iso646_cn}, - {-1}, {-1}, {-1}, -#line 26 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str556, ei_ucs2}, - {-1}, {-1}, {-1}, {-1}, -#line 19 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str561, ei_ascii}, -#line 335 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str562, ei_gb18030_2005}, - {-1}, {-1}, -#line 330 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str565, ei_euc_cn}, - {-1}, {-1}, {-1}, -#line 174 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str569, ei_cp1250}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 52 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str576, ei_java}, -#line 296 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str577, ei_gb2312}, -#line 220 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str578, ei_mac_croatian}, -#line 363 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str579, ei_euc_kr}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 344 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str587, ei_euc_tw}, -#line 41 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str588, ei_utf32}, - {-1}, {-1}, {-1}, {-1}, -#line 343 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str593, ei_euc_tw}, -#line 322 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str594, ei_iso2022_jpms}, -#line 319 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str595, ei_iso2022_jp1}, - {-1}, {-1}, {-1}, {-1}, -#line 235 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str600, ei_georgian_academy}, - {-1}, {-1}, {-1}, {-1}, -#line 73 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str605, ei_iso8859_3}, - {-1}, {-1}, -#line 184 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str608, ei_cp1253}, - {-1}, {-1}, {-1}, -#line 32 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str612, ei_ucs2le}, - {-1}, -#line 224 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str614, ei_mac_greek}, -#line 173 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str615, ei_cp1250}, - {-1}, -#line 313 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str617, ei_sjis}, - {-1}, {-1}, {-1}, -#line 320 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str621, ei_iso2022_jp2}, - {-1}, {-1}, {-1}, -#line 334 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str625, ei_cp936}, -#line 321 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str626, ei_iso2022_jp2}, - {-1}, {-1}, {-1}, {-1}, -#line 255 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str631, ei_tis620}, -#line 306 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str632, ei_euc_jp}, - {-1}, {-1}, {-1}, {-1}, -#line 207 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str637, ei_cp862}, -#line 305 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str638, ei_euc_jp}, -#line 45 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str639, ei_utf7}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 46 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str646, ei_utf7}, - {-1}, -#line 183 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str648, ei_cp1253}, - {-1}, -#line 36 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str650, ei_ucs4be}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, -#line 96 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str662, ei_iso8859_6}, - {-1}, -#line 55 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str664, ei_iso8859_1}, - {-1}, -#line 355 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str666, ei_big5hkscs2001}, -#line 227 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str667, ei_mac_arabic}, -#line 27 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str668, ei_ucs2be}, - {-1}, {-1}, {-1}, {-1}, -#line 366 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str673, ei_johab}, -#line 356 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str674, ei_big5hkscs2004}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 359 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str682, ei_big5hkscs2008}, - {-1}, -#line 354 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str684, ei_big5hkscs1999}, -#line 40 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str685, ei_utf16le}, -#line 99 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str686, ei_iso8859_6}, - {-1}, {-1}, -#line 350 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str689, ei_ces_big5}, -#line 65 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str690, ei_iso8859_2}, - {-1}, {-1}, {-1}, -#line 118 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str694, ei_iso8859_8}, -#line 349 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str695, ei_ces_big5}, - {-1}, -#line 283 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str697, ei_jisx0212}, - {-1}, {-1}, {-1}, -#line 233 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str701, ei_nextstep}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 317 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str710, ei_iso2022_jp}, -#line 20 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str711, ei_ascii}, - {-1}, {-1}, -#line 249 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str714, ei_cp1133}, - {-1}, -#line 318 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str716, ei_iso2022_jp}, - {-1}, -#line 258 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str718, ei_cp874}, - {-1}, -#line 202 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str720, ei_cp850}, -#line 254 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str721, ei_tis620}, - {-1}, -#line 195 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str723, ei_cp1257}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 18 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str732, ei_ascii}, - {-1}, {-1}, -#line 271 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str735, ei_jisx0201}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, -#line 28 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str747, ei_ucs2be}, - {-1}, {-1}, -#line 17 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str750, ei_ascii}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, -#line 193 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str761, ei_cp1256}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 275 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str767, ei_jisx0208}, -#line 272 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str768, ei_jisx0201}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 285 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str778, ei_jisx0212}, -#line 282 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str779, ei_jisx0208}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 106 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str787, ei_iso8859_7}, - {-1}, {-1}, -#line 265 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str790, ei_tcvn}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, -#line 44 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str801, ei_utf7}, - {-1}, {-1}, {-1}, {-1}, -#line 39 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str806, ei_utf16be}, -#line 274 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str807, ei_jisx0201}, - {-1}, {-1}, {-1}, {-1}, -#line 218 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str812, ei_mac_centraleurope}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 345 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str818, ei_euc_tw}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 43 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str836, ei_utf32le}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, -#line 221 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str849, ei_mac_romania}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 277 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str858, ei_jisx0208}, - {-1}, {-1}, {-1}, -#line 105 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str862, ei_iso8859_7}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, -#line 196 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str873, ei_cp1257}, - {-1}, {-1}, {-1}, {-1}, -#line 223 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str878, ei_mac_ukraine}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 307 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str887, ei_euc_jp}, - {-1}, {-1}, {-1}, -#line 276 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str891, ei_jisx0208}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 50 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str900, ei_ucs4swapped}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 284 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str908, ei_jisx0212}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 48 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str918, ei_ucs2swapped}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, -#line 42 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str957, ei_utf32be}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 346 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str974, ei_euc_tw}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 337 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str992, ei_gb18030_2022}, - {-1}, {-1}, {-1}, {-1}, -#line 226 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str997, ei_mac_hebrew}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, -#line 309 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1019, ei_euc_jp}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, -#line 336 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1040, ei_gb18030_2005}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 308 "lib/generated/aliases_sysaix.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1046, ei_euc_jp} - }; - -const struct alias * -HashPool::aliases_lookup (const char *str, size_t len) -{ - if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) - { - unsigned int key = aliases_hash (str, len); - - if (key <= MAX_HASH_VALUE) - { - int o = aliases[key].name; - if (o >= 0) - { - const char *s = o + stringpool; - - if (*str == *s && !strcmp (str + 1, s + 1)) - return &aliases[key]; - } - } - } - return 0; -} diff --git a/lib/generated/aliases_syshpux.h b/lib/generated/aliases_syshpux.h deleted file mode 100644 index d4eafe5a..00000000 --- a/lib/generated/aliases_syshpux.h +++ /dev/null @@ -1,1791 +0,0 @@ -/* C++ code produced by gperf version 3.1 */ -/* Command-line: gperf -L C++ -Z HashPool -m 10 lib/generated/aliases_syshpux.gperf */ -/* Computed positions: -k'1,3-11,$' */ - -#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ - && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ - && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ - && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ - && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ - && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ - && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ - && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ - && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ - && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ - && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ - && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ - && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ - && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ - && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ - && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ - && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ - && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ - && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ - && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ - && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ - && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ - && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) -/* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." -#endif - -#line 1 "lib/generated/aliases_syshpux.gperf" -struct alias { int name; unsigned int encoding_index; }; - -#define TOTAL_KEYWORDS 359 -#define MIN_WORD_LENGTH 2 -#define MAX_WORD_LENGTH 45 -#define MIN_HASH_VALUE 23 -#define MAX_HASH_VALUE 1164 -/* maximum key range = 1142, duplicates = 0 */ - -class HashPool -{ -private: - static inline unsigned int aliases_hash (const char *str, size_t len); -public: - static const struct alias *aliases_lookup (const char *str, size_t len); -}; - -inline unsigned int -HashPool::aliases_hash (const char *str, size_t len) -{ - static const unsigned short asso_values[] = - { - 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, - 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, - 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, - 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, - 1165, 1165, 1165, 1165, 1165, 5, 126, 1165, 39, 7, - 37, 146, 20, 18, 5, 90, 29, 33, 300, 1165, - 1165, 1165, 1165, 1165, 1165, 11, 217, 14, 10, 121, - 118, 18, 108, 5, 191, 161, 208, 218, 7, 5, - 153, 1165, 5, 50, 14, 201, 236, 149, 148, 8, - 9, 1165, 1165, 1165, 1165, 6, 1165, 1165, 1165, 1165, - 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, - 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, - 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165 - }; - unsigned int hval = len; - - switch (hval) - { - default: - hval += asso_values[static_cast(str[10])]; - /*FALLTHROUGH*/ - case 10: - hval += asso_values[static_cast(str[9])]; - /*FALLTHROUGH*/ - case 9: - hval += asso_values[static_cast(str[8])]; - /*FALLTHROUGH*/ - case 8: - hval += asso_values[static_cast(str[7])]; - /*FALLTHROUGH*/ - case 7: - hval += asso_values[static_cast(str[6])]; - /*FALLTHROUGH*/ - case 6: - hval += asso_values[static_cast(str[5])]; - /*FALLTHROUGH*/ - case 5: - hval += asso_values[static_cast(str[4])]; - /*FALLTHROUGH*/ - case 4: - hval += asso_values[static_cast(str[3])]; - /*FALLTHROUGH*/ - case 3: - hval += asso_values[static_cast(str[2])]; - /*FALLTHROUGH*/ - case 2: - case 1: - hval += asso_values[static_cast(str[0])]; - break; - } - return hval + asso_values[static_cast(str[len - 1])]; -} - -struct stringpool_t - { - char stringpool_str23[sizeof("CN")]; - char stringpool_str36[sizeof("R8")]; - char stringpool_str42[sizeof("866")]; - char stringpool_str45[sizeof("ASCII")]; - char stringpool_str48[sizeof("ISO-IR-6")]; - char stringpool_str62[sizeof("ISO-IR-166")]; - char stringpool_str63[sizeof("CP866")]; - char stringpool_str82[sizeof("ISO646-CN")]; - char stringpool_str83[sizeof("C99")]; - char stringpool_str84[sizeof("CP154")]; - char stringpool_str86[sizeof("ISO-IR-14")]; - char stringpool_str88[sizeof("ISO-IR-165")]; - char stringpool_str92[sizeof("CP1256")]; - char stringpool_str94[sizeof("ISO-IR-126")]; - char stringpool_str96[sizeof("CP1251")]; - char stringpool_str100[sizeof("ISO-IR-101")]; - char stringpool_str106[sizeof("862")]; - char stringpool_str107[sizeof("ISO-IR-144")]; - char stringpool_str110[sizeof("850")]; - char stringpool_str111[sizeof("CSASCII")]; - char stringpool_str115[sizeof("ISO-IR-58")]; - char stringpool_str118[sizeof("CP1255")]; - char stringpool_str119[sizeof("HZ")]; - char stringpool_str121[sizeof("CP819")]; - char stringpool_str122[sizeof("CP1254")]; - char stringpool_str123[sizeof("GEORGIAN-ACADEMY")]; - char stringpool_str124[sizeof("ISO-IR-226")]; - char stringpool_str125[sizeof("ISO-IR-148")]; - char stringpool_str127[sizeof("CP862")]; - char stringpool_str131[sizeof("ISO-IR-159")]; - char stringpool_str132[sizeof("ISO-IR-110")]; - char stringpool_str133[sizeof("ISO-IR-149")]; - char stringpool_str135[sizeof("RK1048")]; - char stringpool_str137[sizeof("ISO88596")]; - char stringpool_str138[sizeof("CP949")]; - char stringpool_str140[sizeof("CP1258")]; - char stringpool_str141[sizeof("ISO88591")]; - char stringpool_str143[sizeof("ISO8859-6")]; - char stringpool_str144[sizeof("CP850")]; - char stringpool_str146[sizeof("ISO-IR-199")]; - char stringpool_str147[sizeof("ISO8859-1")]; - char stringpool_str148[sizeof("CP950")]; - char stringpool_str149[sizeof("ISO-8859-6")]; - char stringpool_str150[sizeof("ISO_8859-6")]; - char stringpool_str151[sizeof("ISO8859-16")]; - char stringpool_str152[sizeof("ISO-IR-109")]; - char stringpool_str153[sizeof("ISO-8859-1")]; - char stringpool_str154[sizeof("ISO_8859-1")]; - char stringpool_str155[sizeof("ISO8859-11")]; - char stringpool_str156[sizeof("CP1252")]; - char stringpool_str157[sizeof("ISO-8859-16")]; - char stringpool_str158[sizeof("ISO_8859-16")]; - char stringpool_str159[sizeof("SJIS")]; - char stringpool_str160[sizeof("CP1250")]; - char stringpool_str161[sizeof("ISO-8859-11")]; - char stringpool_str162[sizeof("ISO_8859-11")]; - char stringpool_str163[sizeof("ISO88595")]; - char stringpool_str164[sizeof("ISO-IR-100")]; - char stringpool_str165[sizeof("ISO_8859-16:2001")]; - char stringpool_str166[sizeof("CP50221")]; - char stringpool_str167[sizeof("HP15CN")]; - char stringpool_str168[sizeof("EUCCN")]; - char stringpool_str169[sizeof("ISO8859-5")]; - char stringpool_str171[sizeof("ISO885915")]; - char stringpool_str173[sizeof("ISO8859-4")]; - char stringpool_str174[sizeof("EUC-CN")]; - char stringpool_str175[sizeof("ISO-8859-5")]; - char stringpool_str176[sizeof("ISO_8859-5")]; - char stringpool_str177[sizeof("ISO8859-15")]; - char stringpool_str178[sizeof("CP874")]; - char stringpool_str179[sizeof("ISO-8859-4")]; - char stringpool_str180[sizeof("ISO_8859-4")]; - char stringpool_str181[sizeof("ISO8859-14")]; - char stringpool_str183[sizeof("ISO-8859-15")]; - char stringpool_str184[sizeof("ISO_8859-15")]; - char stringpool_str185[sizeof("ISO88598")]; - char stringpool_str187[sizeof("ISO-8859-14")]; - char stringpool_str188[sizeof("ISO_8859-14")]; - char stringpool_str190[sizeof("TIS620")]; - char stringpool_str191[sizeof("ISO8859-8")]; - char stringpool_str192[sizeof("CP1361")]; - char stringpool_str193[sizeof("ISO88599")]; - char stringpool_str194[sizeof("CP1131")]; - char stringpool_str196[sizeof("TIS-620")]; - char stringpool_str197[sizeof("ISO-8859-8")]; - char stringpool_str198[sizeof("ISO_8859-8")]; - char stringpool_str199[sizeof("ISO8859-9")]; - char stringpool_str200[sizeof("ISO_8859-15:1998")]; - char stringpool_str201[sizeof("ISO88592")]; - char stringpool_str202[sizeof("ISO_8859-14:1998")]; - char stringpool_str203[sizeof("ISO-IR-179")]; - char stringpool_str205[sizeof("ISO-8859-9")]; - char stringpool_str206[sizeof("ISO_8859-9")]; - char stringpool_str207[sizeof("ISO8859-2")]; - char stringpool_str208[sizeof("CP936")]; - char stringpool_str209[sizeof("ISO-2022-CN")]; - char stringpool_str213[sizeof("ISO-8859-2")]; - char stringpool_str214[sizeof("ISO_8859-2")]; - char stringpool_str215[sizeof("L6")]; - char stringpool_str216[sizeof("KOI8-R")]; - char stringpool_str217[sizeof("L1")]; - char stringpool_str219[sizeof("ISO8859-10")]; - char stringpool_str220[sizeof("ISO-2022-CN-EXT")]; - char stringpool_str223[sizeof("PT154")]; - char stringpool_str225[sizeof("ISO-8859-10")]; - char stringpool_str226[sizeof("ISO_8859-10")]; - char stringpool_str228[sizeof("L5")]; - char stringpool_str229[sizeof("ISO_8859-10:1992")]; - char stringpool_str230[sizeof("L4")]; - char stringpool_str231[sizeof("CSKOI8R")]; - char stringpool_str232[sizeof("UHC")]; - char stringpool_str234[sizeof("KOI8-T")]; - char stringpool_str236[sizeof("TIS620-0")]; - char stringpool_str237[sizeof("ISO-IR-57")]; - char stringpool_str239[sizeof("L8")]; - char stringpool_str243[sizeof("X0201")]; - char stringpool_str244[sizeof("GB_1988-80")]; - char stringpool_str245[sizeof("ISO-IR-157")]; - char stringpool_str247[sizeof("L2")]; - char stringpool_str248[sizeof("ISO-IR-87")]; - char stringpool_str249[sizeof("MAC")]; - char stringpool_str250[sizeof("LATIN6")]; - char stringpool_str251[sizeof("ISO-IR-138")]; - char stringpool_str253[sizeof("US")]; - char stringpool_str254[sizeof("LATIN1")]; - char stringpool_str262[sizeof("CP1257")]; - char stringpool_str263[sizeof("CSISO2022CN")]; - char stringpool_str264[sizeof("ISO-IR-127")]; - char stringpool_str265[sizeof("KSC_5601")]; - char stringpool_str268[sizeof("TCVN")]; - char stringpool_str271[sizeof("X0212")]; - char stringpool_str272[sizeof("CP932")]; - char stringpool_str273[sizeof("IBM866")]; - char stringpool_str275[sizeof("BIG5")]; - char stringpool_str276[sizeof("LATIN5")]; - char stringpool_str278[sizeof("ARABIC")]; - char stringpool_str280[sizeof("LATIN4")]; - char stringpool_str281[sizeof("BIG-5")]; - char stringpool_str282[sizeof("ELOT_928")]; - char stringpool_str287[sizeof("X0208")]; - char stringpool_str288[sizeof("GB2312")]; - char stringpool_str289[sizeof("L10")]; - char stringpool_str296[sizeof("CSBIG5")]; - char stringpool_str297[sizeof("KZ-1048")]; - char stringpool_str298[sizeof("LATIN8")]; - char stringpool_str300[sizeof("L7")]; - char stringpool_str301[sizeof("UCS-4")]; - char stringpool_str302[sizeof("CN-BIG5")]; - char stringpool_str304[sizeof("US-ASCII")]; - char stringpool_str305[sizeof("ROMAN8")]; - char stringpool_str307[sizeof("ISO88597")]; - char stringpool_str308[sizeof("MS-ANSI")]; - char stringpool_str311[sizeof("EUCKR")]; - char stringpool_str312[sizeof("LATIN-9")]; - char stringpool_str313[sizeof("ISO8859-7")]; - char stringpool_str314[sizeof("LATIN2")]; - char stringpool_str315[sizeof("KS_C_5601-1989")]; - char stringpool_str316[sizeof("CSKZ1048")]; - char stringpool_str317[sizeof("EUC-KR")]; - char stringpool_str318[sizeof("KOREAN")]; - char stringpool_str319[sizeof("ISO-8859-7")]; - char stringpool_str320[sizeof("ISO_8859-7")]; - char stringpool_str321[sizeof("VISCII")]; - char stringpool_str322[sizeof("MACCROATIAN")]; - char stringpool_str324[sizeof("GB18030")]; - char stringpool_str325[sizeof("CSUCS4")]; - char stringpool_str326[sizeof("LATIN10")]; - char stringpool_str331[sizeof("IBM819")]; - char stringpool_str332[sizeof("ISO-10646-UCS-4")]; - char stringpool_str335[sizeof("UCS-2")]; - char stringpool_str337[sizeof("IBM862")]; - char stringpool_str338[sizeof("GEORGIAN-PS")]; - char stringpool_str340[sizeof("CSISOLATIN6")]; - char stringpool_str342[sizeof("CSVISCII")]; - char stringpool_str343[sizeof("GBK")]; - char stringpool_str344[sizeof("CSISOLATIN1")]; - char stringpool_str346[sizeof("JP")]; - char stringpool_str347[sizeof("UTF-16")]; - char stringpool_str349[sizeof("ISO-10646-UCS-2")]; - char stringpool_str350[sizeof("CP367")]; - char stringpool_str352[sizeof("ISO-2022-KR")]; - char stringpool_str354[sizeof("IBM850")]; - char stringpool_str355[sizeof("ISO646-US")]; - char stringpool_str356[sizeof("L3")]; - char stringpool_str360[sizeof("CSISOLATINARABIC")]; - char stringpool_str361[sizeof("CN-GB-ISOIR165")]; - char stringpool_str365[sizeof("CSISOLATINCYRILLIC")]; - char stringpool_str366[sizeof("CSISOLATIN5")]; - char stringpool_str370[sizeof("CSISOLATIN4")]; - char stringpool_str372[sizeof("KS_C_5601-1987")]; - char stringpool_str373[sizeof("GB_2312-80")]; - char stringpool_str374[sizeof("CP1253")]; - char stringpool_str375[sizeof("ARMSCII-8")]; - char stringpool_str381[sizeof("UTF8")]; - char stringpool_str382[sizeof("MACTHAI")]; - char stringpool_str383[sizeof("CSISO14JISC6220RO")]; - char stringpool_str387[sizeof("UTF-8")]; - char stringpool_str392[sizeof("PTCP154")]; - char stringpool_str398[sizeof("UNICODE-1-1")]; - char stringpool_str404[sizeof("CSISOLATIN2")]; - char stringpool_str406[sizeof("CSISO2022KR")]; - char stringpool_str408[sizeof("ISO-IR-203")]; - char stringpool_str409[sizeof("CSUNICODE11")]; - char stringpool_str412[sizeof("MS936")]; - char stringpool_str413[sizeof("JIS_C6220-1969-RO")]; - char stringpool_str415[sizeof("ISO-CELTIC")]; - char stringpool_str416[sizeof("TIS620.2529-1")]; - char stringpool_str417[sizeof("ECMA-114")]; - char stringpool_str420[sizeof("LATIN7")]; - char stringpool_str421[sizeof("JIS0208")]; - char stringpool_str422[sizeof("CSPTCP154")]; - char stringpool_str425[sizeof("ISO8859-3")]; - char stringpool_str426[sizeof("HP-ROMAN8")]; - char stringpool_str431[sizeof("ISO-8859-3")]; - char stringpool_str432[sizeof("ISO_8859-3")]; - char stringpool_str433[sizeof("ISO8859-13")]; - char stringpool_str434[sizeof("ASMO-708")]; - char stringpool_str435[sizeof("ECMA-118")]; - char stringpool_str437[sizeof("CSISO159JISX02121990")]; - char stringpool_str438[sizeof("TCVN5712-1")]; - char stringpool_str439[sizeof("ISO-8859-13")]; - char stringpool_str440[sizeof("ISO_8859-13")]; - char stringpool_str441[sizeof("ISO_646.IRV:1991")]; - char stringpool_str442[sizeof("STRK1048-2002")]; - char stringpool_str446[sizeof("CHINESE")]; - char stringpool_str451[sizeof("CSKSC56011987")]; - char stringpool_str452[sizeof("EUCTW")]; - char stringpool_str453[sizeof("JAVA")]; - char stringpool_str454[sizeof("WINDOWS-1256")]; - char stringpool_str456[sizeof("WINDOWS-1251")]; - char stringpool_str458[sizeof("EUC-TW")]; - char stringpool_str460[sizeof("TCVN-5712")]; - char stringpool_str467[sizeof("WINDOWS-1255")]; - char stringpool_str469[sizeof("WINDOWS-1254")]; - char stringpool_str472[sizeof("CP1133")]; - char stringpool_str476[sizeof("CN-GB")]; - char stringpool_str478[sizeof("WINDOWS-1258")]; - char stringpool_str480[sizeof("VISCII1.1-1")]; - char stringpool_str481[sizeof("CYRILLIC")]; - char stringpool_str485[sizeof("GREEK8")]; - char stringpool_str486[sizeof("WINDOWS-1252")]; - char stringpool_str487[sizeof("UNICODE-1-1-UTF-7")]; - char stringpool_str488[sizeof("WINDOWS-1250")]; - char stringpool_str492[sizeof("ISO_8859-5:1988")]; - char stringpool_str493[sizeof("MACROMAN")]; - char stringpool_str494[sizeof("ISO_8859-4:1988")]; - char stringpool_str496[sizeof("CSUNICODE11UTF7")]; - char stringpool_str497[sizeof("SHIFT-JIS")]; - char stringpool_str498[sizeof("SHIFT_JIS")]; - char stringpool_str499[sizeof("CSISO57GB1988")]; - char stringpool_str503[sizeof("ISO_8859-8:1988")]; - char stringpool_str506[sizeof("CSIBM866")]; - char stringpool_str507[sizeof("CSUNICODE")]; - char stringpool_str509[sizeof("UTF-7")]; - char stringpool_str511[sizeof("ISO_8859-9:1989")]; - char stringpool_str513[sizeof("CSISOLATINGREEK")]; - char stringpool_str515[sizeof("MACROMANIA")]; - char stringpool_str517[sizeof("JIS_C6226-1983")]; - char stringpool_str518[sizeof("MACARABIC")]; - char stringpool_str521[sizeof("CSGB2312")]; - char stringpool_str528[sizeof("CSEUCKR")]; - char stringpool_str532[sizeof("LATIN3")]; - char stringpool_str533[sizeof("JIS_X0201")]; - char stringpool_str534[sizeof("ISO-2022-JP-1")]; - char stringpool_str538[sizeof("MACINTOSH")]; - char stringpool_str539[sizeof("WINDOWS-1257")]; - char stringpool_str540[sizeof("ISO_8859-6:1987")]; - char stringpool_str542[sizeof("ISO_8859-1:1987")]; - char stringpool_str543[sizeof("ANSI_X3.4-1986")]; - char stringpool_str545[sizeof("WINDOWS-874")]; - char stringpool_str546[sizeof("CYRILLIC-ASIAN")]; - char stringpool_str550[sizeof("UTF-32")]; - char stringpool_str551[sizeof("ISO646-JP")]; - char stringpool_str560[sizeof("IBM367")]; - char stringpool_str561[sizeof("JIS_X0212")]; - char stringpool_str564[sizeof("ISO-2022-JP-2")]; - char stringpool_str565[sizeof("CSMACINTOSH")]; - char stringpool_str567[sizeof("ANSI_X3.4-1968")]; - char stringpool_str572[sizeof("ISO_8859-2:1987")]; - char stringpool_str574[sizeof("JISX0201-1976")]; - char stringpool_str575[sizeof("WINDOWS-936")]; - char stringpool_str577[sizeof("JIS_X0208")]; - char stringpool_str578[sizeof("ISO-2022-JP-MS")]; - char stringpool_str580[sizeof("JIS_X0212-1990")]; - char stringpool_str587[sizeof("GREEK")]; - char stringpool_str589[sizeof("CSHPROMAN8")]; - char stringpool_str591[sizeof("MS-EE")]; - char stringpool_str592[sizeof("CSISOLATINHEBREW")]; - char stringpool_str593[sizeof("CSISO58GB231280")]; - char stringpool_str595[sizeof("WINDOWS-1253")]; - char stringpool_str604[sizeof("JIS_X0208-1990")]; - char stringpool_str608[sizeof("KOI8-U")]; - char stringpool_str612[sizeof("MS_KANJI")]; - char stringpool_str614[sizeof("KOI8-RU")]; - char stringpool_str615[sizeof("CSSHIFTJIS")]; - char stringpool_str617[sizeof("CSISO2022JP2")]; - char stringpool_str620[sizeof("ISO_8859-3:1988")]; - char stringpool_str622[sizeof("CSISOLATIN3")]; - char stringpool_str624[sizeof("UNICODEBIG")]; - char stringpool_str625[sizeof("ISO_8859-7:1987")]; - char stringpool_str627[sizeof("HZ-GB-2312")]; - char stringpool_str628[sizeof("MACICELAND")]; - char stringpool_str631[sizeof("CSISO87JISX0208")]; - char stringpool_str637[sizeof("EUCJP")]; - char stringpool_str638[sizeof("TIS620.2533-1")]; - char stringpool_str643[sizeof("EUC-JP")]; - char stringpool_str655[sizeof("UCS-4-INTERNAL")]; - char stringpool_str657[sizeof("CSPC862LATINHEBREW")]; - char stringpool_str668[sizeof("NEXTSTEP")]; - char stringpool_str669[sizeof("CSEUCTW")]; - char stringpool_str670[sizeof("TIS620.2533-0")]; - char stringpool_str672[sizeof("UCS-2-INTERNAL")]; - char stringpool_str673[sizeof("MS-CYRL")]; - char stringpool_str678[sizeof("ISO-2022-JP")]; - char stringpool_str681[sizeof("ISO_8859-7:2003")]; - char stringpool_str686[sizeof("MS-HEBR")]; - char stringpool_str691[sizeof("MS-ARAB")]; - char stringpool_str695[sizeof("BIG5HKSCS")]; - char stringpool_str701[sizeof("BIG5-HKSCS")]; - char stringpool_str703[sizeof("JIS_X0212.1990-0")]; - char stringpool_str711[sizeof("JIS_X0208-1983")]; - char stringpool_str723[sizeof("GB18030:2005")]; - char stringpool_str724[sizeof("MACCYRILLIC")]; - char stringpool_str731[sizeof("UNICODELITTLE")]; - char stringpool_str732[sizeof("CSISO2022JP")]; - char stringpool_str733[sizeof("UCS-4LE")]; - char stringpool_str740[sizeof("GB18030:2022")]; - char stringpool_str742[sizeof("UCS-4BE")]; - char stringpool_str749[sizeof("JOHAB")]; - char stringpool_str750[sizeof("UCS-2LE")]; - char stringpool_str755[sizeof("HEBREW")]; - char stringpool_str759[sizeof("UCS-2BE")]; - char stringpool_str772[sizeof("MS-TURK")]; - char stringpool_str775[sizeof("CSHALFWIDTHKATAKANA")]; - char stringpool_str784[sizeof("EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE")]; - char stringpool_str794[sizeof("UTF-16LE")]; - char stringpool_str799[sizeof("MULELAO-1")]; - char stringpool_str803[sizeof("UTF-16BE")]; - char stringpool_str818[sizeof("MS-GREEK")]; - char stringpool_str820[sizeof("UCS-4-SWAPPED")]; - char stringpool_str827[sizeof("MACGREEK")]; - char stringpool_str837[sizeof("UCS-2-SWAPPED")]; - char stringpool_str843[sizeof("BIGFIVE")]; - char stringpool_str849[sizeof("BIG-FIVE")]; - char stringpool_str857[sizeof("IBM-CP1133")]; - char stringpool_str870[sizeof("MACCENTRALEUROPE")]; - char stringpool_str874[sizeof("MACUKRAINE")]; - char stringpool_str882[sizeof("TCVN5712-1:1993")]; - char stringpool_str894[sizeof("MACTURKISH")]; - char stringpool_str963[sizeof("BIG5-HKSCS:2001")]; - char stringpool_str965[sizeof("UTF-32LE")]; - char stringpool_str974[sizeof("UTF-32BE")]; - char stringpool_str976[sizeof("BIG5-HKSCS:2004")]; - char stringpool_str985[sizeof("BIG5-HKSCS:2008")]; - char stringpool_str989[sizeof("BIG5-HKSCS:1999")]; - char stringpool_str1062[sizeof("WINBALTRIM")]; - char stringpool_str1111[sizeof("MACHEBREW")]; - char stringpool_str1135[sizeof("CSPC850MULTILINGUAL")]; - char stringpool_str1164[sizeof("CSEUCPKDFMTJAPANESE")]; - }; -static const struct stringpool_t stringpool_contents = - { - "CN", - "R8", - "866", - "ASCII", - "ISO-IR-6", - "ISO-IR-166", - "CP866", - "ISO646-CN", - "C99", - "CP154", - "ISO-IR-14", - "ISO-IR-165", - "CP1256", - "ISO-IR-126", - "CP1251", - "ISO-IR-101", - "862", - "ISO-IR-144", - "850", - "CSASCII", - "ISO-IR-58", - "CP1255", - "HZ", - "CP819", - "CP1254", - "GEORGIAN-ACADEMY", - "ISO-IR-226", - "ISO-IR-148", - "CP862", - "ISO-IR-159", - "ISO-IR-110", - "ISO-IR-149", - "RK1048", - "ISO88596", - "CP949", - "CP1258", - "ISO88591", - "ISO8859-6", - "CP850", - "ISO-IR-199", - "ISO8859-1", - "CP950", - "ISO-8859-6", - "ISO_8859-6", - "ISO8859-16", - "ISO-IR-109", - "ISO-8859-1", - "ISO_8859-1", - "ISO8859-11", - "CP1252", - "ISO-8859-16", - "ISO_8859-16", - "SJIS", - "CP1250", - "ISO-8859-11", - "ISO_8859-11", - "ISO88595", - "ISO-IR-100", - "ISO_8859-16:2001", - "CP50221", - "HP15CN", - "EUCCN", - "ISO8859-5", - "ISO885915", - "ISO8859-4", - "EUC-CN", - "ISO-8859-5", - "ISO_8859-5", - "ISO8859-15", - "CP874", - "ISO-8859-4", - "ISO_8859-4", - "ISO8859-14", - "ISO-8859-15", - "ISO_8859-15", - "ISO88598", - "ISO-8859-14", - "ISO_8859-14", - "TIS620", - "ISO8859-8", - "CP1361", - "ISO88599", - "CP1131", - "TIS-620", - "ISO-8859-8", - "ISO_8859-8", - "ISO8859-9", - "ISO_8859-15:1998", - "ISO88592", - "ISO_8859-14:1998", - "ISO-IR-179", - "ISO-8859-9", - "ISO_8859-9", - "ISO8859-2", - "CP936", - "ISO-2022-CN", - "ISO-8859-2", - "ISO_8859-2", - "L6", - "KOI8-R", - "L1", - "ISO8859-10", - "ISO-2022-CN-EXT", - "PT154", - "ISO-8859-10", - "ISO_8859-10", - "L5", - "ISO_8859-10:1992", - "L4", - "CSKOI8R", - "UHC", - "KOI8-T", - "TIS620-0", - "ISO-IR-57", - "L8", - "X0201", - "GB_1988-80", - "ISO-IR-157", - "L2", - "ISO-IR-87", - "MAC", - "LATIN6", - "ISO-IR-138", - "US", - "LATIN1", - "CP1257", - "CSISO2022CN", - "ISO-IR-127", - "KSC_5601", - "TCVN", - "X0212", - "CP932", - "IBM866", - "BIG5", - "LATIN5", - "ARABIC", - "LATIN4", - "BIG-5", - "ELOT_928", - "X0208", - "GB2312", - "L10", - "CSBIG5", - "KZ-1048", - "LATIN8", - "L7", - "UCS-4", - "CN-BIG5", - "US-ASCII", - "ROMAN8", - "ISO88597", - "MS-ANSI", - "EUCKR", - "LATIN-9", - "ISO8859-7", - "LATIN2", - "KS_C_5601-1989", - "CSKZ1048", - "EUC-KR", - "KOREAN", - "ISO-8859-7", - "ISO_8859-7", - "VISCII", - "MACCROATIAN", - "GB18030", - "CSUCS4", - "LATIN10", - "IBM819", - "ISO-10646-UCS-4", - "UCS-2", - "IBM862", - "GEORGIAN-PS", - "CSISOLATIN6", - "CSVISCII", - "GBK", - "CSISOLATIN1", - "JP", - "UTF-16", - "ISO-10646-UCS-2", - "CP367", - "ISO-2022-KR", - "IBM850", - "ISO646-US", - "L3", - "CSISOLATINARABIC", - "CN-GB-ISOIR165", - "CSISOLATINCYRILLIC", - "CSISOLATIN5", - "CSISOLATIN4", - "KS_C_5601-1987", - "GB_2312-80", - "CP1253", - "ARMSCII-8", - "UTF8", - "MACTHAI", - "CSISO14JISC6220RO", - "UTF-8", - "PTCP154", - "UNICODE-1-1", - "CSISOLATIN2", - "CSISO2022KR", - "ISO-IR-203", - "CSUNICODE11", - "MS936", - "JIS_C6220-1969-RO", - "ISO-CELTIC", - "TIS620.2529-1", - "ECMA-114", - "LATIN7", - "JIS0208", - "CSPTCP154", - "ISO8859-3", - "HP-ROMAN8", - "ISO-8859-3", - "ISO_8859-3", - "ISO8859-13", - "ASMO-708", - "ECMA-118", - "CSISO159JISX02121990", - "TCVN5712-1", - "ISO-8859-13", - "ISO_8859-13", - "ISO_646.IRV:1991", - "STRK1048-2002", - "CHINESE", - "CSKSC56011987", - "EUCTW", - "JAVA", - "WINDOWS-1256", - "WINDOWS-1251", - "EUC-TW", - "TCVN-5712", - "WINDOWS-1255", - "WINDOWS-1254", - "CP1133", - "CN-GB", - "WINDOWS-1258", - "VISCII1.1-1", - "CYRILLIC", - "GREEK8", - "WINDOWS-1252", - "UNICODE-1-1-UTF-7", - "WINDOWS-1250", - "ISO_8859-5:1988", - "MACROMAN", - "ISO_8859-4:1988", - "CSUNICODE11UTF7", - "SHIFT-JIS", - "SHIFT_JIS", - "CSISO57GB1988", - "ISO_8859-8:1988", - "CSIBM866", - "CSUNICODE", - "UTF-7", - "ISO_8859-9:1989", - "CSISOLATINGREEK", - "MACROMANIA", - "JIS_C6226-1983", - "MACARABIC", - "CSGB2312", - "CSEUCKR", - "LATIN3", - "JIS_X0201", - "ISO-2022-JP-1", - "MACINTOSH", - "WINDOWS-1257", - "ISO_8859-6:1987", - "ISO_8859-1:1987", - "ANSI_X3.4-1986", - "WINDOWS-874", - "CYRILLIC-ASIAN", - "UTF-32", - "ISO646-JP", - "IBM367", - "JIS_X0212", - "ISO-2022-JP-2", - "CSMACINTOSH", - "ANSI_X3.4-1968", - "ISO_8859-2:1987", - "JISX0201-1976", - "WINDOWS-936", - "JIS_X0208", - "ISO-2022-JP-MS", - "JIS_X0212-1990", - "GREEK", - "CSHPROMAN8", - "MS-EE", - "CSISOLATINHEBREW", - "CSISO58GB231280", - "WINDOWS-1253", - "JIS_X0208-1990", - "KOI8-U", - "MS_KANJI", - "KOI8-RU", - "CSSHIFTJIS", - "CSISO2022JP2", - "ISO_8859-3:1988", - "CSISOLATIN3", - "UNICODEBIG", - "ISO_8859-7:1987", - "HZ-GB-2312", - "MACICELAND", - "CSISO87JISX0208", - "EUCJP", - "TIS620.2533-1", - "EUC-JP", - "UCS-4-INTERNAL", - "CSPC862LATINHEBREW", - "NEXTSTEP", - "CSEUCTW", - "TIS620.2533-0", - "UCS-2-INTERNAL", - "MS-CYRL", - "ISO-2022-JP", - "ISO_8859-7:2003", - "MS-HEBR", - "MS-ARAB", - "BIG5HKSCS", - "BIG5-HKSCS", - "JIS_X0212.1990-0", - "JIS_X0208-1983", - "GB18030:2005", - "MACCYRILLIC", - "UNICODELITTLE", - "CSISO2022JP", - "UCS-4LE", - "GB18030:2022", - "UCS-4BE", - "JOHAB", - "UCS-2LE", - "HEBREW", - "UCS-2BE", - "MS-TURK", - "CSHALFWIDTHKATAKANA", - "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", - "UTF-16LE", - "MULELAO-1", - "UTF-16BE", - "MS-GREEK", - "UCS-4-SWAPPED", - "MACGREEK", - "UCS-2-SWAPPED", - "BIGFIVE", - "BIG-FIVE", - "IBM-CP1133", - "MACCENTRALEUROPE", - "MACUKRAINE", - "TCVN5712-1:1993", - "MACTURKISH", - "BIG5-HKSCS:2001", - "UTF-32LE", - "UTF-32BE", - "BIG5-HKSCS:2004", - "BIG5-HKSCS:2008", - "BIG5-HKSCS:1999", - "WINBALTRIM", - "MACHEBREW", - "CSPC850MULTILINGUAL", - "CSEUCPKDFMTJAPANESE" - }; -#define stringpool ((const char *) &stringpool_contents) - -static const struct alias aliases[] = - { - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 297 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str23, ei_iso646_cn}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, -#line 236 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str36, ei_hp_roman8}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 216 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str42, ei_cp866}, - {-1}, {-1}, -#line 13 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str45, ei_ascii}, - {-1}, {-1}, -#line 16 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str48, ei_ascii}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, -#line 261 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str62, ei_tis620}, -#line 214 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str63, ei_cp866}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 295 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str82, ei_iso646_cn}, -#line 52 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str83, ei_c99}, -#line 245 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str84, ei_pt154}, - {-1}, -#line 273 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str86, ei_iso646_jp}, - {-1}, -#line 302 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str88, ei_isoir165}, - {-1}, {-1}, {-1}, -#line 198 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str92, ei_cp1256}, - {-1}, -#line 112 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str94, ei_iso8859_7}, - {-1}, -#line 183 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str96, ei_cp1251}, - {-1}, {-1}, {-1}, -#line 68 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str100, ei_iso8859_2}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 212 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str106, ei_cp862}, -#line 93 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str107, ei_iso8859_5}, - {-1}, {-1}, -#line 208 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str110, ei_cp850}, -#line 22 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str111, ei_ascii}, - {-1}, {-1}, {-1}, -#line 300 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str115, ei_gb2312}, - {-1}, {-1}, -#line 195 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str118, ei_cp1255}, -#line 344 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str119, ei_hz}, - {-1}, -#line 58 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str121, ei_iso8859_1}, -#line 192 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str122, ei_cp1254}, -#line 240 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str123, ei_georgian_academy}, -#line 172 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str124, ei_iso8859_16}, -#line 131 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str125, ei_iso8859_9}, - {-1}, -#line 210 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str127, ei_cp862}, - {-1}, {-1}, {-1}, -#line 292 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str131, ei_jisx0212}, -#line 85 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str132, ei_iso8859_4}, -#line 307 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str133, ei_ksc5601}, - {-1}, -#line 248 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str135, ei_rk1048}, - {-1}, -#line 107 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str137, ei_iso8859_6}, -#line 365 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str138, ei_cp949}, - {-1}, -#line 204 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str140, ei_cp1258}, -#line 64 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str141, ei_iso8859_1}, - {-1}, -#line 106 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str143, ei_iso8859_6}, -#line 206 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str144, ei_cp850}, - {-1}, -#line 157 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str146, ei_iso8859_14}, -#line 63 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str147, ei_iso8859_1}, -#line 355 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str148, ei_cp950}, -#line 98 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str149, ei_iso8859_6}, -#line 99 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str150, ei_iso8859_6}, -#line 175 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str151, ei_iso8859_16}, -#line 77 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str152, ei_iso8859_3}, -#line 54 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str153, ei_iso8859_1}, -#line 55 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str154, ei_iso8859_1}, -#line 147 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str155, ei_iso8859_11}, -#line 186 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str156, ei_cp1252}, -#line 169 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str157, ei_iso8859_16}, -#line 170 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str158, ei_iso8859_16}, -#line 316 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str159, ei_sjis}, -#line 180 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str160, ei_cp1250}, -#line 145 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str161, ei_iso8859_11}, -#line 146 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str162, ei_iso8859_11}, -#line 97 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str163, ei_iso8859_5}, -#line 57 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str164, ei_iso8859_1}, -#line 171 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str165, ei_iso8859_16}, -#line 326 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str166, ei_iso2022_jpms}, -#line 333 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str167, ei_euc_cn}, -#line 328 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str168, ei_euc_cn}, -#line 96 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str169, ei_iso8859_5}, - {-1}, -#line 168 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str171, ei_iso8859_15}, - {-1}, -#line 89 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str173, ei_iso8859_4}, -#line 327 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str174, ei_euc_cn}, -#line 90 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str175, ei_iso8859_5}, -#line 91 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str176, ei_iso8859_5}, -#line 167 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str177, ei_iso8859_15}, -#line 262 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str178, ei_cp874}, -#line 82 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str179, ei_iso8859_4}, -#line 83 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str180, ei_iso8859_4}, -#line 161 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str181, ei_iso8859_14}, - {-1}, -#line 162 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str183, ei_iso8859_15}, -#line 163 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str184, ei_iso8859_15}, -#line 127 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str185, ei_iso8859_8}, - {-1}, -#line 154 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str187, ei_iso8859_14}, -#line 155 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str188, ei_iso8859_14}, - {-1}, -#line 256 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str190, ei_tis620}, -#line 126 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str191, ei_iso8859_8}, -#line 368 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str192, ei_johab}, -#line 136 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str193, ei_iso8859_9}, -#line 218 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str194, ei_cp1131}, - {-1}, -#line 255 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str196, ei_tis620}, -#line 120 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str197, ei_iso8859_8}, -#line 121 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str198, ei_iso8859_8}, -#line 135 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str199, ei_iso8859_9}, -#line 164 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str200, ei_iso8859_15}, -#line 73 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str201, ei_iso8859_2}, -#line 156 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str202, ei_iso8859_14}, -#line 150 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str203, ei_iso8859_13}, - {-1}, -#line 128 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str205, ei_iso8859_9}, -#line 129 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str206, ei_iso8859_9}, -#line 72 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str207, ei_iso8859_2}, -#line 335 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str208, ei_cp936}, -#line 341 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str209, ei_iso2022_cn}, - {-1}, {-1}, {-1}, -#line 65 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str213, ei_iso8859_2}, -#line 66 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str214, ei_iso8859_2}, -#line 142 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str215, ei_iso8859_10}, -#line 176 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str216, ei_koi8_r}, -#line 61 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str217, ei_iso8859_1}, - {-1}, -#line 144 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str219, ei_iso8859_10}, -#line 343 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str220, ei_iso2022_cn_ext}, - {-1}, {-1}, -#line 243 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str223, ei_pt154}, - {-1}, -#line 137 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str225, ei_iso8859_10}, -#line 138 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str226, ei_iso8859_10}, - {-1}, -#line 133 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str228, ei_iso8859_9}, -#line 139 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str229, ei_iso8859_10}, -#line 87 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str230, ei_iso8859_4}, -#line 177 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str231, ei_koi8_r}, -#line 366 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str232, ei_cp949}, - {-1}, -#line 242 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str234, ei_koi8_t}, - {-1}, -#line 257 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str236, ei_tis620}, -#line 296 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str237, ei_iso646_cn}, - {-1}, -#line 159 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str239, ei_iso8859_14}, - {-1}, {-1}, {-1}, -#line 278 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str243, ei_jisx0201}, -#line 294 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str244, ei_iso646_cn}, -#line 140 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str245, ei_iso8859_10}, - {-1}, -#line 70 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str247, ei_iso8859_2}, -#line 285 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str248, ei_jisx0208}, -#line 221 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str249, ei_mac_roman}, -#line 141 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str250, ei_iso8859_10}, -#line 123 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str251, ei_iso8859_8}, - {-1}, -#line 21 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str253, ei_ascii}, -#line 60 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str254, ei_iso8859_1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 201 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str262, ei_cp1257}, -#line 342 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str263, ei_iso2022_cn}, -#line 101 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str264, ei_iso8859_6}, -#line 304 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str265, ei_ksc5601}, - {-1}, {-1}, -#line 267 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str268, ei_tcvn}, - {-1}, {-1}, -#line 291 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str271, ei_jisx0212}, -#line 319 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str272, ei_cp932}, -#line 215 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str273, ei_cp866}, - {-1}, -#line 349 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str275, ei_ces_big5}, -#line 132 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str276, ei_iso8859_9}, - {-1}, -#line 104 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str278, ei_iso8859_6}, - {-1}, -#line 86 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str280, ei_iso8859_4}, -#line 350 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str281, ei_ces_big5}, -#line 114 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str282, ei_iso8859_7}, - {-1}, {-1}, {-1}, {-1}, -#line 284 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str287, ei_jisx0208}, -#line 329 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str288, ei_euc_cn}, -#line 174 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str289, ei_iso8859_16}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 354 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str296, ei_ces_big5}, -#line 250 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str297, ei_rk1048}, -#line 158 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str298, ei_iso8859_14}, - {-1}, -#line 152 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str300, ei_iso8859_13}, -#line 34 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str301, ei_ucs4}, -#line 353 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str302, ei_ces_big5}, - {-1}, -#line 12 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str304, ei_ascii}, -#line 235 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str305, ei_hp_roman8}, - {-1}, -#line 119 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str307, ei_iso8859_7}, -#line 188 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str308, ei_cp1252}, - {-1}, {-1}, -#line 363 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str311, ei_euc_kr}, -#line 166 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str312, ei_iso8859_15}, -#line 118 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str313, ei_iso8859_7}, -#line 69 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str314, ei_iso8859_2}, -#line 306 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str315, ei_ksc5601}, -#line 251 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str316, ei_rk1048}, -#line 362 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str317, ei_euc_kr}, -#line 309 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str318, ei_ksc5601}, -#line 108 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str319, ei_iso8859_7}, -#line 109 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str320, ei_iso8859_7}, -#line 264 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str321, ei_viscii}, -#line 225 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str322, ei_mac_croatian}, - {-1}, -#line 338 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str324, ei_gb18030_2005}, -#line 36 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str325, ei_ucs4}, -#line 173 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str326, ei_iso8859_16}, - {-1}, {-1}, {-1}, {-1}, -#line 59 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str331, ei_iso8859_1}, -#line 35 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str332, ei_ucs4}, - {-1}, {-1}, -#line 25 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str335, ei_ucs2}, - {-1}, -#line 211 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str337, ei_cp862}, -#line 241 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str338, ei_georgian_ps}, - {-1}, -#line 143 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str340, ei_iso8859_10}, - {-1}, -#line 266 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str342, ei_viscii}, -#line 334 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str343, ei_ces_gbk}, -#line 62 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str344, ei_iso8859_1}, - {-1}, -#line 274 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str346, ei_iso646_jp}, -#line 39 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str347, ei_utf16}, - {-1}, -#line 26 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str349, ei_ucs2}, -#line 19 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str350, ei_ascii}, - {-1}, -#line 369 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str352, ei_iso2022_kr}, - {-1}, -#line 207 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str354, ei_cp850}, -#line 14 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str355, ei_ascii}, -#line 79 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str356, ei_iso8859_3}, - {-1}, {-1}, {-1}, -#line 105 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str360, ei_iso8859_6}, -#line 303 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str361, ei_isoir165}, - {-1}, {-1}, {-1}, -#line 95 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str365, ei_iso8859_5}, -#line 134 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str366, ei_iso8859_9}, - {-1}, {-1}, {-1}, -#line 88 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str370, ei_iso8859_4}, - {-1}, -#line 305 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str372, ei_ksc5601}, -#line 299 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str373, ei_gb2312}, -#line 189 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str374, ei_cp1253}, -#line 239 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str375, ei_armscii_8}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 24 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str381, ei_utf8}, -#line 233 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str382, ei_mac_thai}, -#line 275 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str383, ei_iso646_jp}, - {-1}, {-1}, {-1}, -#line 23 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str387, ei_utf8}, - {-1}, {-1}, {-1}, {-1}, -#line 244 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str392, ei_pt154}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 30 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str398, ei_ucs2be}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 71 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str404, ei_iso8859_2}, - {-1}, -#line 370 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str406, ei_iso2022_kr}, - {-1}, -#line 165 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str408, ei_iso8859_15}, -#line 31 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str409, ei_ucs2be}, - {-1}, {-1}, -#line 336 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str412, ei_cp936}, -#line 271 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str413, ei_iso646_jp}, - {-1}, -#line 160 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str415, ei_iso8859_14}, -#line 258 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str416, ei_tis620}, -#line 102 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str417, ei_iso8859_6}, - {-1}, {-1}, -#line 151 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str420, ei_iso8859_13}, -#line 283 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str421, ei_jisx0208}, -#line 247 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str422, ei_pt154}, - {-1}, {-1}, -#line 81 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str425, ei_iso8859_3}, -#line 234 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str426, ei_hp_roman8}, - {-1}, {-1}, {-1}, {-1}, -#line 74 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str431, ei_iso8859_3}, -#line 75 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str432, ei_iso8859_3}, -#line 153 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str433, ei_iso8859_13}, -#line 103 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str434, ei_iso8859_6}, -#line 113 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str435, ei_iso8859_7}, - {-1}, -#line 293 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str437, ei_jisx0212}, -#line 269 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str438, ei_tcvn}, -#line 148 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str439, ei_iso8859_13}, -#line 149 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str440, ei_iso8859_13}, -#line 15 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str441, ei_ascii}, -#line 249 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str442, ei_rk1048}, - {-1}, {-1}, {-1}, -#line 332 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str446, ei_euc_cn}, - {-1}, {-1}, {-1}, {-1}, -#line 308 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str451, ei_ksc5601}, -#line 347 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str452, ei_euc_tw}, -#line 53 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str453, ei_java}, -#line 199 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str454, ei_cp1256}, - {-1}, -#line 184 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str456, ei_cp1251}, - {-1}, -#line 346 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str458, ei_euc_tw}, - {-1}, -#line 268 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str460, ei_tcvn}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 196 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str467, ei_cp1255}, - {-1}, -#line 193 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str469, ei_cp1254}, - {-1}, {-1}, -#line 253 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str472, ei_cp1133}, - {-1}, {-1}, {-1}, -#line 330 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str476, ei_euc_cn}, - {-1}, -#line 205 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str478, ei_cp1258}, - {-1}, -#line 265 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str480, ei_viscii}, -#line 94 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str481, ei_iso8859_5}, - {-1}, {-1}, {-1}, -#line 115 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str485, ei_iso8859_7}, -#line 187 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str486, ei_cp1252}, -#line 46 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str487, ei_utf7}, -#line 181 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str488, ei_cp1250}, - {-1}, {-1}, {-1}, -#line 92 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str492, ei_iso8859_5}, -#line 219 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str493, ei_mac_roman}, -#line 84 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str494, ei_iso8859_4}, - {-1}, -#line 47 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str496, ei_utf7}, -#line 315 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str497, ei_sjis}, -#line 314 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str498, ei_sjis}, -#line 298 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str499, ei_iso646_cn}, - {-1}, {-1}, {-1}, -#line 122 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str503, ei_iso8859_8}, - {-1}, {-1}, -#line 217 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str506, ei_cp866}, -#line 27 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str507, ei_ucs2}, - {-1}, -#line 45 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str509, ei_utf7}, - {-1}, -#line 130 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str511, ei_iso8859_9}, - {-1}, -#line 117 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str513, ei_iso8859_7}, - {-1}, -#line 226 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str515, ei_mac_romania}, - {-1}, -#line 286 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str517, ei_jisx0208}, -#line 232 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str518, ei_mac_arabic}, - {-1}, {-1}, -#line 331 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str521, ei_euc_cn}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 364 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str528, ei_euc_kr}, - {-1}, {-1}, {-1}, -#line 78 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str532, ei_iso8859_3}, -#line 276 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str533, ei_jisx0201}, -#line 322 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str534, ei_iso2022_jp1}, - {-1}, {-1}, {-1}, -#line 220 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str538, ei_mac_roman}, -#line 202 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str539, ei_cp1257}, -#line 100 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str540, ei_iso8859_6}, - {-1}, -#line 56 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str542, ei_iso8859_1}, -#line 18 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str543, ei_ascii}, - {-1}, -#line 263 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str545, ei_cp874}, -#line 246 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str546, ei_pt154}, - {-1}, {-1}, {-1}, -#line 42 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str550, ei_utf32}, -#line 272 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str551, ei_iso646_jp}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 20 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str560, ei_ascii}, -#line 288 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str561, ei_jisx0212}, - {-1}, {-1}, -#line 323 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str564, ei_iso2022_jp2}, -#line 222 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str565, ei_mac_roman}, - {-1}, -#line 17 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str567, ei_ascii}, - {-1}, {-1}, {-1}, {-1}, -#line 67 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str572, ei_iso8859_2}, - {-1}, -#line 277 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str574, ei_jisx0201}, -#line 337 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str575, ei_cp936}, - {-1}, -#line 280 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str577, ei_jisx0208}, -#line 325 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str578, ei_iso2022_jpms}, - {-1}, -#line 290 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str580, ei_jisx0212}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 116 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str587, ei_iso8859_7}, - {-1}, -#line 237 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str589, ei_hp_roman8}, - {-1}, -#line 182 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str591, ei_cp1250}, -#line 125 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str592, ei_iso8859_8}, -#line 301 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str593, ei_gb2312}, - {-1}, -#line 190 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str595, ei_cp1253}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 282 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str604, ei_jisx0208}, - {-1}, {-1}, {-1}, -#line 178 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str608, ei_koi8_u}, - {-1}, {-1}, {-1}, -#line 317 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str612, ei_sjis}, - {-1}, -#line 179 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str614, ei_koi8_ru}, -#line 318 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str615, ei_sjis}, - {-1}, -#line 324 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str617, ei_iso2022_jp2}, - {-1}, {-1}, -#line 76 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str620, ei_iso8859_3}, - {-1}, -#line 80 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str622, ei_iso8859_3}, - {-1}, -#line 29 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str624, ei_ucs2be}, -#line 110 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str625, ei_iso8859_7}, - {-1}, -#line 345 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str627, ei_hz}, -#line 224 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str628, ei_mac_iceland}, - {-1}, {-1}, -#line 287 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str631, ei_jisx0208}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 311 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str637, ei_euc_jp}, -#line 260 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str638, ei_tis620}, - {-1}, {-1}, {-1}, {-1}, -#line 310 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str643, ei_euc_jp}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, -#line 50 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str655, ei_ucs4internal}, - {-1}, -#line 213 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str657, ei_cp862}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, -#line 238 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str668, ei_nextstep}, -#line 348 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str669, ei_euc_tw}, -#line 259 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str670, ei_tis620}, - {-1}, -#line 48 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str672, ei_ucs2internal}, -#line 185 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str673, ei_cp1251}, - {-1}, {-1}, {-1}, {-1}, -#line 320 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str678, ei_iso2022_jp}, - {-1}, {-1}, -#line 111 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str681, ei_iso8859_7}, - {-1}, {-1}, {-1}, {-1}, -#line 197 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str686, ei_cp1255}, - {-1}, {-1}, {-1}, {-1}, -#line 200 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str691, ei_cp1256}, - {-1}, {-1}, {-1}, -#line 360 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str695, ei_big5hkscs2008}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 359 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str701, ei_big5hkscs2008}, - {-1}, -#line 289 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str703, ei_jisx0212}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 281 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str711, ei_jisx0208}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, -#line 339 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str723, ei_gb18030_2005}, -#line 227 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str724, ei_mac_cyrillic}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 33 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str731, ei_ucs2le}, -#line 321 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str732, ei_iso2022_jp}, -#line 38 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str733, ei_ucs4le}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 340 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str740, ei_gb18030_2022}, - {-1}, -#line 37 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str742, ei_ucs4be}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 367 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str749, ei_johab}, -#line 32 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str750, ei_ucs2le}, - {-1}, {-1}, {-1}, {-1}, -#line 124 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str755, ei_iso8859_8}, - {-1}, {-1}, {-1}, -#line 28 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str759, ei_ucs2be}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, -#line 194 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str772, ei_cp1254}, - {-1}, {-1}, -#line 279 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str775, ei_jisx0201}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 312 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str784, ei_euc_jp}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 41 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str794, ei_utf16le}, - {-1}, {-1}, {-1}, {-1}, -#line 252 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str799, ei_mulelao}, - {-1}, {-1}, {-1}, -#line 40 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str803, ei_utf16be}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 191 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str818, ei_cp1253}, - {-1}, -#line 51 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str820, ei_ucs4swapped}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 229 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str827, ei_mac_greek}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 49 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str837, ei_ucs2swapped}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 352 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str843, ei_ces_big5}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 351 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str849, ei_ces_big5}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 254 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str857, ei_cp1133}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, -#line 223 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str870, ei_mac_centraleurope}, - {-1}, {-1}, {-1}, -#line 228 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str874, ei_mac_ukraine}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 270 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str882, ei_tcvn}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, -#line 230 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str894, ei_mac_turkish}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 357 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str963, ei_big5hkscs2001}, - {-1}, -#line 44 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str965, ei_utf32le}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 43 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str974, ei_utf32be}, - {-1}, -#line 358 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str976, ei_big5hkscs2004}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 361 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str985, ei_big5hkscs2008}, - {-1}, {-1}, {-1}, -#line 356 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str989, ei_big5hkscs1999}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 203 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1062, ei_cp1257}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, -#line 231 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1111, ei_mac_hebrew}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 209 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1135, ei_cp850}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, -#line 313 "lib/generated/aliases_syshpux.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str1164, ei_euc_jp} - }; - -const struct alias * -HashPool::aliases_lookup (const char *str, size_t len) -{ - if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) - { - unsigned int key = aliases_hash (str, len); - - if (key <= MAX_HASH_VALUE) - { - int o = aliases[key].name; - if (o >= 0) - { - const char *s = o + stringpool; - - if (*str == *s && !strcmp (str + 1, s + 1)) - return &aliases[key]; - } - } - } - return 0; -} diff --git a/lib/generated/aliases_sysosf1.h b/lib/generated/aliases_sysosf1.h deleted file mode 100644 index 6167addc..00000000 --- a/lib/generated/aliases_sysosf1.h +++ /dev/null @@ -1,1749 +0,0 @@ -/* C++ code produced by gperf version 3.1 */ -/* Command-line: gperf -L C++ -Z HashPool -m 10 lib/generated/aliases_sysosf1.gperf */ -/* Computed positions: -k'1,3-11,$' */ - -#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ - && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ - && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ - && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ - && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ - && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ - && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ - && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ - && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ - && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ - && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ - && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ - && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ - && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ - && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ - && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ - && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ - && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ - && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ - && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ - && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ - && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ - && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) -/* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." -#endif - -#line 1 "lib/generated/aliases_sysosf1.gperf" -struct alias { int name; unsigned int encoding_index; }; - -#define TOTAL_KEYWORDS 354 -#define MIN_WORD_LENGTH 2 -#define MAX_WORD_LENGTH 45 -#define MIN_HASH_VALUE 5 -#define MAX_HASH_VALUE 999 -/* maximum key range = 995, duplicates = 0 */ - -class HashPool -{ -private: - static inline unsigned int aliases_hash (const char *str, size_t len); -public: - static const struct alias *aliases_lookup (const char *str, size_t len); -}; - -inline unsigned int -HashPool::aliases_hash (const char *str, size_t len) -{ - static const unsigned short asso_values[] = - { - 1000,1000,1000,1000,1000,1000,1000,1000,1000,1000, - 1000,1000,1000,1000,1000,1000,1000,1000,1000,1000, - 1000,1000,1000,1000,1000,1000,1000,1000,1000,1000, - 1000,1000,1000,1000,1000,1000,1000,1000,1000,1000, - 1000,1000,1000,1000,1000, 0, 37,1000, 44, 2, - 16, 28, 9, 13, 5, 190, 20, 0, 242,1000, - 1000,1000,1000,1000,1000, 13, 212, 2, 19, 66, - 10, 134, 52, 88, 187, 190, 6, 142, 3, 0, - 99,1000, 0, 11, 118, 241, 170, 160, 367, 54, - 21,1000,1000,1000,1000, 1,1000,1000,1000,1000, - 1000,1000,1000,1000,1000,1000,1000,1000,1000,1000, - 1000,1000,1000,1000,1000,1000,1000,1000,1000,1000, - 1000,1000,1000,1000,1000,1000,1000,1000 - }; - unsigned int hval = len; - - switch (hval) - { - default: - hval += asso_values[static_cast(str[10])]; - /*FALLTHROUGH*/ - case 10: - hval += asso_values[static_cast(str[9])]; - /*FALLTHROUGH*/ - case 9: - hval += asso_values[static_cast(str[8])]; - /*FALLTHROUGH*/ - case 8: - hval += asso_values[static_cast(str[7])]; - /*FALLTHROUGH*/ - case 7: - hval += asso_values[static_cast(str[6])]; - /*FALLTHROUGH*/ - case 6: - hval += asso_values[static_cast(str[5])]; - /*FALLTHROUGH*/ - case 5: - hval += asso_values[static_cast(str[4])]; - /*FALLTHROUGH*/ - case 4: - hval += asso_values[static_cast(str[3])]; - /*FALLTHROUGH*/ - case 3: - hval += asso_values[static_cast(str[2])]; - /*FALLTHROUGH*/ - case 2: - case 1: - hval += asso_values[static_cast(str[0])]; - break; - } - return hval + asso_values[static_cast(str[len - 1])]; -} - -struct stringpool_t - { - char stringpool_str5[sizeof("C99")]; - char stringpool_str7[sizeof("CN")]; - char stringpool_str10[sizeof("L1")]; - char stringpool_str13[sizeof("L6")]; - char stringpool_str16[sizeof("CP949")]; - char stringpool_str17[sizeof("L4")]; - char stringpool_str21[sizeof("L5")]; - char stringpool_str22[sizeof("R8")]; - char stringpool_str24[sizeof("L2")]; - char stringpool_str28[sizeof("L8")]; - char stringpool_str29[sizeof("CP819")]; - char stringpool_str33[sizeof("866")]; - char stringpool_str36[sizeof("L3")]; - char stringpool_str40[sizeof("CP154")]; - char stringpool_str42[sizeof("CP866")]; - char stringpool_str43[sizeof("CP1251")]; - char stringpool_str44[sizeof("CP1131")]; - char stringpool_str45[sizeof("CP936")]; - char stringpool_str47[sizeof("CP1361")]; - char stringpool_str49[sizeof("CP1256")]; - char stringpool_str55[sizeof("862")]; - char stringpool_str57[sizeof("CP1254")]; - char stringpool_str64[sizeof("CP862")]; - char stringpool_str65[sizeof("CP1255")]; - char stringpool_str67[sizeof("CP932")]; - char stringpool_str71[sizeof("CP1252")]; - char stringpool_str75[sizeof("HZ")]; - char stringpool_str79[sizeof("CP1258")]; - char stringpool_str81[sizeof("EUCCN")]; - char stringpool_str82[sizeof("EUC-CN")]; - char stringpool_str95[sizeof("CP1253")]; - char stringpool_str96[sizeof("CP1133")]; - char stringpool_str97[sizeof("L10")]; - char stringpool_str101[sizeof("RK1048")]; - char stringpool_str102[sizeof("CP50221")]; - char stringpool_str108[sizeof("CP950")]; - char stringpool_str111[sizeof("850")]; - char stringpool_str124[sizeof("ISO646-CN")]; - char stringpool_str125[sizeof("SJIS")]; - char stringpool_str127[sizeof("CP1250")]; - char stringpool_str128[sizeof("CP850")]; - char stringpool_str137[sizeof("PT154")]; - char stringpool_str149[sizeof("MAC")]; - char stringpool_str150[sizeof("ISO8859-9")]; - char stringpool_str151[sizeof("ISO-8859-9")]; - char stringpool_str152[sizeof("ISO_8859-9")]; - char stringpool_str154[sizeof("ISO8859-1")]; - char stringpool_str155[sizeof("ISO-8859-1")]; - char stringpool_str156[sizeof("ISO_8859-1")]; - char stringpool_str157[sizeof("ISO8859-11")]; - char stringpool_str158[sizeof("ISO-8859-11")]; - char stringpool_str159[sizeof("ISO_8859-11")]; - char stringpool_str160[sizeof("ISO8859-6")]; - char stringpool_str161[sizeof("ISO-8859-6")]; - char stringpool_str162[sizeof("ISO_8859-6")]; - char stringpool_str163[sizeof("ISO8859-16")]; - char stringpool_str164[sizeof("ISO-8859-16")]; - char stringpool_str165[sizeof("ISO_8859-16")]; - char stringpool_str167[sizeof("ISO_8859-16:2001")]; - char stringpool_str168[sizeof("ISO8859-4")]; - char stringpool_str169[sizeof("ISO-8859-4")]; - char stringpool_str170[sizeof("ISO_8859-4")]; - char stringpool_str171[sizeof("ISO8859-14")]; - char stringpool_str172[sizeof("ISO-8859-14")]; - char stringpool_str173[sizeof("ISO_8859-14")]; - char stringpool_str176[sizeof("ISO8859-5")]; - char stringpool_str177[sizeof("ISO-8859-5")]; - char stringpool_str178[sizeof("ISO_8859-5")]; - char stringpool_str179[sizeof("ISO8859-15")]; - char stringpool_str180[sizeof("ISO-8859-15")]; - char stringpool_str181[sizeof("ISO_8859-15")]; - char stringpool_str182[sizeof("ISO8859-2")]; - char stringpool_str183[sizeof("ISO-8859-2")]; - char stringpool_str184[sizeof("ISO_8859-2")]; - char stringpool_str185[sizeof("MS936")]; - char stringpool_str188[sizeof("ISO-IR-199")]; - char stringpool_str189[sizeof("ISO_8859-14:1998")]; - char stringpool_str190[sizeof("ISO8859-8")]; - char stringpool_str191[sizeof("ISO-8859-8")]; - char stringpool_str192[sizeof("ISO_8859-8")]; - char stringpool_str193[sizeof("ISO_8859-15:1998")]; - char stringpool_str194[sizeof("ISO-IR-6")]; - char stringpool_str197[sizeof("ISO-IR-149")]; - char stringpool_str198[sizeof("L7")]; - char stringpool_str199[sizeof("ISO-2022-CN")]; - char stringpool_str201[sizeof("ISO-IR-159")]; - char stringpool_str202[sizeof("CYRILLIC")]; - char stringpool_str203[sizeof("ISO-IR-166")]; - char stringpool_str204[sizeof("ROMAN8")]; - char stringpool_str205[sizeof("ISO-IR-14")]; - char stringpool_str206[sizeof("ISO8859-3")]; - char stringpool_str207[sizeof("ISO-8859-3")]; - char stringpool_str208[sizeof("ISO_8859-3")]; - char stringpool_str209[sizeof("ISO8859-13")]; - char stringpool_str210[sizeof("ISO-8859-13")]; - char stringpool_str211[sizeof("ISO_8859-13")]; - char stringpool_str212[sizeof("CSISO2022CN")]; - char stringpool_str214[sizeof("ISO-IR-126")]; - char stringpool_str215[sizeof("ISO-IR-144")]; - char stringpool_str217[sizeof("MS-CYRL")]; - char stringpool_str218[sizeof("GB2312")]; - char stringpool_str219[sizeof("ISO-IR-165")]; - char stringpool_str220[sizeof("ISO_8859-10:1992")]; - char stringpool_str222[sizeof("LATIN-9")]; - char stringpool_str225[sizeof("LATIN1")]; - char stringpool_str228[sizeof("ISO-IR-226")]; - char stringpool_str231[sizeof("LATIN6")]; - char stringpool_str232[sizeof("ISO-IR-109")]; - char stringpool_str233[sizeof("CYRILLIC-ASIAN")]; - char stringpool_str235[sizeof("CP874")]; - char stringpool_str236[sizeof("ISO-IR-101")]; - char stringpool_str237[sizeof("ISO-IR-148")]; - char stringpool_str238[sizeof("ISO-IR-58")]; - char stringpool_str239[sizeof("LATIN4")]; - char stringpool_str240[sizeof("PTCP154")]; - char stringpool_str241[sizeof("ISO8859-10")]; - char stringpool_str242[sizeof("ISO-8859-10")]; - char stringpool_str243[sizeof("ISO_8859-10")]; - char stringpool_str244[sizeof("TIS620")]; - char stringpool_str245[sizeof("TIS-620")]; - char stringpool_str246[sizeof("MULELAO-1")]; - char stringpool_str247[sizeof("LATIN5")]; - char stringpool_str248[sizeof("UHC")]; - char stringpool_str249[sizeof("ELOT_928")]; - char stringpool_str251[sizeof("ECMA-114")]; - char stringpool_str253[sizeof("LATIN2")]; - char stringpool_str254[sizeof("US")]; - char stringpool_str256[sizeof("ISO-IR-138")]; - char stringpool_str258[sizeof("IBM819")]; - char stringpool_str259[sizeof("HP-ROMAN8")]; - char stringpool_str261[sizeof("LATIN8")]; - char stringpool_str263[sizeof("EUCKR")]; - char stringpool_str264[sizeof("EUC-KR")]; - char stringpool_str265[sizeof("KSC5601")]; - char stringpool_str267[sizeof("KSC_5601")]; - char stringpool_str269[sizeof("UTF-16")]; - char stringpool_str271[sizeof("IBM866")]; - char stringpool_str273[sizeof("ECMA-118")]; - char stringpool_str274[sizeof("KS_C_5601-1989")]; - char stringpool_str275[sizeof("UCS-4")]; - char stringpool_str277[sizeof("LATIN3")]; - char stringpool_str278[sizeof("ISO-IR-110")]; - char stringpool_str280[sizeof("CSUCS4")]; - char stringpool_str281[sizeof("KOREAN")]; - char stringpool_str284[sizeof("ASCII")]; - char stringpool_str287[sizeof("JIS_C6226-1983")]; - char stringpool_str288[sizeof("JP")]; - char stringpool_str289[sizeof("UCS-2")]; - char stringpool_str290[sizeof("TIS620-0")]; - char stringpool_str291[sizeof("TIS620.2529-1")]; - char stringpool_str292[sizeof("KZ-1048")]; - char stringpool_str293[sizeof("IBM862")]; - char stringpool_str294[sizeof("DECHANZI")]; - char stringpool_str295[sizeof("GB_1988-80")]; - char stringpool_str296[sizeof("UTF-8")]; - char stringpool_str298[sizeof("TCVN")]; - char stringpool_str299[sizeof("CSASCII")]; - char stringpool_str301[sizeof("JIS_C6220-1969-RO")]; - char stringpool_str302[sizeof("ISO-IR-203")]; - char stringpool_str304[sizeof("KOI8-R")]; - char stringpool_str305[sizeof("DECKOREAN")]; - char stringpool_str307[sizeof("CSKOI8R")]; - char stringpool_str309[sizeof("CHINESE")]; - char stringpool_str312[sizeof("LATIN10")]; - char stringpool_str313[sizeof("MACROMAN")]; - char stringpool_str315[sizeof("GB_2312-80")]; - char stringpool_str316[sizeof("CSKZ1048")]; - char stringpool_str317[sizeof("UTF-32")]; - char stringpool_str318[sizeof("ISO-2022-CN-EXT")]; - char stringpool_str320[sizeof("ISO-IR-100")]; - char stringpool_str323[sizeof("GB18030")]; - char stringpool_str331[sizeof("TIS620.2533-1")]; - char stringpool_str336[sizeof("ARABIC")]; - char stringpool_str344[sizeof("CSISOLATIN1")]; - char stringpool_str345[sizeof("MS-EE")]; - char stringpool_str349[sizeof("JIS0208")]; - char stringpool_str350[sizeof("CSISOLATIN6")]; - char stringpool_str351[sizeof("CSISOLATINCYRILLIC")]; - char stringpool_str352[sizeof("MS-ANSI")]; - char stringpool_str354[sizeof("TACTIS")]; - char stringpool_str357[sizeof("IBM850")]; - char stringpool_str358[sizeof("CSISOLATIN4")]; - char stringpool_str360[sizeof("CSISOLATINARABIC")]; - char stringpool_str361[sizeof("CSHPROMAN8")]; - char stringpool_str362[sizeof("CSPTCP154")]; - char stringpool_str365[sizeof("STRK1048-2002")]; - char stringpool_str366[sizeof("CSISOLATIN5")]; - char stringpool_str370[sizeof("MACICELAND")]; - char stringpool_str372[sizeof("CSISOLATIN2")]; - char stringpool_str373[sizeof("TIS620.2533-0")]; - char stringpool_str376[sizeof("BIG5")]; - char stringpool_str377[sizeof("BIG-5")]; - char stringpool_str378[sizeof("ISO-IR-179")]; - char stringpool_str379[sizeof("ISO646-US")]; - char stringpool_str381[sizeof("ISO-2022-KR")]; - char stringpool_str382[sizeof("ISO-CELTIC")]; - char stringpool_str387[sizeof("JAVA")]; - char stringpool_str393[sizeof("ARMSCII-8")]; - char stringpool_str394[sizeof("CSISO2022KR")]; - char stringpool_str395[sizeof("MACCROATIAN")]; - char stringpool_str396[sizeof("CSISOLATIN3")]; - char stringpool_str398[sizeof("WINDOWS-1251")]; - char stringpool_str399[sizeof("ISO_8859-9:1989")]; - char stringpool_str401[sizeof("WINDOWS-1256")]; - char stringpool_str402[sizeof("WINDOWS-936")]; - char stringpool_str403[sizeof("MACCYRILLIC")]; - char stringpool_str404[sizeof("UTF-16LE")]; - char stringpool_str405[sizeof("WINDOWS-1254")]; - char stringpool_str406[sizeof("UCS-4LE")]; - char stringpool_str409[sizeof("WINDOWS-1255")]; - char stringpool_str412[sizeof("WINDOWS-1252")]; - char stringpool_str413[sizeof("UCS-2LE")]; - char stringpool_str415[sizeof("VISCII1.1-1")]; - char stringpool_str416[sizeof("WINDOWS-1258")]; - char stringpool_str417[sizeof("CSISO14JISC6220RO")]; - char stringpool_str418[sizeof("ISO-10646-UCS-4")]; - char stringpool_str419[sizeof("CP1257")]; - char stringpool_str420[sizeof("CP367")]; - char stringpool_str421[sizeof("ISO_646.IRV:1991")]; - char stringpool_str422[sizeof("X0212")]; - char stringpool_str424[sizeof("WINDOWS-1253")]; - char stringpool_str425[sizeof("ISO-10646-UCS-2")]; - char stringpool_str426[sizeof("MACROMANIA")]; - char stringpool_str428[sizeof("ISO_8859-4:1988")]; - char stringpool_str429[sizeof("IBM-CP1133")]; - char stringpool_str432[sizeof("ISO_8859-5:1988")]; - char stringpool_str433[sizeof("UNICODE-1-1")]; - char stringpool_str434[sizeof("CSGB2312")]; - char stringpool_str436[sizeof("X0201")]; - char stringpool_str437[sizeof("ASMO-708")]; - char stringpool_str438[sizeof("CSUNICODE11")]; - char stringpool_str439[sizeof("ISO_8859-8:1988")]; - char stringpool_str440[sizeof("WINDOWS-1250")]; - char stringpool_str441[sizeof("UTF-32LE")]; - char stringpool_str447[sizeof("ISO_8859-3:1988")]; - char stringpool_str453[sizeof("VISCII")]; - char stringpool_str457[sizeof("GEORGIAN-ACADEMY")]; - char stringpool_str458[sizeof("EUCJP")]; - char stringpool_str459[sizeof("EUC-JP")]; - char stringpool_str464[sizeof("KS_C_5601-1987")]; - char stringpool_str466[sizeof("CSISO159JISX02121990")]; - char stringpool_str468[sizeof("CSBIG5")]; - char stringpool_str469[sizeof("CN-BIG5")]; - char stringpool_str472[sizeof("X0208")]; - char stringpool_str474[sizeof("CSKSC56011987")]; - char stringpool_str477[sizeof("MACINTOSH")]; - char stringpool_str479[sizeof("MS-HEBR")]; - char stringpool_str481[sizeof("ISO-2022-JP-1")]; - char stringpool_str483[sizeof("MACARABIC")]; - char stringpool_str486[sizeof("HZ-GB-2312")]; - char stringpool_str487[sizeof("CSIBM866")]; - char stringpool_str491[sizeof("ISO-2022-JP-MS")]; - char stringpool_str494[sizeof("CSMACINTOSH")]; - char stringpool_str495[sizeof("ISO-2022-JP-2")]; - char stringpool_str496[sizeof("CSUNICODE")]; - char stringpool_str500[sizeof("MACCENTRALEUROPE")]; - char stringpool_str501[sizeof("ISO646-JP")]; - char stringpool_str502[sizeof("GREEK8")]; - char stringpool_str504[sizeof("GEORGIAN-PS")]; - char stringpool_str507[sizeof("CSISO2022JP2")]; - char stringpool_str508[sizeof("CSEUCKR")]; - char stringpool_str510[sizeof("MACTHAI")]; - char stringpool_str511[sizeof("EUCTW")]; - char stringpool_str512[sizeof("EUC-TW")]; - char stringpool_str517[sizeof("GBK")]; - char stringpool_str526[sizeof("TCVN5712-1")]; - char stringpool_str530[sizeof("ISO8859-7")]; - char stringpool_str531[sizeof("ISO-8859-7")]; - char stringpool_str532[sizeof("ISO_8859-7")]; - char stringpool_str533[sizeof("SHIFT-JIS")]; - char stringpool_str534[sizeof("SHIFT_JIS")]; - char stringpool_str537[sizeof("TCVN-5712")]; - char stringpool_str539[sizeof("US-ASCII")]; - char stringpool_str540[sizeof("KOI8-T")]; - char stringpool_str545[sizeof("CSVISCII")]; - char stringpool_str547[sizeof("CSPC862LATINHEBREW")]; - char stringpool_str552[sizeof("CSHALFWIDTHKATAKANA")]; - char stringpool_str556[sizeof("UCS-4-INTERNAL")]; - char stringpool_str557[sizeof("CSISOLATINHEBREW")]; - char stringpool_str562[sizeof("CN-GB-ISOIR165")]; - char stringpool_str563[sizeof("UCS-2-INTERNAL")]; - char stringpool_str565[sizeof("CN-GB")]; - char stringpool_str575[sizeof("ANSI_X3.4-1986")]; - char stringpool_str576[sizeof("ISO-2022-JP")]; - char stringpool_str578[sizeof("ISO-IR-57")]; - char stringpool_str581[sizeof("ISO-IR-157")]; - char stringpool_str583[sizeof("CSISO58GB231280")]; - char stringpool_str584[sizeof("ISO-IR-127")]; - char stringpool_str585[sizeof("ISO-IR-87")]; - char stringpool_str586[sizeof("WINDOWS-1257")]; - char stringpool_str588[sizeof("CSSHIFTJIS")]; - char stringpool_str589[sizeof("CSISO2022JP")]; - char stringpool_str590[sizeof("ANSI_X3.4-1968")]; - char stringpool_str591[sizeof("ISO_8859-1:1987")]; - char stringpool_str592[sizeof("WINDOWS-874")]; - char stringpool_str594[sizeof("ISO_8859-6:1987")]; - char stringpool_str599[sizeof("MS-ARAB")]; - char stringpool_str601[sizeof("LATIN7")]; - char stringpool_str605[sizeof("ISO_8859-2:1987")]; - char stringpool_str610[sizeof("UTF-16BE")]; - char stringpool_str612[sizeof("UCS-4BE")]; - char stringpool_str617[sizeof("ISO_8859-7:2003")]; - char stringpool_str618[sizeof("GB18030:2022")]; - char stringpool_str619[sizeof("UCS-2BE")]; - char stringpool_str627[sizeof("UNICODE-1-1-UTF-7")]; - char stringpool_str630[sizeof("CSUNICODE11UTF7")]; - char stringpool_str636[sizeof("UTF-7")]; - char stringpool_str643[sizeof("GB18030:2005")]; - char stringpool_str645[sizeof("BIG5HKSCS")]; - char stringpool_str646[sizeof("BIG5-HKSCS")]; - char stringpool_str647[sizeof("UTF-32BE")]; - char stringpool_str649[sizeof("IBM367")]; - char stringpool_str651[sizeof("GREEK")]; - char stringpool_str656[sizeof("HEBREW")]; - char stringpool_str657[sizeof("SDECKANJI")]; - char stringpool_str668[sizeof("CSISOLATINGREEK")]; - char stringpool_str669[sizeof("JIS_X0212")]; - char stringpool_str675[sizeof("UCS-4-SWAPPED")]; - char stringpool_str681[sizeof("JOHAB")]; - char stringpool_str682[sizeof("UCS-2-SWAPPED")]; - char stringpool_str683[sizeof("JIS_X0201")]; - char stringpool_str685[sizeof("CSISO57GB1988")]; - char stringpool_str691[sizeof("JISX0201-1976")]; - char stringpool_str704[sizeof("JIS_X0212-1990")]; - char stringpool_str712[sizeof("CSPC850MULTILINGUAL")]; - char stringpool_str713[sizeof("EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE")]; - char stringpool_str719[sizeof("JIS_X0208")]; - char stringpool_str720[sizeof("MS_KANJI")]; - char stringpool_str734[sizeof("JIS_X0208-1983")]; - char stringpool_str743[sizeof("JIS_X0212.1990-0")]; - char stringpool_str750[sizeof("JIS_X0208-1990")]; - char stringpool_str753[sizeof("BIGFIVE")]; - char stringpool_str754[sizeof("BIG-FIVE")]; - char stringpool_str756[sizeof("CSEUCTW")]; - char stringpool_str779[sizeof("ISO_8859-7:1987")]; - char stringpool_str786[sizeof("KOI8-U")]; - char stringpool_str787[sizeof("KOI8-RU")]; - char stringpool_str796[sizeof("MS-GREEK")]; - char stringpool_str798[sizeof("MACGREEK")]; - char stringpool_str799[sizeof("TCVN5712-1:1993")]; - char stringpool_str821[sizeof("MACUKRAINE")]; - char stringpool_str825[sizeof("UNICODELITTLE")]; - char stringpool_str869[sizeof("MACHEBREW")]; - char stringpool_str882[sizeof("BIG5-HKSCS:1999")]; - char stringpool_str884[sizeof("BIG5-HKSCS:2001")]; - char stringpool_str888[sizeof("MS-TURK")]; - char stringpool_str889[sizeof("NEXTSTEP")]; - char stringpool_str891[sizeof("BIG5-HKSCS:2004")]; - char stringpool_str894[sizeof("WINBALTRIM")]; - char stringpool_str902[sizeof("BIG5-HKSCS:2008")]; - char stringpool_str906[sizeof("MACTURKISH")]; - char stringpool_str974[sizeof("CSEUCPKDFMTJAPANESE")]; - char stringpool_str994[sizeof("UNICODEBIG")]; - char stringpool_str999[sizeof("CSISO87JISX0208")]; - }; -static const struct stringpool_t stringpool_contents = - { - "C99", - "CN", - "L1", - "L6", - "CP949", - "L4", - "L5", - "R8", - "L2", - "L8", - "CP819", - "866", - "L3", - "CP154", - "CP866", - "CP1251", - "CP1131", - "CP936", - "CP1361", - "CP1256", - "862", - "CP1254", - "CP862", - "CP1255", - "CP932", - "CP1252", - "HZ", - "CP1258", - "EUCCN", - "EUC-CN", - "CP1253", - "CP1133", - "L10", - "RK1048", - "CP50221", - "CP950", - "850", - "ISO646-CN", - "SJIS", - "CP1250", - "CP850", - "PT154", - "MAC", - "ISO8859-9", - "ISO-8859-9", - "ISO_8859-9", - "ISO8859-1", - "ISO-8859-1", - "ISO_8859-1", - "ISO8859-11", - "ISO-8859-11", - "ISO_8859-11", - "ISO8859-6", - "ISO-8859-6", - "ISO_8859-6", - "ISO8859-16", - "ISO-8859-16", - "ISO_8859-16", - "ISO_8859-16:2001", - "ISO8859-4", - "ISO-8859-4", - "ISO_8859-4", - "ISO8859-14", - "ISO-8859-14", - "ISO_8859-14", - "ISO8859-5", - "ISO-8859-5", - "ISO_8859-5", - "ISO8859-15", - "ISO-8859-15", - "ISO_8859-15", - "ISO8859-2", - "ISO-8859-2", - "ISO_8859-2", - "MS936", - "ISO-IR-199", - "ISO_8859-14:1998", - "ISO8859-8", - "ISO-8859-8", - "ISO_8859-8", - "ISO_8859-15:1998", - "ISO-IR-6", - "ISO-IR-149", - "L7", - "ISO-2022-CN", - "ISO-IR-159", - "CYRILLIC", - "ISO-IR-166", - "ROMAN8", - "ISO-IR-14", - "ISO8859-3", - "ISO-8859-3", - "ISO_8859-3", - "ISO8859-13", - "ISO-8859-13", - "ISO_8859-13", - "CSISO2022CN", - "ISO-IR-126", - "ISO-IR-144", - "MS-CYRL", - "GB2312", - "ISO-IR-165", - "ISO_8859-10:1992", - "LATIN-9", - "LATIN1", - "ISO-IR-226", - "LATIN6", - "ISO-IR-109", - "CYRILLIC-ASIAN", - "CP874", - "ISO-IR-101", - "ISO-IR-148", - "ISO-IR-58", - "LATIN4", - "PTCP154", - "ISO8859-10", - "ISO-8859-10", - "ISO_8859-10", - "TIS620", - "TIS-620", - "MULELAO-1", - "LATIN5", - "UHC", - "ELOT_928", - "ECMA-114", - "LATIN2", - "US", - "ISO-IR-138", - "IBM819", - "HP-ROMAN8", - "LATIN8", - "EUCKR", - "EUC-KR", - "KSC5601", - "KSC_5601", - "UTF-16", - "IBM866", - "ECMA-118", - "KS_C_5601-1989", - "UCS-4", - "LATIN3", - "ISO-IR-110", - "CSUCS4", - "KOREAN", - "ASCII", - "JIS_C6226-1983", - "JP", - "UCS-2", - "TIS620-0", - "TIS620.2529-1", - "KZ-1048", - "IBM862", - "DECHANZI", - "GB_1988-80", - "UTF-8", - "TCVN", - "CSASCII", - "JIS_C6220-1969-RO", - "ISO-IR-203", - "KOI8-R", - "DECKOREAN", - "CSKOI8R", - "CHINESE", - "LATIN10", - "MACROMAN", - "GB_2312-80", - "CSKZ1048", - "UTF-32", - "ISO-2022-CN-EXT", - "ISO-IR-100", - "GB18030", - "TIS620.2533-1", - "ARABIC", - "CSISOLATIN1", - "MS-EE", - "JIS0208", - "CSISOLATIN6", - "CSISOLATINCYRILLIC", - "MS-ANSI", - "TACTIS", - "IBM850", - "CSISOLATIN4", - "CSISOLATINARABIC", - "CSHPROMAN8", - "CSPTCP154", - "STRK1048-2002", - "CSISOLATIN5", - "MACICELAND", - "CSISOLATIN2", - "TIS620.2533-0", - "BIG5", - "BIG-5", - "ISO-IR-179", - "ISO646-US", - "ISO-2022-KR", - "ISO-CELTIC", - "JAVA", - "ARMSCII-8", - "CSISO2022KR", - "MACCROATIAN", - "CSISOLATIN3", - "WINDOWS-1251", - "ISO_8859-9:1989", - "WINDOWS-1256", - "WINDOWS-936", - "MACCYRILLIC", - "UTF-16LE", - "WINDOWS-1254", - "UCS-4LE", - "WINDOWS-1255", - "WINDOWS-1252", - "UCS-2LE", - "VISCII1.1-1", - "WINDOWS-1258", - "CSISO14JISC6220RO", - "ISO-10646-UCS-4", - "CP1257", - "CP367", - "ISO_646.IRV:1991", - "X0212", - "WINDOWS-1253", - "ISO-10646-UCS-2", - "MACROMANIA", - "ISO_8859-4:1988", - "IBM-CP1133", - "ISO_8859-5:1988", - "UNICODE-1-1", - "CSGB2312", - "X0201", - "ASMO-708", - "CSUNICODE11", - "ISO_8859-8:1988", - "WINDOWS-1250", - "UTF-32LE", - "ISO_8859-3:1988", - "VISCII", - "GEORGIAN-ACADEMY", - "EUCJP", - "EUC-JP", - "KS_C_5601-1987", - "CSISO159JISX02121990", - "CSBIG5", - "CN-BIG5", - "X0208", - "CSKSC56011987", - "MACINTOSH", - "MS-HEBR", - "ISO-2022-JP-1", - "MACARABIC", - "HZ-GB-2312", - "CSIBM866", - "ISO-2022-JP-MS", - "CSMACINTOSH", - "ISO-2022-JP-2", - "CSUNICODE", - "MACCENTRALEUROPE", - "ISO646-JP", - "GREEK8", - "GEORGIAN-PS", - "CSISO2022JP2", - "CSEUCKR", - "MACTHAI", - "EUCTW", - "EUC-TW", - "GBK", - "TCVN5712-1", - "ISO8859-7", - "ISO-8859-7", - "ISO_8859-7", - "SHIFT-JIS", - "SHIFT_JIS", - "TCVN-5712", - "US-ASCII", - "KOI8-T", - "CSVISCII", - "CSPC862LATINHEBREW", - "CSHALFWIDTHKATAKANA", - "UCS-4-INTERNAL", - "CSISOLATINHEBREW", - "CN-GB-ISOIR165", - "UCS-2-INTERNAL", - "CN-GB", - "ANSI_X3.4-1986", - "ISO-2022-JP", - "ISO-IR-57", - "ISO-IR-157", - "CSISO58GB231280", - "ISO-IR-127", - "ISO-IR-87", - "WINDOWS-1257", - "CSSHIFTJIS", - "CSISO2022JP", - "ANSI_X3.4-1968", - "ISO_8859-1:1987", - "WINDOWS-874", - "ISO_8859-6:1987", - "MS-ARAB", - "LATIN7", - "ISO_8859-2:1987", - "UTF-16BE", - "UCS-4BE", - "ISO_8859-7:2003", - "GB18030:2022", - "UCS-2BE", - "UNICODE-1-1-UTF-7", - "CSUNICODE11UTF7", - "UTF-7", - "GB18030:2005", - "BIG5HKSCS", - "BIG5-HKSCS", - "UTF-32BE", - "IBM367", - "GREEK", - "HEBREW", - "SDECKANJI", - "CSISOLATINGREEK", - "JIS_X0212", - "UCS-4-SWAPPED", - "JOHAB", - "UCS-2-SWAPPED", - "JIS_X0201", - "CSISO57GB1988", - "JISX0201-1976", - "JIS_X0212-1990", - "CSPC850MULTILINGUAL", - "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", - "JIS_X0208", - "MS_KANJI", - "JIS_X0208-1983", - "JIS_X0212.1990-0", - "JIS_X0208-1990", - "BIGFIVE", - "BIG-FIVE", - "CSEUCTW", - "ISO_8859-7:1987", - "KOI8-U", - "KOI8-RU", - "MS-GREEK", - "MACGREEK", - "TCVN5712-1:1993", - "MACUKRAINE", - "UNICODELITTLE", - "MACHEBREW", - "BIG5-HKSCS:1999", - "BIG5-HKSCS:2001", - "MS-TURK", - "NEXTSTEP", - "BIG5-HKSCS:2004", - "WINBALTRIM", - "BIG5-HKSCS:2008", - "MACTURKISH", - "CSEUCPKDFMTJAPANESE", - "UNICODEBIG", - "CSISO87JISX0208" - }; -#define stringpool ((const char *) &stringpool_contents) - -static const struct alias aliases[] = - { - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 51 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str5, ei_c99}, - {-1}, -#line 289 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str7, ei_iso646_cn}, - {-1}, {-1}, -#line 60 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str10, ei_iso8859_1}, - {-1}, {-1}, -#line 134 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str13, ei_iso8859_10}, - {-1}, {-1}, -#line 359 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str16, ei_cp949}, -#line 84 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str17, ei_iso8859_4}, - {-1}, {-1}, {-1}, -#line 126 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str21, ei_iso8859_9}, -#line 227 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str22, ei_hp_roman8}, - {-1}, -#line 68 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str24, ei_iso8859_2}, - {-1}, {-1}, {-1}, -#line 151 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str28, ei_iso8859_14}, -#line 57 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str29, ei_iso8859_1}, - {-1}, {-1}, {-1}, -#line 207 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str33, ei_cp866}, - {-1}, {-1}, -#line 76 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str36, ei_iso8859_3}, - {-1}, {-1}, {-1}, -#line 236 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str40, ei_pt154}, - {-1}, -#line 205 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str42, ei_cp866}, -#line 174 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str43, ei_cp1251}, -#line 209 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str44, ei_cp1131}, -#line 328 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str45, ei_cp936}, - {-1}, -#line 363 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str47, ei_johab}, - {-1}, -#line 189 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str49, ei_cp1256}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 203 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str55, ei_cp862}, - {-1}, -#line 183 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str57, ei_cp1254}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 201 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str64, ei_cp862}, -#line 186 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str65, ei_cp1255}, - {-1}, -#line 312 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str67, ei_cp932}, - {-1}, {-1}, {-1}, -#line 177 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str71, ei_cp1252}, - {-1}, {-1}, {-1}, -#line 337 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str75, ei_hz}, - {-1}, {-1}, {-1}, -#line 195 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str79, ei_cp1258}, - {-1}, -#line 321 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str81, ei_euc_cn}, -#line 320 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str82, ei_euc_cn}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, -#line 180 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str95, ei_cp1253}, -#line 244 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str96, ei_cp1133}, -#line 165 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str97, ei_iso8859_16}, - {-1}, {-1}, {-1}, -#line 239 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str101, ei_rk1048}, -#line 319 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str102, ei_iso2022_jpms}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 348 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str108, ei_cp950}, - {-1}, {-1}, -#line 199 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str111, ei_cp850}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, -#line 287 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str124, ei_iso646_cn}, -#line 309 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str125, ei_sjis}, - {-1}, -#line 171 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str127, ei_cp1250}, -#line 197 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str128, ei_cp850}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 234 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str137, ei_pt154}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, -#line 212 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str149, ei_mac_roman}, -#line 128 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str150, ei_iso8859_9}, -#line 121 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str151, ei_iso8859_9}, -#line 122 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str152, ei_iso8859_9}, - {-1}, -#line 62 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str154, ei_iso8859_1}, -#line 53 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str155, ei_iso8859_1}, -#line 54 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str156, ei_iso8859_1}, -#line 139 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str157, ei_iso8859_11}, -#line 137 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str158, ei_iso8859_11}, -#line 138 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str159, ei_iso8859_11}, -#line 102 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str160, ei_iso8859_6}, -#line 94 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str161, ei_iso8859_6}, -#line 95 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str162, ei_iso8859_6}, -#line 166 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str163, ei_iso8859_16}, -#line 160 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str164, ei_iso8859_16}, -#line 161 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str165, ei_iso8859_16}, - {-1}, -#line 162 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str167, ei_iso8859_16}, -#line 86 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str168, ei_iso8859_4}, -#line 79 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str169, ei_iso8859_4}, -#line 80 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str170, ei_iso8859_4}, -#line 153 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str171, ei_iso8859_14}, -#line 146 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str172, ei_iso8859_14}, -#line 147 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str173, ei_iso8859_14}, - {-1}, {-1}, -#line 93 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str176, ei_iso8859_5}, -#line 87 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str177, ei_iso8859_5}, -#line 88 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str178, ei_iso8859_5}, -#line 159 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str179, ei_iso8859_15}, -#line 154 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str180, ei_iso8859_15}, -#line 155 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str181, ei_iso8859_15}, -#line 70 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str182, ei_iso8859_2}, -#line 63 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str183, ei_iso8859_2}, -#line 64 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str184, ei_iso8859_2}, -#line 329 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str185, ei_cp936}, - {-1}, {-1}, -#line 149 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str188, ei_iso8859_14}, -#line 148 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str189, ei_iso8859_14}, -#line 120 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str190, ei_iso8859_8}, -#line 114 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str191, ei_iso8859_8}, -#line 115 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str192, ei_iso8859_8}, -#line 156 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str193, ei_iso8859_15}, -#line 16 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str194, ei_ascii}, - {-1}, {-1}, -#line 299 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str197, ei_ksc5601}, -#line 144 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str198, ei_iso8859_13}, -#line 334 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str199, ei_iso2022_cn}, - {-1}, -#line 284 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str201, ei_jisx0212}, -#line 91 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str202, ei_iso8859_5}, -#line 252 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str203, ei_tis620}, -#line 226 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str204, ei_hp_roman8}, -#line 265 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str205, ei_iso646_jp}, -#line 78 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str206, ei_iso8859_3}, -#line 71 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str207, ei_iso8859_3}, -#line 72 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str208, ei_iso8859_3}, -#line 145 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str209, ei_iso8859_13}, -#line 140 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str210, ei_iso8859_13}, -#line 141 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str211, ei_iso8859_13}, -#line 335 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str212, ei_iso2022_cn}, - {-1}, -#line 107 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str214, ei_iso8859_7}, -#line 90 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str215, ei_iso8859_5}, - {-1}, -#line 176 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str217, ei_cp1251}, -#line 322 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str218, ei_euc_cn}, -#line 294 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str219, ei_isoir165}, -#line 131 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str220, ei_iso8859_10}, - {-1}, -#line 158 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str222, ei_iso8859_15}, - {-1}, {-1}, -#line 59 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str225, ei_iso8859_1}, - {-1}, {-1}, -#line 163 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str228, ei_iso8859_16}, - {-1}, {-1}, -#line 133 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str231, ei_iso8859_10}, -#line 74 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str232, ei_iso8859_3}, -#line 237 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str233, ei_pt154}, - {-1}, -#line 254 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str235, ei_cp874}, -#line 66 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str236, ei_iso8859_2}, -#line 124 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str237, ei_iso8859_9}, -#line 292 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str238, ei_gb2312}, -#line 83 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str239, ei_iso8859_4}, -#line 235 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str240, ei_pt154}, -#line 136 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str241, ei_iso8859_10}, -#line 129 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str242, ei_iso8859_10}, -#line 130 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str243, ei_iso8859_10}, -#line 247 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str244, ei_tis620}, -#line 246 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str245, ei_tis620}, -#line 243 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str246, ei_mulelao}, -#line 125 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str247, ei_iso8859_9}, -#line 360 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str248, ei_cp949}, -#line 109 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str249, ei_iso8859_7}, - {-1}, -#line 98 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str251, ei_iso8859_6}, - {-1}, -#line 67 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str253, ei_iso8859_2}, -#line 21 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str254, ei_ascii}, - {-1}, -#line 117 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str256, ei_iso8859_8}, - {-1}, -#line 58 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str258, ei_iso8859_1}, -#line 225 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str259, ei_hp_roman8}, - {-1}, -#line 150 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str261, ei_iso8859_14}, - {-1}, -#line 356 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str263, ei_euc_kr}, -#line 355 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str264, ei_euc_kr}, -#line 361 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str265, ei_cp949}, - {-1}, -#line 296 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str267, ei_ksc5601}, - {-1}, -#line 38 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str269, ei_utf16}, - {-1}, -#line 206 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str271, ei_cp866}, - {-1}, -#line 108 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str273, ei_iso8859_7}, -#line 298 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str274, ei_ksc5601}, -#line 33 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str275, ei_ucs4}, - {-1}, -#line 75 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str277, ei_iso8859_3}, -#line 82 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str278, ei_iso8859_4}, - {-1}, -#line 35 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str280, ei_ucs4}, -#line 301 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str281, ei_ksc5601}, - {-1}, {-1}, -#line 13 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str284, ei_ascii}, - {-1}, {-1}, -#line 278 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str287, ei_jisx0208}, -#line 266 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str288, ei_iso646_jp}, -#line 24 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str289, ei_ucs2}, -#line 248 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str290, ei_tis620}, -#line 249 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str291, ei_tis620}, -#line 241 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str292, ei_rk1048}, -#line 202 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str293, ei_cp862}, -#line 326 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str294, ei_euc_cn}, -#line 286 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str295, ei_iso646_cn}, -#line 23 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str296, ei_utf8}, - {-1}, -#line 259 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str298, ei_tcvn}, -#line 22 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str299, ei_ascii}, - {-1}, -#line 263 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str301, ei_iso646_jp}, -#line 157 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str302, ei_iso8859_15}, - {-1}, -#line 167 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str304, ei_koi8_r}, -#line 358 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str305, ei_euc_kr}, - {-1}, -#line 168 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str307, ei_koi8_r}, - {-1}, -#line 325 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str309, ei_euc_cn}, - {-1}, {-1}, -#line 164 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str312, ei_iso8859_16}, -#line 210 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str313, ei_mac_roman}, - {-1}, -#line 291 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str315, ei_gb2312}, -#line 242 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str316, ei_rk1048}, -#line 41 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str317, ei_utf32}, -#line 336 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str318, ei_iso2022_cn_ext}, - {-1}, -#line 56 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str320, ei_iso8859_1}, - {-1}, {-1}, -#line 331 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str323, ei_gb18030_2005}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 251 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str331, ei_tis620}, - {-1}, {-1}, {-1}, {-1}, -#line 100 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str336, ei_iso8859_6}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 61 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str344, ei_iso8859_1}, -#line 173 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str345, ei_cp1250}, - {-1}, {-1}, {-1}, -#line 275 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str349, ei_jisx0208}, -#line 135 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str350, ei_iso8859_10}, -#line 92 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str351, ei_iso8859_5}, -#line 179 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str352, ei_cp1252}, - {-1}, -#line 253 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str354, ei_tis620}, - {-1}, {-1}, -#line 198 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str357, ei_cp850}, -#line 85 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str358, ei_iso8859_4}, - {-1}, -#line 101 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str360, ei_iso8859_6}, -#line 228 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str361, ei_hp_roman8}, -#line 238 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str362, ei_pt154}, - {-1}, {-1}, -#line 240 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str365, ei_rk1048}, -#line 127 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str366, ei_iso8859_9}, - {-1}, {-1}, {-1}, -#line 215 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str370, ei_mac_iceland}, - {-1}, -#line 69 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str372, ei_iso8859_2}, -#line 250 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str373, ei_tis620}, - {-1}, {-1}, -#line 342 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str376, ei_ces_big5}, -#line 343 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str377, ei_ces_big5}, -#line 142 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str378, ei_iso8859_13}, -#line 14 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str379, ei_ascii}, - {-1}, -#line 364 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str381, ei_iso2022_kr}, -#line 152 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str382, ei_iso8859_14}, - {-1}, {-1}, {-1}, {-1}, -#line 52 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str387, ei_java}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 230 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str393, ei_armscii_8}, -#line 365 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str394, ei_iso2022_kr}, -#line 216 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str395, ei_mac_croatian}, -#line 77 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str396, ei_iso8859_3}, - {-1}, -#line 175 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str398, ei_cp1251}, -#line 123 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str399, ei_iso8859_9}, - {-1}, -#line 190 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str401, ei_cp1256}, -#line 330 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str402, ei_cp936}, -#line 218 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str403, ei_mac_cyrillic}, -#line 40 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str404, ei_utf16le}, -#line 184 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str405, ei_cp1254}, -#line 37 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str406, ei_ucs4le}, - {-1}, {-1}, -#line 187 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str409, ei_cp1255}, - {-1}, {-1}, -#line 178 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str412, ei_cp1252}, -#line 31 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str413, ei_ucs2le}, - {-1}, -#line 257 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str415, ei_viscii}, -#line 196 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str416, ei_cp1258}, -#line 267 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str417, ei_iso646_jp}, -#line 34 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str418, ei_ucs4}, -#line 192 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str419, ei_cp1257}, -#line 19 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str420, ei_ascii}, -#line 15 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str421, ei_ascii}, -#line 283 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str422, ei_jisx0212}, - {-1}, -#line 181 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str424, ei_cp1253}, -#line 25 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str425, ei_ucs2}, -#line 217 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str426, ei_mac_romania}, - {-1}, -#line 81 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str428, ei_iso8859_4}, -#line 245 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str429, ei_cp1133}, - {-1}, {-1}, -#line 89 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str432, ei_iso8859_5}, -#line 29 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str433, ei_ucs2be}, -#line 324 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str434, ei_euc_cn}, - {-1}, -#line 270 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str436, ei_jisx0201}, -#line 99 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str437, ei_iso8859_6}, -#line 30 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str438, ei_ucs2be}, -#line 116 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str439, ei_iso8859_8}, -#line 172 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str440, ei_cp1250}, -#line 43 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str441, ei_utf32le}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 73 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str447, ei_iso8859_3}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 256 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str453, ei_viscii}, - {-1}, {-1}, {-1}, -#line 231 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str457, ei_georgian_academy}, -#line 303 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str458, ei_euc_jp}, -#line 302 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str459, ei_euc_jp}, - {-1}, {-1}, {-1}, {-1}, -#line 297 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str464, ei_ksc5601}, - {-1}, -#line 285 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str466, ei_jisx0212}, - {-1}, -#line 347 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str468, ei_ces_big5}, -#line 346 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str469, ei_ces_big5}, - {-1}, {-1}, -#line 276 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str472, ei_jisx0208}, - {-1}, -#line 300 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str474, ei_ksc5601}, - {-1}, {-1}, -#line 211 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str477, ei_mac_roman}, - {-1}, -#line 188 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str479, ei_cp1255}, - {-1}, -#line 315 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str481, ei_iso2022_jp1}, - {-1}, -#line 223 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str483, ei_mac_arabic}, - {-1}, {-1}, -#line 338 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str486, ei_hz}, -#line 208 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str487, ei_cp866}, - {-1}, {-1}, {-1}, -#line 318 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str491, ei_iso2022_jpms}, - {-1}, {-1}, -#line 213 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str494, ei_mac_roman}, -#line 316 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str495, ei_iso2022_jp2}, -#line 26 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str496, ei_ucs2}, - {-1}, {-1}, {-1}, -#line 214 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str500, ei_mac_centraleurope}, -#line 264 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str501, ei_iso646_jp}, -#line 110 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str502, ei_iso8859_7}, - {-1}, -#line 232 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str504, ei_georgian_ps}, - {-1}, {-1}, -#line 317 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str507, ei_iso2022_jp2}, -#line 357 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str508, ei_euc_kr}, - {-1}, -#line 224 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str510, ei_mac_thai}, -#line 340 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str511, ei_euc_tw}, -#line 339 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str512, ei_euc_tw}, - {-1}, {-1}, {-1}, {-1}, -#line 327 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str517, ei_ces_gbk}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 261 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str526, ei_tcvn}, - {-1}, {-1}, {-1}, -#line 113 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str530, ei_iso8859_7}, -#line 103 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str531, ei_iso8859_7}, -#line 104 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str532, ei_iso8859_7}, -#line 308 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str533, ei_sjis}, -#line 307 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str534, ei_sjis}, - {-1}, {-1}, -#line 260 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str537, ei_tcvn}, - {-1}, -#line 12 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str539, ei_ascii}, -#line 233 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str540, ei_koi8_t}, - {-1}, {-1}, {-1}, {-1}, -#line 258 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str545, ei_viscii}, - {-1}, -#line 204 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str547, ei_cp862}, - {-1}, {-1}, {-1}, {-1}, -#line 271 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str552, ei_jisx0201}, - {-1}, {-1}, {-1}, -#line 49 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str556, ei_ucs4internal}, -#line 119 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str557, ei_iso8859_8}, - {-1}, {-1}, {-1}, {-1}, -#line 295 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str562, ei_isoir165}, -#line 47 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str563, ei_ucs2internal}, - {-1}, -#line 323 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str565, ei_euc_cn}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 18 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str575, ei_ascii}, -#line 313 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str576, ei_iso2022_jp}, - {-1}, -#line 288 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str578, ei_iso646_cn}, - {-1}, {-1}, -#line 132 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str581, ei_iso8859_10}, - {-1}, -#line 293 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str583, ei_gb2312}, -#line 97 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str584, ei_iso8859_6}, -#line 277 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str585, ei_jisx0208}, -#line 193 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str586, ei_cp1257}, - {-1}, -#line 311 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str588, ei_sjis}, -#line 314 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str589, ei_iso2022_jp}, -#line 17 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str590, ei_ascii}, -#line 55 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str591, ei_iso8859_1}, -#line 255 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str592, ei_cp874}, - {-1}, -#line 96 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str594, ei_iso8859_6}, - {-1}, {-1}, {-1}, {-1}, -#line 191 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str599, ei_cp1256}, - {-1}, -#line 143 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str601, ei_iso8859_13}, - {-1}, {-1}, {-1}, -#line 65 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str605, ei_iso8859_2}, - {-1}, {-1}, {-1}, {-1}, -#line 39 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str610, ei_utf16be}, - {-1}, -#line 36 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str612, ei_ucs4be}, - {-1}, {-1}, {-1}, {-1}, -#line 106 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str617, ei_iso8859_7}, -#line 333 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str618, ei_gb18030_2022}, -#line 27 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str619, ei_ucs2be}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 45 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str627, ei_utf7}, - {-1}, {-1}, -#line 46 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str630, ei_utf7}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 44 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str636, ei_utf7}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 332 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str643, ei_gb18030_2005}, - {-1}, -#line 353 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str645, ei_big5hkscs2008}, -#line 352 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str646, ei_big5hkscs2008}, -#line 42 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str647, ei_utf32be}, - {-1}, -#line 20 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str649, ei_ascii}, - {-1}, -#line 111 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str651, ei_iso8859_7}, - {-1}, {-1}, {-1}, {-1}, -#line 118 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str656, ei_iso8859_8}, -#line 306 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str657, ei_euc_jp}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, -#line 112 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str668, ei_iso8859_7}, -#line 280 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str669, ei_jisx0212}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 50 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str675, ei_ucs4swapped}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 362 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str681, ei_johab}, -#line 48 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str682, ei_ucs2swapped}, -#line 268 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str683, ei_jisx0201}, - {-1}, -#line 290 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str685, ei_iso646_cn}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 269 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str691, ei_jisx0201}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, -#line 282 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str704, ei_jisx0212}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 200 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str712, ei_cp850}, -#line 304 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str713, ei_euc_jp}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 272 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str719, ei_jisx0208}, -#line 310 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str720, ei_sjis}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, -#line 273 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str734, ei_jisx0208}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 281 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str743, ei_jisx0212}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 274 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str750, ei_jisx0208}, - {-1}, {-1}, -#line 345 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str753, ei_ces_big5}, -#line 344 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str754, ei_ces_big5}, - {-1}, -#line 341 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str756, ei_euc_tw}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, -#line 105 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str779, ei_iso8859_7}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 169 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str786, ei_koi8_u}, -#line 170 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str787, ei_koi8_ru}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 182 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str796, ei_cp1253}, - {-1}, -#line 220 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str798, ei_mac_greek}, -#line 262 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str799, ei_tcvn}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, -#line 219 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str821, ei_mac_ukraine}, - {-1}, {-1}, {-1}, -#line 32 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str825, ei_ucs2le}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 222 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str869, ei_mac_hebrew}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, -#line 349 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str882, ei_big5hkscs1999}, - {-1}, -#line 350 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str884, ei_big5hkscs2001}, - {-1}, {-1}, {-1}, -#line 185 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str888, ei_cp1254}, -#line 229 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str889, ei_nextstep}, - {-1}, -#line 351 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str891, ei_big5hkscs2004}, - {-1}, {-1}, -#line 194 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str894, ei_cp1257}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 354 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str902, ei_big5hkscs2008}, - {-1}, {-1}, {-1}, -#line 221 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str906, ei_mac_turkish}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, -#line 305 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str974, ei_euc_jp}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, -#line 28 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str994, ei_ucs2be}, - {-1}, {-1}, {-1}, {-1}, -#line 279 "lib/generated/aliases_sysosf1.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str999, ei_jisx0208} - }; - -const struct alias * -HashPool::aliases_lookup (const char *str, size_t len) -{ - if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) - { - unsigned int key = aliases_hash (str, len); - - if (key <= MAX_HASH_VALUE) - { - int o = aliases[key].name; - if (o >= 0) - { - const char *s = o + stringpool; - - if (*str == *s && !strcmp (str + 1, s + 1)) - return &aliases[key]; - } - } - } - return 0; -} diff --git a/lib/generated/aliases_syssolaris.h b/lib/generated/aliases_syssolaris.h deleted file mode 100644 index b7ecc950..00000000 --- a/lib/generated/aliases_syssolaris.h +++ /dev/null @@ -1,1754 +0,0 @@ -/* C++ code produced by gperf version 3.1 */ -/* Command-line: gperf -L C++ -Z HashPool -m 10 lib/generated/aliases_syssolaris.gperf */ -/* Computed positions: -k'1,3-11,$' */ - -#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ - && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ - && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ - && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ - && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ - && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ - && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ - && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ - && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ - && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ - && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ - && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ - && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ - && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ - && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ - && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ - && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ - && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ - && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ - && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ - && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ - && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ - && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) -/* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." -#endif - -#line 1 "lib/generated/aliases_syssolaris.gperf" -struct alias { int name; unsigned int encoding_index; }; - -#define TOTAL_KEYWORDS 356 -#define MIN_WORD_LENGTH 2 -#define MAX_WORD_LENGTH 45 -#define MIN_HASH_VALUE 6 -#define MAX_HASH_VALUE 919 -/* maximum key range = 914, duplicates = 0 */ - -class HashPool -{ -private: - static inline unsigned int aliases_hash (const char *str, size_t len); -public: - static const struct alias *aliases_lookup (const char *str, size_t len); -}; - -inline unsigned int -HashPool::aliases_hash (const char *str, size_t len) -{ - static const unsigned short asso_values[] = - { - 920, 920, 920, 920, 920, 920, 920, 920, 920, 920, - 920, 920, 920, 920, 920, 920, 920, 920, 920, 920, - 920, 920, 920, 920, 920, 920, 920, 920, 920, 920, - 920, 920, 920, 920, 920, 920, 920, 920, 920, 920, - 920, 920, 920, 920, 920, 10, 1, 920, 29, 0, - 5, 74, 47, 2, 1, 150, 4, 11, 271, 920, - 920, 920, 920, 920, 920, 60, 172, 1, 3, 71, - 164, 91, 54, 0, 205, 108, 135, 85, 8, 0, - 145, 920, 41, 74, 8, 74, 227, 141, 174, 7, - 2, 920, 920, 920, 920, 70, 920, 920, 920, 920, - 920, 920, 920, 920, 920, 920, 920, 920, 920, 920, - 920, 920, 920, 920, 920, 920, 920, 920, 920, 920, - 920, 920, 920, 920, 920, 920, 920, 920 - }; - unsigned int hval = len; - - switch (hval) - { - default: - hval += asso_values[static_cast(str[10])]; - /*FALLTHROUGH*/ - case 10: - hval += asso_values[static_cast(str[9])]; - /*FALLTHROUGH*/ - case 9: - hval += asso_values[static_cast(str[8])]; - /*FALLTHROUGH*/ - case 8: - hval += asso_values[static_cast(str[7])]; - /*FALLTHROUGH*/ - case 7: - hval += asso_values[static_cast(str[6])]; - /*FALLTHROUGH*/ - case 6: - hval += asso_values[static_cast(str[5])]; - /*FALLTHROUGH*/ - case 5: - hval += asso_values[static_cast(str[4])]; - /*FALLTHROUGH*/ - case 4: - hval += asso_values[static_cast(str[3])]; - /*FALLTHROUGH*/ - case 3: - hval += asso_values[static_cast(str[2])]; - /*FALLTHROUGH*/ - case 2: - case 1: - hval += asso_values[static_cast(str[0])]; - break; - } - return hval + asso_values[static_cast(str[len - 1])]; -} - -struct stringpool_t - { - char stringpool_str6[sizeof("646")]; - char stringpool_str9[sizeof("866")]; - char stringpool_str11[sizeof("CN")]; - char stringpool_str13[sizeof("CP866")]; - char stringpool_str14[sizeof("CP1251")]; - char stringpool_str16[sizeof("CP1256")]; - char stringpool_str17[sizeof("862")]; - char stringpool_str18[sizeof("CP1255")]; - char stringpool_str21[sizeof("CP862")]; - char stringpool_str22[sizeof("CP1258")]; - char stringpool_str24[sizeof("CP1252")]; - char stringpool_str26[sizeof("C99")]; - char stringpool_str32[sizeof("CP819")]; - char stringpool_str35[sizeof("5601")]; - char stringpool_str40[sizeof("ISO8859-1")]; - char stringpool_str41[sizeof("ISO8859-11")]; - char stringpool_str42[sizeof("ISO8859-6")]; - char stringpool_str43[sizeof("ISO8859-16")]; - char stringpool_str44[sizeof("ISO8859-5")]; - char stringpool_str45[sizeof("ISO8859-15")]; - char stringpool_str47[sizeof("R8")]; - char stringpool_str48[sizeof("ISO8859-8")]; - char stringpool_str49[sizeof("CP50221")]; - char stringpool_str50[sizeof("ISO8859-2")]; - char stringpool_str51[sizeof("ISO-8859-1")]; - char stringpool_str52[sizeof("ISO-8859-11")]; - char stringpool_str53[sizeof("ISO-8859-6")]; - char stringpool_str54[sizeof("ISO-8859-16")]; - char stringpool_str55[sizeof("ISO-8859-5")]; - char stringpool_str56[sizeof("ISO-8859-15")]; - char stringpool_str58[sizeof("HZ")]; - char stringpool_str59[sizeof("ISO-8859-8")]; - char stringpool_str61[sizeof("ISO-8859-2")]; - char stringpool_str62[sizeof("ISO8859-9")]; - char stringpool_str65[sizeof("850")]; - char stringpool_str66[sizeof("ASCII")]; - char stringpool_str70[sizeof("CP850")]; - char stringpool_str71[sizeof("ISO-IR-6")]; - char stringpool_str72[sizeof("CP1250")]; - char stringpool_str73[sizeof("ISO-8859-9")]; - char stringpool_str74[sizeof("ISO-IR-166")]; - char stringpool_str76[sizeof("ISO-IR-165")]; - char stringpool_str77[sizeof("CP950")]; - char stringpool_str78[sizeof("ISO-IR-126")]; - char stringpool_str79[sizeof("UHC")]; - char stringpool_str80[sizeof("ISO-IR-58")]; - char stringpool_str81[sizeof("CP1131")]; - char stringpool_str82[sizeof("CP1361")]; - char stringpool_str83[sizeof("ISO-IR-226")]; - char stringpool_str85[sizeof("ISO646-CN")]; - char stringpool_str86[sizeof("CP949")]; - char stringpool_str90[sizeof("MAC")]; - char stringpool_str92[sizeof("ISO-2022-CN")]; - char stringpool_str93[sizeof("CP936")]; - char stringpool_str94[sizeof("EUCCN")]; - char stringpool_str95[sizeof("ISO-IR-159")]; - char stringpool_str96[sizeof("ISO-2022-CN-EXT")]; - char stringpool_str98[sizeof("IBM866")]; - char stringpool_str99[sizeof("ISO8859-10")]; - char stringpool_str100[sizeof("ISO-IR-101")]; - char stringpool_str101[sizeof("CP932")]; - char stringpool_str102[sizeof("CP154")]; - char stringpool_str104[sizeof("ISO-IR-199")]; - char stringpool_str105[sizeof("EUC-CN")]; - char stringpool_str106[sizeof("IBM862")]; - char stringpool_str108[sizeof("CP1254")]; - char stringpool_str110[sizeof("ISO-8859-10")]; - char stringpool_str111[sizeof("ISO_8859-1")]; - char stringpool_str112[sizeof("ISO_8859-11")]; - char stringpool_str113[sizeof("ISO_8859-6")]; - char stringpool_str114[sizeof("ISO_8859-16")]; - char stringpool_str115[sizeof("ISO_8859-5")]; - char stringpool_str116[sizeof("ISO_8859-15")]; - char stringpool_str117[sizeof("IBM819")]; - char stringpool_str118[sizeof("ISO_8859-16:2001")]; - char stringpool_str119[sizeof("ISO_8859-8")]; - char stringpool_str121[sizeof("ISO_8859-2")]; - char stringpool_str122[sizeof("ISO-IR-109")]; - char stringpool_str123[sizeof("ISO_8859-15:1998")]; - char stringpool_str126[sizeof("ISO-IR-148")]; - char stringpool_str129[sizeof("ISO-IR-110")]; - char stringpool_str131[sizeof("RK1048")]; - char stringpool_str133[sizeof("ISO_8859-9")]; - char stringpool_str134[sizeof("ISO8859-4")]; - char stringpool_str135[sizeof("ISO8859-14")]; - char stringpool_str137[sizeof("L1")]; - char stringpool_str138[sizeof("L6")]; - char stringpool_str139[sizeof("L5")]; - char stringpool_str140[sizeof("ISO-IR-149")]; - char stringpool_str141[sizeof("L8")]; - char stringpool_str142[sizeof("L2")]; - char stringpool_str143[sizeof("CSASCII")]; - char stringpool_str144[sizeof("KOI8-T")]; - char stringpool_str145[sizeof("ISO-8859-4")]; - char stringpool_str146[sizeof("ISO-8859-14")]; - char stringpool_str147[sizeof("CSISO2022CN")]; - char stringpool_str150[sizeof("US")]; - char stringpool_str151[sizeof("ISO_8859-10:1992")]; - char stringpool_str152[sizeof("TIS620")]; - char stringpool_str153[sizeof("ISO-IR-138")]; - char stringpool_str154[sizeof("TIS620.2529-1")]; - char stringpool_str155[sizeof("IBM850")]; - char stringpool_str157[sizeof("LATIN1")]; - char stringpool_str158[sizeof("ISO-IR-100")]; - char stringpool_str159[sizeof("LATIN6")]; - char stringpool_str160[sizeof("ANSI-1251")]; - char stringpool_str161[sizeof("LATIN5")]; - char stringpool_str162[sizeof("CP1253")]; - char stringpool_str163[sizeof("TIS-620")]; - char stringpool_str164[sizeof("ISO-IR-14")]; - char stringpool_str165[sizeof("LATIN8")]; - char stringpool_str167[sizeof("LATIN2")]; - char stringpool_str168[sizeof("ISO_8859-14:1998")]; - char stringpool_str169[sizeof("CSUNICODE11")]; - char stringpool_str170[sizeof("ISO_8859-10")]; - char stringpool_str173[sizeof("UCS-2")]; - char stringpool_str177[sizeof("MS936")]; - char stringpool_str180[sizeof("UNICODE-1-1")]; - char stringpool_str181[sizeof("ELOT_928")]; - char stringpool_str184[sizeof("L4")]; - char stringpool_str186[sizeof("GB2312")]; - char stringpool_str188[sizeof("ISO8859-3")]; - char stringpool_str189[sizeof("ISO8859-13")]; - char stringpool_str190[sizeof("LATIN-9")]; - char stringpool_str192[sizeof("ISO-10646-UCS-2")]; - char stringpool_str193[sizeof("TIS620-0")]; - char stringpool_str194[sizeof("X0212")]; - char stringpool_str196[sizeof("L10")]; - char stringpool_str199[sizeof("ISO-8859-3")]; - char stringpool_str200[sizeof("ISO-8859-13")]; - char stringpool_str202[sizeof("CSKOI8R")]; - char stringpool_str203[sizeof("CSKZ1048")]; - char stringpool_str205[sizeof("ISO_8859-4")]; - char stringpool_str206[sizeof("ISO_8859-14")]; - char stringpool_str208[sizeof("ROMAN8")]; - char stringpool_str209[sizeof("KZ-1048")]; - char stringpool_str210[sizeof("KOI8-R")]; - char stringpool_str211[sizeof("L3")]; - char stringpool_str212[sizeof("ISO-IR-144")]; - char stringpool_str213[sizeof("X0201")]; - char stringpool_str215[sizeof("MACTHAI")]; - char stringpool_str216[sizeof("LATIN10")]; - char stringpool_str219[sizeof("KSC_5601")]; - char stringpool_str221[sizeof("X0208")]; - char stringpool_str226[sizeof("SJIS")]; - char stringpool_str227[sizeof("US-ASCII")]; - char stringpool_str229[sizeof("CP1133")]; - char stringpool_str234[sizeof("ISO-10646-UCS-4")]; - char stringpool_str237[sizeof("ISO-CELTIC")]; - char stringpool_str238[sizeof("CSUNICODE")]; - char stringpool_str242[sizeof("ECMA-118")]; - char stringpool_str243[sizeof("ISO-IR-179")]; - char stringpool_str244[sizeof("MS-ANSI")]; - char stringpool_str246[sizeof("PT154")]; - char stringpool_str247[sizeof("ARMSCII-8")]; - char stringpool_str250[sizeof("CSUCS4")]; - char stringpool_str251[sizeof("LATIN4")]; - char stringpool_str253[sizeof("ISO-IR-203")]; - char stringpool_str254[sizeof("CP874")]; - char stringpool_str255[sizeof("TCVN")]; - char stringpool_str256[sizeof("UTF-16")]; - char stringpool_str257[sizeof("UCS-4")]; - char stringpool_str259[sizeof("ISO_8859-3")]; - char stringpool_str260[sizeof("ISO_8859-13")]; - char stringpool_str261[sizeof("UTF-8")]; - char stringpool_str262[sizeof("GB_1988-80")]; - char stringpool_str263[sizeof("GB18030")]; - char stringpool_str265[sizeof("ISO-2022-KR")]; - char stringpool_str267[sizeof("EUCKR")]; - char stringpool_str271[sizeof("BIG5")]; - char stringpool_str273[sizeof("CSIBM866")]; - char stringpool_str274[sizeof("CSBIG5")]; - char stringpool_str275[sizeof("HP-ROMAN8")]; - char stringpool_str276[sizeof("KOI8-U")]; - char stringpool_str278[sizeof("EUC-KR")]; - char stringpool_str279[sizeof("CNS11643")]; - char stringpool_str282[sizeof("BIG-5")]; - char stringpool_str283[sizeof("MACCROATIAN")]; - char stringpool_str285[sizeof("CN-BIG5")]; - char stringpool_str286[sizeof("TIS620.2533-1")]; - char stringpool_str287[sizeof("L7")]; - char stringpool_str290[sizeof("ISO646-US")]; - char stringpool_str293[sizeof("MACINTOSH")]; - char stringpool_str296[sizeof("MACROMAN")]; - char stringpool_str297[sizeof("CSISOLATIN1")]; - char stringpool_str299[sizeof("CSISOLATIN6")]; - char stringpool_str300[sizeof("ARABIC")]; - char stringpool_str301[sizeof("CSISOLATIN5")]; - char stringpool_str302[sizeof("KOREAN")]; - char stringpool_str303[sizeof("CHINESE")]; - char stringpool_str305[sizeof("LATIN3")]; - char stringpool_str306[sizeof("CSISOLATINCYRILLIC")]; - char stringpool_str307[sizeof("CSISOLATIN2")]; - char stringpool_str308[sizeof("VISCII")]; - char stringpool_str310[sizeof("GBK")]; - char stringpool_str311[sizeof("CSVISCII")]; - char stringpool_str313[sizeof("MS-EE")]; - char stringpool_str314[sizeof("CP1257")]; - char stringpool_str315[sizeof("TIS620.2533-0")]; - char stringpool_str316[sizeof("KS_C_5601-1989")]; - char stringpool_str318[sizeof("KOI8-RU")]; - char stringpool_str320[sizeof("CSISO2022KR")]; - char stringpool_str322[sizeof("CYRILLIC")]; - char stringpool_str323[sizeof("CSUNICODE11UTF7")]; - char stringpool_str324[sizeof("VISCII1.1-1")]; - char stringpool_str327[sizeof("GB_2312-80")]; - char stringpool_str328[sizeof("ECMA-114")]; - char stringpool_str336[sizeof("UNICODE-1-1-UTF-7")]; - char stringpool_str338[sizeof("UTF-32")]; - char stringpool_str340[sizeof("ISO8859-7")]; - char stringpool_str344[sizeof("CSEUCKR")]; - char stringpool_str350[sizeof("ASMO-708")]; - char stringpool_str351[sizeof("ISO-8859-7")]; - char stringpool_str352[sizeof("JP")]; - char stringpool_str355[sizeof("GREEK8")]; - char stringpool_str356[sizeof("CSMACINTOSH")]; - char stringpool_str357[sizeof("JIS0208")]; - char stringpool_str358[sizeof("TIS620.2533")]; - char stringpool_str361[sizeof("CSGB2312")]; - char stringpool_str363[sizeof("CSISOLATINARABIC")]; - char stringpool_str364[sizeof("PCK")]; - char stringpool_str365[sizeof("STRK1048-2002")]; - char stringpool_str367[sizeof("EUCTW")]; - char stringpool_str372[sizeof("ISO-IR-57")]; - char stringpool_str373[sizeof("ISO-IR-157")]; - char stringpool_str374[sizeof("ISO-IR-87")]; - char stringpool_str376[sizeof("ISO-IR-127")]; - char stringpool_str377[sizeof("MACICELAND")]; - char stringpool_str378[sizeof("EUC-TW")]; - char stringpool_str381[sizeof("CP367")]; - char stringpool_str384[sizeof("UNICODELITTLE")]; - char stringpool_str385[sizeof("GEORGIAN-ACADEMY")]; - char stringpool_str390[sizeof("CSKSC56011987")]; - char stringpool_str391[sizeof("CSISOLATIN4")]; - char stringpool_str393[sizeof("ISO_8859-5:1988")]; - char stringpool_str394[sizeof("PTCP154")]; - char stringpool_str395[sizeof("ISO_8859-8:1988")]; - char stringpool_str396[sizeof("WINDOWS-1251")]; - char stringpool_str397[sizeof("WINDOWS-1256")]; - char stringpool_str398[sizeof("WINDOWS-1255")]; - char stringpool_str400[sizeof("WINDOWS-1258")]; - char stringpool_str401[sizeof("WINDOWS-1252")]; - char stringpool_str404[sizeof("ISO_646.IRV:1991")]; - char stringpool_str405[sizeof("CSPTCP154")]; - char stringpool_str409[sizeof("ISO_8859-9:1989")]; - char stringpool_str410[sizeof("MACROMANIA")]; - char stringpool_str411[sizeof("ISO_8859-7")]; - char stringpool_str412[sizeof("CSHPROMAN8")]; - char stringpool_str415[sizeof("CN-GB-ISOIR165")]; - char stringpool_str416[sizeof("CSISO159JISX02121990")]; - char stringpool_str417[sizeof("JIS_C6220-1969-RO")]; - char stringpool_str418[sizeof("MACCYRILLIC")]; - char stringpool_str419[sizeof("CSISO14JISC6220RO")]; - char stringpool_str420[sizeof("TCVN5712-1")]; - char stringpool_str421[sizeof("MS-CYRL")]; - char stringpool_str424[sizeof("TCVN-5712")]; - char stringpool_str425[sizeof("WINDOWS-1250")]; - char stringpool_str427[sizeof("ISO-2022-JP-1")]; - char stringpool_str430[sizeof("MACARABIC")]; - char stringpool_str432[sizeof("ISO-2022-JP-2")]; - char stringpool_str436[sizeof("HZ-GB-2312")]; - char stringpool_str438[sizeof("ISO_8859-4:1988")]; - char stringpool_str441[sizeof("MS-TURK")]; - char stringpool_str443[sizeof("WINDOWS-1254")]; - char stringpool_str444[sizeof("CSEUCTW")]; - char stringpool_str445[sizeof("CSISOLATIN3")]; - char stringpool_str447[sizeof("UCS-2LE")]; - char stringpool_str450[sizeof("UCS-2-INTERNAL")]; - char stringpool_str451[sizeof("CN-GB")]; - char stringpool_str454[sizeof("GREEK")]; - char stringpool_str455[sizeof("KS_C_5601-1987")]; - char stringpool_str457[sizeof("LATIN7")]; - char stringpool_str460[sizeof("JIS_C6226-1983")]; - char stringpool_str465[sizeof("ISO_8859-3:1988")]; - char stringpool_str466[sizeof("IBM367")]; - char stringpool_str467[sizeof("CSISO58GB231280")]; - char stringpool_str470[sizeof("WINDOWS-1253")]; - char stringpool_str473[sizeof("IBM-CP1133")]; - char stringpool_str475[sizeof("WINDOWS-936")]; - char stringpool_str479[sizeof("CYRILLIC-ASIAN")]; - char stringpool_str481[sizeof("MS-HEBR")]; - char stringpool_str484[sizeof("UCS-2BE")]; - char stringpool_str486[sizeof("CSISO2022JP2")]; - char stringpool_str489[sizeof("UCS-4LE")]; - char stringpool_str492[sizeof("UCS-4-INTERNAL")]; - char stringpool_str497[sizeof("CSISOLATINHEBREW")]; - char stringpool_str500[sizeof("CSISOLATINGREEK")]; - char stringpool_str502[sizeof("ISO-2022-JP-MS")]; - char stringpool_str503[sizeof("EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE")]; - char stringpool_str505[sizeof("MULELAO-1")]; - char stringpool_str509[sizeof("MACTURKISH")]; - char stringpool_str513[sizeof("UNICODEBIG")]; - char stringpool_str518[sizeof("CSISO57GB1988")]; - char stringpool_str519[sizeof("CSPC862LATINHEBREW")]; - char stringpool_str525[sizeof("ANSI_X3.4-1986")]; - char stringpool_str526[sizeof("UCS-4BE")]; - char stringpool_str528[sizeof("ANSI_X3.4-1968")]; - char stringpool_str529[sizeof("MACUKRAINE")]; - char stringpool_str534[sizeof("UTF-16LE")]; - char stringpool_str537[sizeof("ISO_8859-1:1987")]; - char stringpool_str538[sizeof("ISO_8859-6:1987")]; - char stringpool_str542[sizeof("ISO_8859-2:1987")]; - char stringpool_str544[sizeof("MS_KANJI")]; - char stringpool_str546[sizeof("WINDOWS-1257")]; - char stringpool_str551[sizeof("JISX0201-1976")]; - char stringpool_str553[sizeof("UTF-7")]; - char stringpool_str554[sizeof("GB18030:2022")]; - char stringpool_str556[sizeof("JAVA")]; - char stringpool_str563[sizeof("ISO646-JP")]; - char stringpool_str568[sizeof("MACCENTRALEUROPE")]; - char stringpool_str570[sizeof("ISO-2022-JP")]; - char stringpool_str571[sizeof("UTF-16BE")]; - char stringpool_str572[sizeof("EUCJP")]; - char stringpool_str575[sizeof("GB18030:2005")]; - char stringpool_str576[sizeof("JIS_X0212")]; - char stringpool_str583[sizeof("EUC-JP")]; - char stringpool_str584[sizeof("MACGREEK")]; - char stringpool_str593[sizeof("MS-GREEK")]; - char stringpool_str595[sizeof("JIS_X0201")]; - char stringpool_str603[sizeof("JIS_X0208")]; - char stringpool_str605[sizeof("GEORGIAN-PS")]; - char stringpool_str607[sizeof("MS-ARAB")]; - char stringpool_str608[sizeof("JIS_X0212.1990-0")]; - char stringpool_str611[sizeof("ISO_8859-7:2003")]; - char stringpool_str612[sizeof("UTF-32LE")]; - char stringpool_str615[sizeof("JIS_X0212-1990")]; - char stringpool_str618[sizeof("SHIFT-JIS")]; - char stringpool_str625[sizeof("CSISO2022JP")]; - char stringpool_str626[sizeof("HEBREW")]; - char stringpool_str636[sizeof("WINDOWS-874")]; - char stringpool_str638[sizeof("CSPC850MULTILINGUAL")]; - char stringpool_str641[sizeof("NEXTSTEP")]; - char stringpool_str643[sizeof("JIS_X0208-1990")]; - char stringpool_str649[sizeof("UTF-32BE")]; - char stringpool_str659[sizeof("BIG5HKSCS")]; - char stringpool_str664[sizeof("CSSHIFTJIS")]; - char stringpool_str668[sizeof("JOHAB")]; - char stringpool_str670[sizeof("BIG5-HKSCS")]; - char stringpool_str678[sizeof("SHIFT_JIS")]; - char stringpool_str687[sizeof("ISO_8859-7:1987")]; - char stringpool_str688[sizeof("JIS_X0208-1983")]; - char stringpool_str699[sizeof("CSHALFWIDTHKATAKANA")]; - char stringpool_str701[sizeof("CSISO87JISX0208")]; - char stringpool_str745[sizeof("WINBALTRIM")]; - char stringpool_str750[sizeof("CSEUCPKDFMTJAPANESE")]; - char stringpool_str754[sizeof("UCS-2-SWAPPED")]; - char stringpool_str770[sizeof("TCVN5712-1:1993")]; - char stringpool_str786[sizeof("MACHEBREW")]; - char stringpool_str796[sizeof("UCS-4-SWAPPED")]; - char stringpool_str803[sizeof("BIGFIVE")]; - char stringpool_str810[sizeof("KO_KR.JOHAP92")]; - char stringpool_str814[sizeof("BIG-FIVE")]; - char stringpool_str872[sizeof("BIG5-HKSCS:2001")]; - char stringpool_str876[sizeof("BIG5-HKSCS:2008")]; - char stringpool_str883[sizeof("BIG5-HKSCS:1999")]; - char stringpool_str919[sizeof("BIG5-HKSCS:2004")]; - }; -static const struct stringpool_t stringpool_contents = - { - "646", - "866", - "CN", - "CP866", - "CP1251", - "CP1256", - "862", - "CP1255", - "CP862", - "CP1258", - "CP1252", - "C99", - "CP819", - "5601", - "ISO8859-1", - "ISO8859-11", - "ISO8859-6", - "ISO8859-16", - "ISO8859-5", - "ISO8859-15", - "R8", - "ISO8859-8", - "CP50221", - "ISO8859-2", - "ISO-8859-1", - "ISO-8859-11", - "ISO-8859-6", - "ISO-8859-16", - "ISO-8859-5", - "ISO-8859-15", - "HZ", - "ISO-8859-8", - "ISO-8859-2", - "ISO8859-9", - "850", - "ASCII", - "CP850", - "ISO-IR-6", - "CP1250", - "ISO-8859-9", - "ISO-IR-166", - "ISO-IR-165", - "CP950", - "ISO-IR-126", - "UHC", - "ISO-IR-58", - "CP1131", - "CP1361", - "ISO-IR-226", - "ISO646-CN", - "CP949", - "MAC", - "ISO-2022-CN", - "CP936", - "EUCCN", - "ISO-IR-159", - "ISO-2022-CN-EXT", - "IBM866", - "ISO8859-10", - "ISO-IR-101", - "CP932", - "CP154", - "ISO-IR-199", - "EUC-CN", - "IBM862", - "CP1254", - "ISO-8859-10", - "ISO_8859-1", - "ISO_8859-11", - "ISO_8859-6", - "ISO_8859-16", - "ISO_8859-5", - "ISO_8859-15", - "IBM819", - "ISO_8859-16:2001", - "ISO_8859-8", - "ISO_8859-2", - "ISO-IR-109", - "ISO_8859-15:1998", - "ISO-IR-148", - "ISO-IR-110", - "RK1048", - "ISO_8859-9", - "ISO8859-4", - "ISO8859-14", - "L1", - "L6", - "L5", - "ISO-IR-149", - "L8", - "L2", - "CSASCII", - "KOI8-T", - "ISO-8859-4", - "ISO-8859-14", - "CSISO2022CN", - "US", - "ISO_8859-10:1992", - "TIS620", - "ISO-IR-138", - "TIS620.2529-1", - "IBM850", - "LATIN1", - "ISO-IR-100", - "LATIN6", - "ANSI-1251", - "LATIN5", - "CP1253", - "TIS-620", - "ISO-IR-14", - "LATIN8", - "LATIN2", - "ISO_8859-14:1998", - "CSUNICODE11", - "ISO_8859-10", - "UCS-2", - "MS936", - "UNICODE-1-1", - "ELOT_928", - "L4", - "GB2312", - "ISO8859-3", - "ISO8859-13", - "LATIN-9", - "ISO-10646-UCS-2", - "TIS620-0", - "X0212", - "L10", - "ISO-8859-3", - "ISO-8859-13", - "CSKOI8R", - "CSKZ1048", - "ISO_8859-4", - "ISO_8859-14", - "ROMAN8", - "KZ-1048", - "KOI8-R", - "L3", - "ISO-IR-144", - "X0201", - "MACTHAI", - "LATIN10", - "KSC_5601", - "X0208", - "SJIS", - "US-ASCII", - "CP1133", - "ISO-10646-UCS-4", - "ISO-CELTIC", - "CSUNICODE", - "ECMA-118", - "ISO-IR-179", - "MS-ANSI", - "PT154", - "ARMSCII-8", - "CSUCS4", - "LATIN4", - "ISO-IR-203", - "CP874", - "TCVN", - "UTF-16", - "UCS-4", - "ISO_8859-3", - "ISO_8859-13", - "UTF-8", - "GB_1988-80", - "GB18030", - "ISO-2022-KR", - "EUCKR", - "BIG5", - "CSIBM866", - "CSBIG5", - "HP-ROMAN8", - "KOI8-U", - "EUC-KR", - "CNS11643", - "BIG-5", - "MACCROATIAN", - "CN-BIG5", - "TIS620.2533-1", - "L7", - "ISO646-US", - "MACINTOSH", - "MACROMAN", - "CSISOLATIN1", - "CSISOLATIN6", - "ARABIC", - "CSISOLATIN5", - "KOREAN", - "CHINESE", - "LATIN3", - "CSISOLATINCYRILLIC", - "CSISOLATIN2", - "VISCII", - "GBK", - "CSVISCII", - "MS-EE", - "CP1257", - "TIS620.2533-0", - "KS_C_5601-1989", - "KOI8-RU", - "CSISO2022KR", - "CYRILLIC", - "CSUNICODE11UTF7", - "VISCII1.1-1", - "GB_2312-80", - "ECMA-114", - "UNICODE-1-1-UTF-7", - "UTF-32", - "ISO8859-7", - "CSEUCKR", - "ASMO-708", - "ISO-8859-7", - "JP", - "GREEK8", - "CSMACINTOSH", - "JIS0208", - "TIS620.2533", - "CSGB2312", - "CSISOLATINARABIC", - "PCK", - "STRK1048-2002", - "EUCTW", - "ISO-IR-57", - "ISO-IR-157", - "ISO-IR-87", - "ISO-IR-127", - "MACICELAND", - "EUC-TW", - "CP367", - "UNICODELITTLE", - "GEORGIAN-ACADEMY", - "CSKSC56011987", - "CSISOLATIN4", - "ISO_8859-5:1988", - "PTCP154", - "ISO_8859-8:1988", - "WINDOWS-1251", - "WINDOWS-1256", - "WINDOWS-1255", - "WINDOWS-1258", - "WINDOWS-1252", - "ISO_646.IRV:1991", - "CSPTCP154", - "ISO_8859-9:1989", - "MACROMANIA", - "ISO_8859-7", - "CSHPROMAN8", - "CN-GB-ISOIR165", - "CSISO159JISX02121990", - "JIS_C6220-1969-RO", - "MACCYRILLIC", - "CSISO14JISC6220RO", - "TCVN5712-1", - "MS-CYRL", - "TCVN-5712", - "WINDOWS-1250", - "ISO-2022-JP-1", - "MACARABIC", - "ISO-2022-JP-2", - "HZ-GB-2312", - "ISO_8859-4:1988", - "MS-TURK", - "WINDOWS-1254", - "CSEUCTW", - "CSISOLATIN3", - "UCS-2LE", - "UCS-2-INTERNAL", - "CN-GB", - "GREEK", - "KS_C_5601-1987", - "LATIN7", - "JIS_C6226-1983", - "ISO_8859-3:1988", - "IBM367", - "CSISO58GB231280", - "WINDOWS-1253", - "IBM-CP1133", - "WINDOWS-936", - "CYRILLIC-ASIAN", - "MS-HEBR", - "UCS-2BE", - "CSISO2022JP2", - "UCS-4LE", - "UCS-4-INTERNAL", - "CSISOLATINHEBREW", - "CSISOLATINGREEK", - "ISO-2022-JP-MS", - "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", - "MULELAO-1", - "MACTURKISH", - "UNICODEBIG", - "CSISO57GB1988", - "CSPC862LATINHEBREW", - "ANSI_X3.4-1986", - "UCS-4BE", - "ANSI_X3.4-1968", - "MACUKRAINE", - "UTF-16LE", - "ISO_8859-1:1987", - "ISO_8859-6:1987", - "ISO_8859-2:1987", - "MS_KANJI", - "WINDOWS-1257", - "JISX0201-1976", - "UTF-7", - "GB18030:2022", - "JAVA", - "ISO646-JP", - "MACCENTRALEUROPE", - "ISO-2022-JP", - "UTF-16BE", - "EUCJP", - "GB18030:2005", - "JIS_X0212", - "EUC-JP", - "MACGREEK", - "MS-GREEK", - "JIS_X0201", - "JIS_X0208", - "GEORGIAN-PS", - "MS-ARAB", - "JIS_X0212.1990-0", - "ISO_8859-7:2003", - "UTF-32LE", - "JIS_X0212-1990", - "SHIFT-JIS", - "CSISO2022JP", - "HEBREW", - "WINDOWS-874", - "CSPC850MULTILINGUAL", - "NEXTSTEP", - "JIS_X0208-1990", - "UTF-32BE", - "BIG5HKSCS", - "CSSHIFTJIS", - "JOHAB", - "BIG5-HKSCS", - "SHIFT_JIS", - "ISO_8859-7:1987", - "JIS_X0208-1983", - "CSHALFWIDTHKATAKANA", - "CSISO87JISX0208", - "WINBALTRIM", - "CSEUCPKDFMTJAPANESE", - "UCS-2-SWAPPED", - "TCVN5712-1:1993", - "MACHEBREW", - "UCS-4-SWAPPED", - "BIGFIVE", - "KO_KR.JOHAP92", - "BIG-FIVE", - "BIG5-HKSCS:2001", - "BIG5-HKSCS:2008", - "BIG5-HKSCS:1999", - "BIG5-HKSCS:2004" - }; -#define stringpool ((const char *) &stringpool_contents) - -static const struct alias aliases[] = - { - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 23 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str6, ei_ascii}, - {-1}, {-1}, -#line 209 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str9, ei_cp866}, - {-1}, -#line 291 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str11, ei_iso646_cn}, - {-1}, -#line 207 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str13, ei_cp866}, -#line 175 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str14, ei_cp1251}, - {-1}, -#line 191 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str16, ei_cp1256}, -#line 205 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str17, ei_cp862}, -#line 188 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str18, ei_cp1255}, - {-1}, {-1}, -#line 203 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str21, ei_cp862}, -#line 197 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str22, ei_cp1258}, - {-1}, -#line 179 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str24, ei_cp1252}, - {-1}, -#line 52 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str26, ei_c99}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 58 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str32, ei_iso8859_1}, - {-1}, {-1}, -#line 360 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str35, ei_euc_kr}, - {-1}, {-1}, {-1}, {-1}, -#line 63 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str40, ei_iso8859_1}, -#line 140 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str41, ei_iso8859_11}, -#line 103 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str42, ei_iso8859_6}, -#line 167 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str43, ei_iso8859_16}, -#line 94 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str44, ei_iso8859_5}, -#line 160 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str45, ei_iso8859_15}, - {-1}, -#line 229 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str47, ei_hp_roman8}, -#line 121 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str48, ei_iso8859_8}, -#line 321 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str49, ei_iso2022_jpms}, -#line 71 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str50, ei_iso8859_2}, -#line 54 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str51, ei_iso8859_1}, -#line 138 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str52, ei_iso8859_11}, -#line 95 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str53, ei_iso8859_6}, -#line 161 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str54, ei_iso8859_16}, -#line 88 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str55, ei_iso8859_5}, -#line 155 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str56, ei_iso8859_15}, - {-1}, -#line 338 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str58, ei_hz}, -#line 115 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str59, ei_iso8859_8}, - {-1}, -#line 64 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str61, ei_iso8859_2}, -#line 129 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str62, ei_iso8859_9}, - {-1}, {-1}, -#line 201 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str65, ei_cp850}, -#line 13 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str66, ei_ascii}, - {-1}, {-1}, {-1}, -#line 199 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str70, ei_cp850}, -#line 16 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str71, ei_ascii}, -#line 172 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str72, ei_cp1250}, -#line 122 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str73, ei_iso8859_9}, -#line 254 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str74, ei_tis620}, - {-1}, -#line 296 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str76, ei_isoir165}, -#line 350 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str77, ei_cp950}, -#line 108 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str78, ei_iso8859_7}, -#line 362 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str79, ei_cp949}, -#line 294 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str80, ei_gb2312}, -#line 211 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str81, ei_cp1131}, -#line 364 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str82, ei_johab}, -#line 164 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str83, ei_iso8859_16}, - {-1}, -#line 289 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str85, ei_iso646_cn}, -#line 361 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str86, ei_cp949}, - {-1}, {-1}, {-1}, -#line 214 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str90, ei_mac_roman}, - {-1}, -#line 335 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str92, ei_iso2022_cn}, -#line 329 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str93, ei_cp936}, -#line 323 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str94, ei_euc_cn}, -#line 286 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str95, ei_jisx0212}, -#line 337 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str96, ei_iso2022_cn_ext}, - {-1}, -#line 208 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str98, ei_cp866}, -#line 137 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str99, ei_iso8859_10}, -#line 67 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str100, ei_iso8859_2}, -#line 314 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str101, ei_cp932}, -#line 238 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str102, ei_pt154}, - {-1}, -#line 150 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str104, ei_iso8859_14}, -#line 322 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str105, ei_euc_cn}, -#line 204 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str106, ei_cp862}, - {-1}, -#line 185 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str108, ei_cp1254}, - {-1}, -#line 130 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str110, ei_iso8859_10}, -#line 55 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str111, ei_iso8859_1}, -#line 139 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str112, ei_iso8859_11}, -#line 96 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str113, ei_iso8859_6}, -#line 162 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str114, ei_iso8859_16}, -#line 89 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str115, ei_iso8859_5}, -#line 156 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str116, ei_iso8859_15}, -#line 59 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str117, ei_iso8859_1}, -#line 163 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str118, ei_iso8859_16}, -#line 116 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str119, ei_iso8859_8}, - {-1}, -#line 65 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str121, ei_iso8859_2}, -#line 75 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str122, ei_iso8859_3}, -#line 157 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str123, ei_iso8859_15}, - {-1}, {-1}, -#line 125 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str126, ei_iso8859_9}, - {-1}, {-1}, -#line 83 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str129, ei_iso8859_4}, - {-1}, -#line 241 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str131, ei_rk1048}, - {-1}, -#line 123 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str133, ei_iso8859_9}, -#line 87 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str134, ei_iso8859_4}, -#line 154 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str135, ei_iso8859_14}, - {-1}, -#line 61 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str137, ei_iso8859_1}, -#line 135 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str138, ei_iso8859_10}, -#line 127 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str139, ei_iso8859_9}, -#line 301 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str140, ei_ksc5601}, -#line 152 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str141, ei_iso8859_14}, -#line 69 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str142, ei_iso8859_2}, -#line 22 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str143, ei_ascii}, -#line 235 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str144, ei_koi8_t}, -#line 80 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str145, ei_iso8859_4}, -#line 147 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str146, ei_iso8859_14}, -#line 336 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str147, ei_iso2022_cn}, - {-1}, {-1}, -#line 21 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str150, ei_ascii}, -#line 132 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str151, ei_iso8859_10}, -#line 249 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str152, ei_tis620}, -#line 118 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str153, ei_iso8859_8}, -#line 251 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str154, ei_tis620}, -#line 200 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str155, ei_cp850}, - {-1}, -#line 60 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str157, ei_iso8859_1}, -#line 57 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str158, ei_iso8859_1}, -#line 134 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str159, ei_iso8859_10}, -#line 178 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str160, ei_cp1251}, -#line 126 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str161, ei_iso8859_9}, -#line 182 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str162, ei_cp1253}, -#line 248 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str163, ei_tis620}, -#line 267 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str164, ei_iso646_jp}, -#line 151 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str165, ei_iso8859_14}, - {-1}, -#line 68 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str167, ei_iso8859_2}, -#line 149 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str168, ei_iso8859_14}, -#line 31 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str169, ei_ucs2be}, -#line 131 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str170, ei_iso8859_10}, - {-1}, {-1}, -#line 25 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str173, ei_ucs2}, - {-1}, {-1}, {-1}, -#line 330 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str177, ei_cp936}, - {-1}, {-1}, -#line 30 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str180, ei_ucs2be}, -#line 110 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str181, ei_iso8859_7}, - {-1}, {-1}, -#line 85 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str184, ei_iso8859_4}, - {-1}, -#line 324 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str186, ei_euc_cn}, - {-1}, -#line 79 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str188, ei_iso8859_3}, -#line 146 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str189, ei_iso8859_13}, -#line 159 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str190, ei_iso8859_15}, - {-1}, -#line 26 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str192, ei_ucs2}, -#line 250 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str193, ei_tis620}, -#line 285 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str194, ei_jisx0212}, - {-1}, -#line 166 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str196, ei_iso8859_16}, - {-1}, {-1}, -#line 72 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str199, ei_iso8859_3}, -#line 141 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str200, ei_iso8859_13}, - {-1}, -#line 169 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str202, ei_koi8_r}, -#line 244 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str203, ei_rk1048}, - {-1}, -#line 81 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str205, ei_iso8859_4}, -#line 148 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str206, ei_iso8859_14}, - {-1}, -#line 228 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str208, ei_hp_roman8}, -#line 243 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str209, ei_rk1048}, -#line 168 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str210, ei_koi8_r}, -#line 77 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str211, ei_iso8859_3}, -#line 91 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str212, ei_iso8859_5}, -#line 272 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str213, ei_jisx0201}, - {-1}, -#line 226 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str215, ei_mac_thai}, -#line 165 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str216, ei_iso8859_16}, - {-1}, {-1}, -#line 298 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str219, ei_ksc5601}, - {-1}, -#line 278 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str221, ei_jisx0208}, - {-1}, {-1}, {-1}, {-1}, -#line 310 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str226, ei_sjis}, -#line 12 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str227, ei_ascii}, - {-1}, -#line 246 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str229, ei_cp1133}, - {-1}, {-1}, {-1}, {-1}, -#line 35 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str234, ei_ucs4}, - {-1}, {-1}, -#line 153 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str237, ei_iso8859_14}, -#line 27 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str238, ei_ucs2}, - {-1}, {-1}, {-1}, -#line 109 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str242, ei_iso8859_7}, -#line 143 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str243, ei_iso8859_13}, -#line 181 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str244, ei_cp1252}, - {-1}, -#line 236 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str246, ei_pt154}, -#line 232 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str247, ei_armscii_8}, - {-1}, {-1}, -#line 36 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str250, ei_ucs4}, -#line 84 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str251, ei_iso8859_4}, - {-1}, -#line 158 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str253, ei_iso8859_15}, -#line 256 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str254, ei_cp874}, -#line 261 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str255, ei_tcvn}, -#line 39 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str256, ei_utf16}, -#line 34 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str257, ei_ucs4}, - {-1}, -#line 73 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str259, ei_iso8859_3}, -#line 142 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str260, ei_iso8859_13}, -#line 24 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str261, ei_utf8}, -#line 288 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str262, ei_iso646_cn}, -#line 332 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str263, ei_gb18030_2005}, - {-1}, -#line 366 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str265, ei_iso2022_kr}, - {-1}, -#line 358 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str267, ei_euc_kr}, - {-1}, {-1}, {-1}, -#line 344 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str271, ei_ces_big5}, - {-1}, -#line 210 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str273, ei_cp866}, -#line 349 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str274, ei_ces_big5}, -#line 227 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str275, ei_hp_roman8}, -#line 170 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str276, ei_koi8_u}, - {-1}, -#line 357 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str278, ei_euc_kr}, -#line 343 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str279, ei_euc_tw}, - {-1}, {-1}, -#line 345 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str282, ei_ces_big5}, -#line 218 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str283, ei_mac_croatian}, - {-1}, -#line 348 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str285, ei_ces_big5}, -#line 253 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str286, ei_tis620}, -#line 145 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str287, ei_iso8859_13}, - {-1}, {-1}, -#line 14 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str290, ei_ascii}, - {-1}, {-1}, -#line 213 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str293, ei_mac_roman}, - {-1}, {-1}, -#line 212 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str296, ei_mac_roman}, -#line 62 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str297, ei_iso8859_1}, - {-1}, -#line 136 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str299, ei_iso8859_10}, -#line 101 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str300, ei_iso8859_6}, -#line 128 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str301, ei_iso8859_9}, -#line 303 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str302, ei_ksc5601}, -#line 327 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str303, ei_euc_cn}, - {-1}, -#line 76 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str305, ei_iso8859_3}, -#line 93 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str306, ei_iso8859_5}, -#line 70 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str307, ei_iso8859_2}, -#line 258 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str308, ei_viscii}, - {-1}, -#line 328 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str310, ei_ces_gbk}, -#line 260 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str311, ei_viscii}, - {-1}, -#line 174 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str313, ei_cp1250}, -#line 194 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str314, ei_cp1257}, -#line 252 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str315, ei_tis620}, -#line 300 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str316, ei_ksc5601}, - {-1}, -#line 171 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str318, ei_koi8_ru}, - {-1}, -#line 367 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str320, ei_iso2022_kr}, - {-1}, -#line 92 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str322, ei_iso8859_5}, -#line 47 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str323, ei_utf7}, -#line 259 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str324, ei_viscii}, - {-1}, {-1}, -#line 293 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str327, ei_gb2312}, -#line 99 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str328, ei_iso8859_6}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 46 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str336, ei_utf7}, - {-1}, -#line 42 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str338, ei_utf32}, - {-1}, -#line 114 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str340, ei_iso8859_7}, - {-1}, {-1}, {-1}, -#line 359 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str344, ei_euc_kr}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 100 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str350, ei_iso8859_6}, -#line 104 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str351, ei_iso8859_7}, -#line 268 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str352, ei_iso646_jp}, - {-1}, {-1}, -#line 111 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str355, ei_iso8859_7}, -#line 215 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str356, ei_mac_roman}, -#line 277 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str357, ei_jisx0208}, -#line 255 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str358, ei_tis620}, - {-1}, {-1}, -#line 326 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str361, ei_euc_cn}, - {-1}, -#line 102 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str363, ei_iso8859_6}, -#line 313 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str364, ei_sjis}, -#line 242 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str365, ei_rk1048}, - {-1}, -#line 341 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str367, ei_euc_tw}, - {-1}, {-1}, {-1}, {-1}, -#line 290 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str372, ei_iso646_cn}, -#line 133 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str373, ei_iso8859_10}, -#line 279 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str374, ei_jisx0208}, - {-1}, -#line 98 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str376, ei_iso8859_6}, -#line 217 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str377, ei_mac_iceland}, -#line 340 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str378, ei_euc_tw}, - {-1}, {-1}, -#line 19 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str381, ei_ascii}, - {-1}, {-1}, -#line 33 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str384, ei_ucs2le}, -#line 233 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str385, ei_georgian_academy}, - {-1}, {-1}, {-1}, {-1}, -#line 302 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str390, ei_ksc5601}, -#line 86 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str391, ei_iso8859_4}, - {-1}, -#line 90 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str393, ei_iso8859_5}, -#line 237 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str394, ei_pt154}, -#line 117 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str395, ei_iso8859_8}, -#line 176 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str396, ei_cp1251}, -#line 192 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str397, ei_cp1256}, -#line 189 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str398, ei_cp1255}, - {-1}, -#line 198 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str400, ei_cp1258}, -#line 180 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str401, ei_cp1252}, - {-1}, {-1}, -#line 15 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str404, ei_ascii}, -#line 240 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str405, ei_pt154}, - {-1}, {-1}, {-1}, -#line 124 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str409, ei_iso8859_9}, -#line 219 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str410, ei_mac_romania}, -#line 105 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str411, ei_iso8859_7}, -#line 230 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str412, ei_hp_roman8}, - {-1}, {-1}, -#line 297 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str415, ei_isoir165}, -#line 287 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str416, ei_jisx0212}, -#line 265 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str417, ei_iso646_jp}, -#line 220 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str418, ei_mac_cyrillic}, -#line 269 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str419, ei_iso646_jp}, -#line 263 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str420, ei_tcvn}, -#line 177 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str421, ei_cp1251}, - {-1}, {-1}, -#line 262 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str424, ei_tcvn}, -#line 173 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str425, ei_cp1250}, - {-1}, -#line 317 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str427, ei_iso2022_jp1}, - {-1}, {-1}, -#line 225 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str430, ei_mac_arabic}, - {-1}, -#line 318 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str432, ei_iso2022_jp2}, - {-1}, {-1}, {-1}, -#line 339 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str436, ei_hz}, - {-1}, -#line 82 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str438, ei_iso8859_4}, - {-1}, {-1}, -#line 187 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str441, ei_cp1254}, - {-1}, -#line 186 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str443, ei_cp1254}, -#line 342 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str444, ei_euc_tw}, -#line 78 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str445, ei_iso8859_3}, - {-1}, -#line 32 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str447, ei_ucs2le}, - {-1}, {-1}, -#line 48 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str450, ei_ucs2internal}, -#line 325 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str451, ei_euc_cn}, - {-1}, {-1}, -#line 112 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str454, ei_iso8859_7}, -#line 299 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str455, ei_ksc5601}, - {-1}, -#line 144 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str457, ei_iso8859_13}, - {-1}, {-1}, -#line 280 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str460, ei_jisx0208}, - {-1}, {-1}, {-1}, {-1}, -#line 74 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str465, ei_iso8859_3}, -#line 20 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str466, ei_ascii}, -#line 295 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str467, ei_gb2312}, - {-1}, {-1}, -#line 183 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str470, ei_cp1253}, - {-1}, {-1}, -#line 247 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str473, ei_cp1133}, - {-1}, -#line 331 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str475, ei_cp936}, - {-1}, {-1}, {-1}, -#line 239 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str479, ei_pt154}, - {-1}, -#line 190 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str481, ei_cp1255}, - {-1}, {-1}, -#line 28 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str484, ei_ucs2be}, - {-1}, -#line 319 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str486, ei_iso2022_jp2}, - {-1}, {-1}, -#line 38 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str489, ei_ucs4le}, - {-1}, {-1}, -#line 50 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str492, ei_ucs4internal}, - {-1}, {-1}, {-1}, {-1}, -#line 120 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str497, ei_iso8859_8}, - {-1}, {-1}, -#line 113 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str500, ei_iso8859_7}, - {-1}, -#line 320 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str502, ei_iso2022_jpms}, -#line 306 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str503, ei_euc_jp}, - {-1}, -#line 245 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str505, ei_mulelao}, - {-1}, {-1}, {-1}, -#line 223 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str509, ei_mac_turkish}, - {-1}, {-1}, {-1}, -#line 29 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str513, ei_ucs2be}, - {-1}, {-1}, {-1}, {-1}, -#line 292 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str518, ei_iso646_cn}, -#line 206 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str519, ei_cp862}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 18 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str525, ei_ascii}, -#line 37 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str526, ei_ucs4be}, - {-1}, -#line 17 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str528, ei_ascii}, -#line 221 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str529, ei_mac_ukraine}, - {-1}, {-1}, {-1}, {-1}, -#line 41 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str534, ei_utf16le}, - {-1}, {-1}, -#line 56 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str537, ei_iso8859_1}, -#line 97 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str538, ei_iso8859_6}, - {-1}, {-1}, {-1}, -#line 66 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str542, ei_iso8859_2}, - {-1}, -#line 311 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str544, ei_sjis}, - {-1}, -#line 195 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str546, ei_cp1257}, - {-1}, {-1}, {-1}, {-1}, -#line 271 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str551, ei_jisx0201}, - {-1}, -#line 45 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str553, ei_utf7}, -#line 334 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str554, ei_gb18030_2022}, - {-1}, -#line 53 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str556, ei_java}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 266 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str563, ei_iso646_jp}, - {-1}, {-1}, {-1}, {-1}, -#line 216 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str568, ei_mac_centraleurope}, - {-1}, -#line 315 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str570, ei_iso2022_jp}, -#line 40 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str571, ei_utf16be}, -#line 305 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str572, ei_euc_jp}, - {-1}, {-1}, -#line 333 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str575, ei_gb18030_2005}, -#line 282 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str576, ei_jisx0212}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 304 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str583, ei_euc_jp}, -#line 222 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str584, ei_mac_greek}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 184 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str593, ei_cp1253}, - {-1}, -#line 270 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str595, ei_jisx0201}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 274 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str603, ei_jisx0208}, - {-1}, -#line 234 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str605, ei_georgian_ps}, - {-1}, -#line 193 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str607, ei_cp1256}, -#line 283 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str608, ei_jisx0212}, - {-1}, {-1}, -#line 107 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str611, ei_iso8859_7}, -#line 44 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str612, ei_utf32le}, - {-1}, {-1}, -#line 284 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str615, ei_jisx0212}, - {-1}, {-1}, -#line 309 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str618, ei_sjis}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 316 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str625, ei_iso2022_jp}, -#line 119 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str626, ei_iso8859_8}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 257 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str636, ei_cp874}, - {-1}, -#line 202 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str638, ei_cp850}, - {-1}, {-1}, -#line 231 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str641, ei_nextstep}, - {-1}, -#line 276 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str643, ei_jisx0208}, - {-1}, {-1}, {-1}, {-1}, {-1}, -#line 43 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str649, ei_utf32be}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 355 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str659, ei_big5hkscs2008}, - {-1}, {-1}, {-1}, {-1}, -#line 312 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str664, ei_sjis}, - {-1}, {-1}, {-1}, -#line 363 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str668, ei_johab}, - {-1}, -#line 354 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str670, ei_big5hkscs2008}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 308 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str678, ei_sjis}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 106 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str687, ei_iso8859_7}, -#line 275 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str688, ei_jisx0208}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, -#line 273 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str699, ei_jisx0201}, - {-1}, -#line 281 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str701, ei_jisx0208}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 196 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str745, ei_cp1257}, - {-1}, {-1}, {-1}, {-1}, -#line 307 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str750, ei_euc_jp}, - {-1}, {-1}, {-1}, -#line 49 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str754, ei_ucs2swapped}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 264 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str770, ei_tcvn}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 224 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str786, ei_mac_hebrew}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 51 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str796, ei_ucs4swapped}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 347 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str803, ei_ces_big5}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 365 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str810, ei_johab}, - {-1}, {-1}, {-1}, -#line 346 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str814, ei_ces_big5}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, -#line 352 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str872, ei_big5hkscs2001}, - {-1}, {-1}, {-1}, -#line 356 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str876, ei_big5hkscs2008}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 351 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str883, ei_big5hkscs1999}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 353 "lib/generated/aliases_syssolaris.gperf" - {(int)(size_t)&((struct stringpool_t *)0)->stringpool_str919, ei_big5hkscs2004} - }; - -const struct alias * -HashPool::aliases_lookup (const char *str, size_t len) -{ - if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) - { - unsigned int key = aliases_hash (str, len); - - if (key <= MAX_HASH_VALUE) - { - int o = aliases[key].name; - if (o >= 0) - { - const char *s = o + stringpool; - - if (*str == *s && !strcmp (str + 1, s + 1)) - return &aliases[key]; - } - } - } - return 0; -} diff --git a/lib/generated/aliases_zos.h b/lib/generated/aliases_zos.h deleted file mode 100644 index 9143ea16..00000000 --- a/lib/generated/aliases_zos.h +++ /dev/null @@ -1,241 +0,0 @@ - S(zos_0, "IBM-037", ei_ebcdic037 ) - S(zos_1, "IBM037", ei_ebcdic037 ) - S(zos_2, "CP037", ei_ebcdic037 ) - S(zos_3, "EBCDIC-CP-US", ei_ebcdic037 ) - S(zos_4, "EBCDIC-CP-CA", ei_ebcdic037 ) - S(zos_5, "EBCDIC-CP-WT", ei_ebcdic037 ) - S(zos_6, "EBCDIC-CP-NL", ei_ebcdic037 ) - S(zos_7, "CSIBM037", ei_ebcdic037 ) - S(zos_8, "IBM-273", ei_ebcdic273 ) - S(zos_9, "IBM273", ei_ebcdic273 ) - S(zos_10, "CP273", ei_ebcdic273 ) - S(zos_11, "CSIBM273", ei_ebcdic273 ) - S(zos_12, "IBM-277", ei_ebcdic277 ) - S(zos_13, "IBM277", ei_ebcdic277 ) - S(zos_14, "EBCDIC-CP-DK", ei_ebcdic277 ) - S(zos_15, "EBCDIC-CP-NO", ei_ebcdic277 ) - S(zos_16, "CSIBM277", ei_ebcdic277 ) - S(zos_17, "IBM-278", ei_ebcdic278 ) - S(zos_18, "IBM278", ei_ebcdic278 ) - S(zos_19, "CP278", ei_ebcdic278 ) - S(zos_20, "EBCDIC-CP-FI", ei_ebcdic278 ) - S(zos_21, "EBCDIC-CP-SE", ei_ebcdic278 ) - S(zos_22, "CSIBM278", ei_ebcdic278 ) - S(zos_23, "IBM-280", ei_ebcdic280 ) - S(zos_24, "IBM280", ei_ebcdic280 ) - S(zos_25, "CP280", ei_ebcdic280 ) - S(zos_26, "EBCDIC-CP-IT", ei_ebcdic280 ) - S(zos_27, "CSIBM280", ei_ebcdic280 ) - S(zos_28, "IBM-282", ei_ebcdic282 ) - S(zos_29, "IBM282", ei_ebcdic282 ) - S(zos_30, "IBM-284", ei_ebcdic284 ) - S(zos_31, "IBM284", ei_ebcdic284 ) - S(zos_32, "CP284", ei_ebcdic284 ) - S(zos_33, "EBCDIC-CP-ES", ei_ebcdic284 ) - S(zos_34, "CSIBM284", ei_ebcdic284 ) - S(zos_35, "IBM-285", ei_ebcdic285 ) - S(zos_36, "IBM285", ei_ebcdic285 ) - S(zos_37, "CP285", ei_ebcdic285 ) - S(zos_38, "EBCDIC-CP-GB", ei_ebcdic285 ) - S(zos_39, "CSIBM285", ei_ebcdic285 ) - S(zos_40, "IBM-297", ei_ebcdic297 ) - S(zos_41, "IBM297", ei_ebcdic297 ) - S(zos_42, "CP297", ei_ebcdic297 ) - S(zos_43, "EBCDIC-CP-FR", ei_ebcdic297 ) - S(zos_44, "CSIBM297", ei_ebcdic297 ) - S(zos_45, "IBM-423", ei_ebcdic423 ) - S(zos_46, "IBM423", ei_ebcdic423 ) - S(zos_47, "CP423", ei_ebcdic423 ) - S(zos_48, "EBCDIC-CP-GR", ei_ebcdic423 ) - S(zos_49, "CSIBM423", ei_ebcdic423 ) - S(zos_50, "IBM-424", ei_ebcdic424 ) - S(zos_51, "IBM424", ei_ebcdic424 ) - S(zos_52, "CP424", ei_ebcdic424 ) - S(zos_53, "EBCDIC-CP-HE", ei_ebcdic424 ) - S(zos_54, "CSIBM424", ei_ebcdic424 ) - S(zos_55, "IBM-425", ei_ebcdic425 ) - S(zos_56, "IBM425", ei_ebcdic425 ) - S(zos_57, "IBM-500", ei_ebcdic500 ) - S(zos_58, "IBM500", ei_ebcdic500 ) - S(zos_59, "CP500", ei_ebcdic500 ) - S(zos_60, "EBCDIC-CP-BE", ei_ebcdic500 ) - S(zos_61, "EBCDIC-CP-CH", ei_ebcdic500 ) - S(zos_62, "CSIBM500", ei_ebcdic500 ) - S(zos_63, "IBM-838", ei_ebcdic838 ) - S(zos_64, "IBM838", ei_ebcdic838 ) - S(zos_65, "IBM-THAI", ei_ebcdic838 ) - S(zos_66, "CSIBMTHAI", ei_ebcdic838 ) - S(zos_67, "IBM-870", ei_ebcdic870 ) - S(zos_68, "IBM870", ei_ebcdic870 ) - S(zos_69, "CP870", ei_ebcdic870 ) - S(zos_70, "EBCDIC-CP-ROECE", ei_ebcdic870 ) - S(zos_71, "EBCDIC-CP-YU", ei_ebcdic870 ) - S(zos_72, "CSIBM870", ei_ebcdic870 ) - S(zos_73, "IBM-871", ei_ebcdic871 ) - S(zos_74, "IBM871", ei_ebcdic871 ) - S(zos_75, "CP871", ei_ebcdic871 ) - S(zos_76, "EBCDIC-CP-IS", ei_ebcdic871 ) - S(zos_77, "CSIBM871", ei_ebcdic871 ) - S(zos_78, "IBM-875", ei_ebcdic875 ) - S(zos_79, "IBM875", ei_ebcdic875 ) - S(zos_80, "CP875", ei_ebcdic875 ) - S(zos_81, "EBCDIC-GREEK", ei_ebcdic875 ) - S(zos_82, "IBM-880", ei_ebcdic880 ) - S(zos_83, "IBM880", ei_ebcdic880 ) - S(zos_84, "CP880", ei_ebcdic880 ) - S(zos_85, "EBCDIC-CYRILLIC", ei_ebcdic880 ) - S(zos_86, "CSIBM880", ei_ebcdic880 ) - S(zos_87, "IBM-905", ei_ebcdic905 ) - S(zos_88, "IBM905", ei_ebcdic905 ) - S(zos_89, "CP905", ei_ebcdic905 ) - S(zos_90, "EBCDIC-CP-TR", ei_ebcdic905 ) - S(zos_91, "CSIBM905", ei_ebcdic905 ) - S(zos_92, "IBM-924", ei_ebcdic924 ) - S(zos_93, "IBM924", ei_ebcdic924 ) - S(zos_94, "IBM00924", ei_ebcdic924 ) - S(zos_95, "CCSID00924", ei_ebcdic924 ) - S(zos_96, "CP00924", ei_ebcdic924 ) - S(zos_97, "EBCDIC-LATIN9-EURO", ei_ebcdic924 ) - S(zos_98, "CSIBM00924", ei_ebcdic924 ) - S(zos_99, "IBM-1025", ei_ebcdic1025 ) - S(zos_100, "IBM1025", ei_ebcdic1025 ) - S(zos_101, "CP1025", ei_ebcdic1025 ) - S(zos_102, "IBM-1026", ei_ebcdic1026 ) - S(zos_103, "IBM1026", ei_ebcdic1026 ) - S(zos_104, "CP1026", ei_ebcdic1026 ) - S(zos_105, "CSIBM1026", ei_ebcdic1026 ) - S(zos_106, "IBM-1047", ei_ebcdic1047 ) - S(zos_107, "IBM1047", ei_ebcdic1047 ) - S(zos_108, "CP1047", ei_ebcdic1047 ) - S(zos_109, "CSIBM1047", ei_ebcdic1047 ) - S(zos_110, "IBM-1097", ei_ebcdic1097 ) - S(zos_111, "IBM1097", ei_ebcdic1097 ) - S(zos_112, "CP1097", ei_ebcdic1097 ) - S(zos_113, "IBM-1112", ei_ebcdic1112 ) - S(zos_114, "IBM1112", ei_ebcdic1112 ) - S(zos_115, "CP1112", ei_ebcdic1112 ) - S(zos_116, "IBM-1122", ei_ebcdic1122 ) - S(zos_117, "IBM1122", ei_ebcdic1122 ) - S(zos_118, "CP1122", ei_ebcdic1122 ) - S(zos_119, "IBM-1123", ei_ebcdic1123 ) - S(zos_120, "IBM1123", ei_ebcdic1123 ) - S(zos_121, "CP1123", ei_ebcdic1123 ) - S(zos_122, "IBM-1130", ei_ebcdic1130 ) - S(zos_123, "IBM1130", ei_ebcdic1130 ) - S(zos_124, "CP1130", ei_ebcdic1130 ) - S(zos_125, "IBM-1132", ei_ebcdic1132 ) - S(zos_126, "IBM1132", ei_ebcdic1132 ) - S(zos_127, "CP1132", ei_ebcdic1132 ) - S(zos_128, "IBM-1137", ei_ebcdic1137 ) - S(zos_129, "IBM1137", ei_ebcdic1137 ) - S(zos_130, "CP1137", ei_ebcdic1137 ) - S(zos_131, "IBM-1140", ei_ebcdic1140 ) - S(zos_132, "IBM1140", ei_ebcdic1140 ) - S(zos_133, "IBM01140", ei_ebcdic1140 ) - S(zos_134, "CCSID01140", ei_ebcdic1140 ) - S(zos_135, "CP01140", ei_ebcdic1140 ) - S(zos_136, "EBCDIC-US-37+EURO", ei_ebcdic1140 ) - S(zos_137, "CSIBM01140", ei_ebcdic1140 ) - S(zos_138, "IBM-1141", ei_ebcdic1141 ) - S(zos_139, "IBM1141", ei_ebcdic1141 ) - S(zos_140, "IBM01141", ei_ebcdic1141 ) - S(zos_141, "CCSID01141", ei_ebcdic1141 ) - S(zos_142, "CP01141", ei_ebcdic1141 ) - S(zos_143, "EBCDIC-DE-273+EURO", ei_ebcdic1141 ) - S(zos_144, "CSIBM01141", ei_ebcdic1141 ) - S(zos_145, "IBM-1142", ei_ebcdic1142 ) - S(zos_146, "IBM1142", ei_ebcdic1142 ) - S(zos_147, "IBM01142", ei_ebcdic1142 ) - S(zos_148, "CCSID01142", ei_ebcdic1142 ) - S(zos_149, "CP01142", ei_ebcdic1142 ) - S(zos_150, "EBCDIC-DK-277+EURO", ei_ebcdic1142 ) - S(zos_151, "EBCDIC-NO-277+EURO", ei_ebcdic1142 ) - S(zos_152, "CSIBM01142", ei_ebcdic1142 ) - S(zos_153, "IBM-1143", ei_ebcdic1143 ) - S(zos_154, "IBM1143", ei_ebcdic1143 ) - S(zos_155, "IBM01143", ei_ebcdic1143 ) - S(zos_156, "CCSID01143", ei_ebcdic1143 ) - S(zos_157, "CP01143", ei_ebcdic1143 ) - S(zos_158, "EBCDIC-FI-278+EURO", ei_ebcdic1143 ) - S(zos_159, "EBCDIC-SE-278+EURO", ei_ebcdic1143 ) - S(zos_160, "CSIBM01143", ei_ebcdic1143 ) - S(zos_161, "IBM-1144", ei_ebcdic1144 ) - S(zos_162, "IBM1144", ei_ebcdic1144 ) - S(zos_163, "IBM01144", ei_ebcdic1144 ) - S(zos_164, "CCSID01144", ei_ebcdic1144 ) - S(zos_165, "CP01144", ei_ebcdic1144 ) - S(zos_166, "EBCDIC-IT-280+EURO", ei_ebcdic1144 ) - S(zos_167, "CSPC8CODEPAGE1144", ei_ebcdic1144 ) - S(zos_168, "IBM-1145", ei_ebcdic1145 ) - S(zos_169, "IBM1145", ei_ebcdic1145 ) - S(zos_170, "IBM01145", ei_ebcdic1145 ) - S(zos_171, "CCSID01145", ei_ebcdic1145 ) - S(zos_172, "CP01145", ei_ebcdic1145 ) - S(zos_173, "EBCDIC-ES-284+EURO", ei_ebcdic1145 ) - S(zos_174, "CSIBM01145", ei_ebcdic1145 ) - S(zos_175, "IBM-1146", ei_ebcdic1146 ) - S(zos_176, "IBM1146", ei_ebcdic1146 ) - S(zos_177, "IBM01146", ei_ebcdic1146 ) - S(zos_178, "CCSID01146", ei_ebcdic1146 ) - S(zos_179, "CP01146", ei_ebcdic1146 ) - S(zos_180, "EBCDIC-GB-285+EURO", ei_ebcdic1146 ) - S(zos_181, "CSPC8CODEPAGE1146", ei_ebcdic1146 ) - S(zos_182, "IBM-1147", ei_ebcdic1147 ) - S(zos_183, "IBM1147", ei_ebcdic1147 ) - S(zos_184, "IBM01147", ei_ebcdic1147 ) - S(zos_185, "CCSID01147", ei_ebcdic1147 ) - S(zos_186, "CP01147", ei_ebcdic1147 ) - S(zos_187, "EBCDIC-FR-297+EURO", ei_ebcdic1147 ) - S(zos_188, "CSIBM01147", ei_ebcdic1147 ) - S(zos_189, "IBM-1148", ei_ebcdic1148 ) - S(zos_190, "IBM1148", ei_ebcdic1148 ) - S(zos_191, "IBM01148", ei_ebcdic1148 ) - S(zos_192, "CCSID01148", ei_ebcdic1148 ) - S(zos_193, "CP01148", ei_ebcdic1148 ) - S(zos_194, "EBCDIC-INTERNATIONAL-500+EURO", ei_ebcdic1148 ) - S(zos_195, "CSIBM01148", ei_ebcdic1148 ) - S(zos_196, "IBM-1149", ei_ebcdic1149 ) - S(zos_197, "IBM1149", ei_ebcdic1149 ) - S(zos_198, "IBM01149", ei_ebcdic1149 ) - S(zos_199, "CCSID01149", ei_ebcdic1149 ) - S(zos_200, "CP01149", ei_ebcdic1149 ) - S(zos_201, "EBCDIC-IS-871+EURO", ei_ebcdic1149 ) - S(zos_202, "CSIBM01149", ei_ebcdic1149 ) - S(zos_203, "IBM-1153", ei_ebcdic1153 ) - S(zos_204, "IBM1153", ei_ebcdic1153 ) - S(zos_205, "CP1153", ei_ebcdic1153 ) - S(zos_206, "IBM-1154", ei_ebcdic1154 ) - S(zos_207, "IBM1154", ei_ebcdic1154 ) - S(zos_208, "CP1154", ei_ebcdic1154 ) - S(zos_209, "IBM-1155", ei_ebcdic1155 ) - S(zos_210, "IBM1155", ei_ebcdic1155 ) - S(zos_211, "CP1155", ei_ebcdic1155 ) - S(zos_212, "IBM-1156", ei_ebcdic1156 ) - S(zos_213, "IBM1156", ei_ebcdic1156 ) - S(zos_214, "CP1156", ei_ebcdic1156 ) - S(zos_215, "IBM-1157", ei_ebcdic1157 ) - S(zos_216, "IBM1157", ei_ebcdic1157 ) - S(zos_217, "CP1157", ei_ebcdic1157 ) - S(zos_218, "IBM-1158", ei_ebcdic1158 ) - S(zos_219, "IBM1158", ei_ebcdic1158 ) - S(zos_220, "CP1158", ei_ebcdic1158 ) - S(zos_221, "IBM-1160", ei_ebcdic1160 ) - S(zos_222, "IBM1160", ei_ebcdic1160 ) - S(zos_223, "CP1160", ei_ebcdic1160 ) - S(zos_224, "IBM-1164", ei_ebcdic1164 ) - S(zos_225, "IBM1164", ei_ebcdic1164 ) - S(zos_226, "CP1164", ei_ebcdic1164 ) - S(zos_227, "IBM-1165", ei_ebcdic1165 ) - S(zos_228, "IBM1165", ei_ebcdic1165 ) - S(zos_229, "IBM-1166", ei_ebcdic1166 ) - S(zos_230, "IBM1166", ei_ebcdic1166 ) - S(zos_231, "CP1166", ei_ebcdic1166 ) - S(zos_232, "IBM-4971", ei_ebcdic4971 ) - S(zos_233, "IBM4971", ei_ebcdic4971 ) - S(zos_234, "CP4971", ei_ebcdic4971 ) - S(zos_235, "IBM-12712", ei_ebcdic12712 ) - S(zos_236, "IBM12712", ei_ebcdic12712 ) - S(zos_237, "CP12712", ei_ebcdic12712 ) - S(zos_238, "IBM-16804", ei_ebcdic16804 ) - S(zos_239, "IBM16804", ei_ebcdic16804 ) - S(zos_240, "CP16804", ei_ebcdic16804 ) diff --git a/lib/generated/flags.h b/lib/generated/flags.h deleted file mode 100644 index 55a7996b..00000000 --- a/lib/generated/flags.h +++ /dev/null @@ -1,212 +0,0 @@ -/* Generated automatically by genflags. */ - -/* Set if the encoding can encode - the acute and grave accents U+00B4 and U+0060. */ -#define HAVE_ACCENTS 1 - -/* Set if the encoding can encode - the single quotation marks U+2018 and U+2019. */ -#define HAVE_QUOTATION_MARKS 2 - -/* Set if the encoding can encode - the double-width Hangul letters (Jamo) U+3131 to U+3163. */ -#define HAVE_HANGUL_JAMO 4 - -#define ei_ascii_oflags (0) -#define ei_utf8_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_ucs2_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_ucs2be_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_ucs2le_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_ucs4_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_ucs4be_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_ucs4le_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_utf16_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_utf16be_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_utf16le_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_utf32_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_utf32be_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_utf32le_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_utf7_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_ucs2internal_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_ucs2swapped_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_ucs4internal_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_ucs4swapped_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_c99_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_java_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_iso8859_1_oflags (HAVE_ACCENTS) -#define ei_iso8859_2_oflags (HAVE_ACCENTS) -#define ei_iso8859_3_oflags (HAVE_ACCENTS) -#define ei_iso8859_4_oflags (HAVE_ACCENTS) -#define ei_iso8859_5_oflags (0) -#define ei_iso8859_6_oflags (0) -#define ei_iso8859_7_oflags (HAVE_QUOTATION_MARKS) -#define ei_iso8859_8_oflags (HAVE_ACCENTS) -#define ei_iso8859_9_oflags (HAVE_ACCENTS) -#define ei_iso8859_10_oflags (0) -#define ei_iso8859_11_oflags (0) -#define ei_iso8859_13_oflags (0) -#define ei_iso8859_14_oflags (0) -#define ei_iso8859_15_oflags (0) -#define ei_iso8859_16_oflags (0) -#define ei_koi8_r_oflags (0) -#define ei_koi8_u_oflags (0) -#define ei_koi8_ru_oflags (0) -#define ei_cp1250_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_cp1251_oflags (HAVE_QUOTATION_MARKS) -#define ei_cp1252_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_cp1253_oflags (HAVE_QUOTATION_MARKS) -#define ei_cp1254_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_cp1255_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_cp1256_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_cp1257_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_cp1258_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_cp850_oflags (HAVE_ACCENTS) -#define ei_cp862_oflags (0) -#define ei_cp866_oflags (0) -#define ei_cp1131_oflags (0) -#define ei_mac_roman_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_mac_centraleurope_oflags (HAVE_QUOTATION_MARKS) -#define ei_mac_iceland_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_mac_croatian_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_mac_romania_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_mac_cyrillic_oflags (HAVE_QUOTATION_MARKS) -#define ei_mac_ukraine_oflags (HAVE_QUOTATION_MARKS) -#define ei_mac_greek_oflags (HAVE_QUOTATION_MARKS) -#define ei_mac_turkish_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_mac_hebrew_oflags (HAVE_QUOTATION_MARKS) -#define ei_mac_arabic_oflags (0) -#define ei_mac_thai_oflags (HAVE_QUOTATION_MARKS) -#define ei_hp_roman8_oflags (HAVE_ACCENTS) -#define ei_nextstep_oflags (HAVE_ACCENTS) -#define ei_armscii_8_oflags (0) -#define ei_georgian_academy_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_georgian_ps_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_koi8_t_oflags (HAVE_QUOTATION_MARKS) -#define ei_pt154_oflags (HAVE_QUOTATION_MARKS) -#define ei_rk1048_oflags (HAVE_QUOTATION_MARKS) -#define ei_mulelao_oflags (0) -#define ei_cp1133_oflags (0) -#define ei_tis620_oflags (0) -#define ei_cp874_oflags (HAVE_QUOTATION_MARKS) -#define ei_viscii_oflags (0) -#define ei_tcvn_oflags (HAVE_ACCENTS) -#define ei_iso646_jp_oflags (0) -#define ei_jisx0201_oflags (0) -#define ei_jisx0208_oflags (HAVE_QUOTATION_MARKS) -#define ei_jisx0212_oflags (0) -#define ei_iso646_cn_oflags (0) -#define ei_gb2312_oflags (HAVE_QUOTATION_MARKS) -#define ei_isoir165_oflags (HAVE_QUOTATION_MARKS) -#define ei_ksc5601_oflags (HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_euc_jp_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_sjis_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_cp932_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_iso2022_jp_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_iso2022_jp1_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_iso2022_jp2_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_iso2022_jpms_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_euc_cn_oflags (HAVE_QUOTATION_MARKS) -#define ei_ces_gbk_oflags (HAVE_QUOTATION_MARKS) -#define ei_cp936_oflags (HAVE_QUOTATION_MARKS) -#define ei_gb18030_2005_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_gb18030_2022_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_iso2022_cn_oflags (HAVE_QUOTATION_MARKS) -#define ei_iso2022_cn_ext_oflags (HAVE_QUOTATION_MARKS) -#define ei_hz_oflags (HAVE_QUOTATION_MARKS) -#define ei_euc_tw_oflags (HAVE_QUOTATION_MARKS) -#define ei_ces_big5_oflags (HAVE_QUOTATION_MARKS) -#define ei_cp950_oflags (HAVE_QUOTATION_MARKS) -#define ei_big5hkscs1999_oflags (HAVE_QUOTATION_MARKS) -#define ei_big5hkscs2001_oflags (HAVE_QUOTATION_MARKS) -#define ei_big5hkscs2004_oflags (HAVE_QUOTATION_MARKS) -#define ei_big5hkscs2008_oflags (HAVE_QUOTATION_MARKS) -#define ei_euc_kr_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_cp949_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_johab_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_iso2022_kr_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO) -#define ei_cp856_oflags (HAVE_ACCENTS) -#define ei_cp922_oflags (HAVE_ACCENTS) -#define ei_cp943_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_cp1046_oflags (0) -#define ei_cp1124_oflags (0) -#define ei_cp1129_oflags (0) -#define ei_cp1161_oflags (0) -#define ei_cp1162_oflags (HAVE_QUOTATION_MARKS) -#define ei_cp1163_oflags (0) -#define ei_cp437_oflags (0) -#define ei_cp737_oflags (0) -#define ei_cp775_oflags (0) -#define ei_cp852_oflags (HAVE_ACCENTS) -#define ei_cp853_oflags (HAVE_ACCENTS) -#define ei_cp855_oflags (0) -#define ei_cp857_oflags (HAVE_ACCENTS) -#define ei_cp858_oflags (HAVE_ACCENTS) -#define ei_cp860_oflags (0) -#define ei_cp861_oflags (0) -#define ei_cp863_oflags (HAVE_ACCENTS) -#define ei_cp864_oflags (0) -#define ei_cp865_oflags (0) -#define ei_cp869_oflags (HAVE_QUOTATION_MARKS) -#define ei_cp1125_oflags (0) -#define ei_euc_jisx0213_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_shift_jisx0213_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_iso2022_jp3_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_big5_2003_oflags (HAVE_QUOTATION_MARKS) -#define ei_tds565_oflags (0) -#define ei_atarist_oflags (HAVE_ACCENTS) -#define ei_riscos1_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_dec_kanji_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_dec_hanyu_oflags (HAVE_QUOTATION_MARKS) -#define ei_ebcdic037_oflags (HAVE_ACCENTS) -#define ei_ebcdic273_oflags (HAVE_ACCENTS) -#define ei_ebcdic277_oflags (HAVE_ACCENTS) -#define ei_ebcdic278_oflags (HAVE_ACCENTS) -#define ei_ebcdic280_oflags (HAVE_ACCENTS) -#define ei_ebcdic282_oflags (HAVE_ACCENTS) -#define ei_ebcdic284_oflags (HAVE_ACCENTS) -#define ei_ebcdic285_oflags (HAVE_ACCENTS) -#define ei_ebcdic297_oflags (HAVE_ACCENTS) -#define ei_ebcdic423_oflags (HAVE_ACCENTS) -#define ei_ebcdic424_oflags (HAVE_ACCENTS) -#define ei_ebcdic425_oflags (0) -#define ei_ebcdic500_oflags (HAVE_ACCENTS) -#define ei_ebcdic838_oflags (0) -#define ei_ebcdic870_oflags (HAVE_ACCENTS) -#define ei_ebcdic871_oflags (HAVE_ACCENTS) -#define ei_ebcdic875_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_ebcdic880_oflags (0) -#define ei_ebcdic905_oflags (HAVE_ACCENTS) -#define ei_ebcdic924_oflags (0) -#define ei_ebcdic1025_oflags (0) -#define ei_ebcdic1026_oflags (HAVE_ACCENTS) -#define ei_ebcdic1047_oflags (HAVE_ACCENTS) -#define ei_ebcdic1097_oflags (0) -#define ei_ebcdic1112_oflags (0) -#define ei_ebcdic1122_oflags (HAVE_ACCENTS) -#define ei_ebcdic1123_oflags (0) -#define ei_ebcdic1130_oflags (0) -#define ei_ebcdic1132_oflags (0) -#define ei_ebcdic1137_oflags (0) -#define ei_ebcdic1140_oflags (HAVE_ACCENTS) -#define ei_ebcdic1141_oflags (HAVE_ACCENTS) -#define ei_ebcdic1142_oflags (HAVE_ACCENTS) -#define ei_ebcdic1143_oflags (HAVE_ACCENTS) -#define ei_ebcdic1144_oflags (HAVE_ACCENTS) -#define ei_ebcdic1145_oflags (HAVE_ACCENTS) -#define ei_ebcdic1146_oflags (HAVE_ACCENTS) -#define ei_ebcdic1147_oflags (HAVE_ACCENTS) -#define ei_ebcdic1148_oflags (HAVE_ACCENTS) -#define ei_ebcdic1149_oflags (HAVE_ACCENTS) -#define ei_ebcdic1153_oflags (HAVE_ACCENTS) -#define ei_ebcdic1154_oflags (0) -#define ei_ebcdic1155_oflags (HAVE_ACCENTS) -#define ei_ebcdic1156_oflags (0) -#define ei_ebcdic1157_oflags (HAVE_ACCENTS) -#define ei_ebcdic1158_oflags (0) -#define ei_ebcdic1160_oflags (0) -#define ei_ebcdic1164_oflags (0) -#define ei_ebcdic1165_oflags (HAVE_ACCENTS) -#define ei_ebcdic1166_oflags (0) -#define ei_ebcdic4971_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS) -#define ei_ebcdic12712_oflags (HAVE_ACCENTS) -#define ei_ebcdic16804_oflags (0) diff --git a/lib/generated/indexes.h.shippet b/lib/generated/indexes.h.shippet new file mode 100644 index 00000000..cec0a149 --- /dev/null +++ b/lib/generated/indexes.h.shippet @@ -0,0 +1,214 @@ +enum +{ + ENCODING_ISO2022_JP3 = 193, + ENCODING_SHIFT_JISX0213 = 192, + ENCODING_EUC_JISX0213 = 191, + ENCODING_EBCDIC_12712 = 189, + ENCODING_EBCDIC_4971 = 188, + ENCODING_EBCDIC_1166 = 187, + ENCODING_EBCDIC_1160 = 184, + ENCODING_EBCDIC_1158 = 183, + ENCODING_EBCDIC_1155 = 180, + ENCODING_EBCDIC_1153 = 178, + ENCODING_EBCDIC_1147 = 175, + ENCODING_EBCDIC_1145 = 173, + ENCODING_EBCDIC_1144 = 172, + ENCODING_EBCDIC_1143 = 171, + ENCODING_EBCDIC_1142 = 170, + ENCODING_EBCDIC_1137 = 167, + ENCODING_EBCDIC_1132 = 166, + ENCODING_EBCDIC_1123 = 164, + ENCODING_EBCDIC_1122 = 163, + ENCODING_EBCDIC_1112 = 162, + ENCODING_EBCDIC_1097 = 161, + ENCODING_EBCDIC_1025 = 158, + ENCODING_EBCDIC_905 = 156, + ENCODING_EBCDIC_500 = 150, + ENCODING_EBCDIC_425 = 149, + ENCODING_EBCDIC_424 = 148, + ENCODING_EBCDIC_285 = 145, + ENCODING_EBCDIC_284 = 144, + ENCODING_EBCDIC_282 = 143, + ENCODING_EBCDIC_278 = 141, + ENCODING_EBCDIC_277 = 140, + ENCODING_CP1125 = 137, + ENCODING_CP869 = 136, + ENCODING_CP861 = 132, + ENCODING_EBCDIC_1047 = 160, + ENCODING_CP857 = 129, + ENCODING_EBCDIC_423 = 147, + ENCODING_CP853 = 127, + ENCODING_ISO8859_8 = 56, + ENCODING_EBCDIC_1154 = 179, + ENCODING_GB1988_80 = 110, + ENCODING_EBCDIC_1140 = 168, + ENCODING_ISO8859_6 = 54, + ENCODING_ISO8859_3 = 51, + ENCODING_IBM922 = 115, + ENCODING_ISO8859_1 = 49, + ENCODING_ISO8859_10 = 58, + ENCODING_DEC_HANYU = 48, + ENCODING_DEC_KANJI = 47, + ENCODING_ISO8859_4 = 52, + ENCODING_SHIFT_JIS = 22, + ENCODING_IBM1131 = 79, + ENCODING_EBCDIC_880 = 155, + ENCODING_BIG5HKSCS_2001 = 40, + ENCODING_MSEE = 67, + ENCODING_ISO8859_7 = 55, + ENCODING_TDS565 = 195, + ENCODING_EBCDIC_1148 = 176, + ENCODING_IBM1161 = 120, + ENCODING_EBCDIC_037 = 138, + ENCODING_CP775 = 125, + ENCODING_BIG5HKSCS_1999 = 39, + ENCODING_EUC_TW = 36, + ENCODING_EBCDIC_297 = 146, + ENCODING_UHC = 44, + ENCODING_EBCDIC_1156 = 181, + ENCODING_GB18030_2022 = 32, + ENCODING_UTF32 = 11, + ENCODING_ATARIST = 196, + ENCODING_CP864 = 134, + ENCODING_GB2312_80 = 111, + ENCODING_UTF16LE = 10, + ENCODING_EBCDIC_1149 = 177, + ENCODING_UTF16 = 8, + ENCODING_UCS4LE = 7, + ENCODING_EBCDIC_924 = 157, + ENCODING_EUC_KR = 43, + ENCODING_EBCDIC_1026 = 159, + ENCODING_GB18030_2005 = 31, + ENCODING_UCS4_INTERNAL = 17, + ENCODING_KOI8T = 97, + ENCODING_EBCDIC_280 = 142, + ENCODING_UCS2LE = 4, + ENCODING_WINDOWS1258 = 75, + ENCODING_EBCDIC_1157 = 182, + ENCODING_UTF8 = 1, + ENCODING_CP865 = 135, + ENCODING_UCS4 = 5, + ENCODING_CP858 = 130, + ENCODING_HZ = 35, + ENCODING_CP863 = 133, + ENCODING_ISO2022_KR = 46, + ENCODING_C99 = 19, + ENCODING_IBM1163 = 122, + ENCODING_ISO2022_CN = 33, + ENCODING_UTF32LE = 13, + ENCODING_ASCII = 0, + ENCODING_IBM862 = 77, + ENCODING_UTF7 = 14, + ENCODING_WINDOWS950 = 38, + ENCODING_UCS2 = 2, + ENCODING_ISO8859_14 = 61, + ENCODING_IBM943 = 116, + ENCODING_CP737 = 124, + ENCODING_ISO2022_JP1 = 25, + ENCODING_UCS2_SWAPPED = 16, + ENCODING_KOI8_R = 64, + ENCODING_UCS4_SWAPPED = 18, + ENCODING_RISCOS_LATIN1 = 197, + ENCODING_JAVA = 20, + ENCODING_BIG5 = 37, + ENCODING_UTF16BE = 9, + ENCODING_EBCDIC_871 = 153, + ENCODING_UTF32BE = 12, + ENCODING_GEORGIANACADEMY = 95, + ENCODING_IBM932 = 23, + ENCODING_CP860 = 131, + ENCODING_MAC_ICELAND = 82, + ENCODING_ISO2022_JP = 24, + ENCODING_BIG5HKSCS_2004 = 41, + ENCODING_GB2312 = 28, + ENCODING_GBK = 29, + ENCODING_ISO8859_5 = 53, + ENCODING_BIG5HKSCS_2008 = 42, + ENCODING_CP852 = 126, + ENCODING_UCS4BE = 6, + ENCODING_IBM866 = 78, + ENCODING_EBCDIC_875 = 154, + ENCODING_MAC_CROATIAN = 83, + ENCODING_MAC_UKRAINE = 86, + ENCODING_EUC_JP = 21, + ENCODING_ISO2022_JP2 = 26, + ENCODING_ISO8859_11 = 59, + ENCODING_KOI8_U = 65, + ENCODING_EBCDIC_1141 = 169, + ENCODING_EBCDIC_838 = 151, + ENCODING_MSGREEK = 70, + ENCODING_UCS2BE = 3, + ENCODING_ISO8859_13 = 60, + ENCODING_BIG5_2003 = 194, + ENCODING_JISX0208 = 108, + ENCODING_EBCDIC_1146 = 174, + ENCODING_ISO8859_15 = 62, + ENCODING_ISO8859_16 = 63, + ENCODING_IBM1046 = 117, + ENCODING_KOI8_RU = 66, + ENCODING_CNGBISOIR165 = 112, + ENCODING_MSCYRL = 68, + ENCODING_MSTURK = 71, + ENCODING_EBCDIC_1165 = 186, + ENCODING_MSHEBR = 72, + ENCODING_CP855 = 128, + ENCODING_MSARAB = 73, + ENCODING_VISCII = 104, + ENCODING_WINBALTRIM = 74, + ENCODING_EBCDIC_273 = 139, + ENCODING_MACINTOSH = 80, + ENCODING_MAC_CENTRALEUROPE = 81, + ENCODING_MAC_CYRILLIC = 85, + ENCODING_MAC_GREEK = 87, + ENCODING_MAC_ARABIC = 90, + ENCODING_MAC_TURKISH = 88, + ENCODING_EBCDIC_1164 = 185, + ENCODING_MAC_HEBREW = 89, + ENCODING_EBCDIC_16804 = 190, + ENCODING_MAC_THAI = 91, + ENCODING_HPROMAN8 = 92, + ENCODING_UCS2_INTERNAL = 15, + ENCODING_NEXTSTEP = 93, + ENCODING_ARMSCII8 = 94, + ENCODING_ISO8859_2 = 50, + ENCODING_GEORGIANPS = 96, + ENCODING_PT154 = 98, + ENCODING_MAC_ROMANIA = 84, + ENCODING_IBM850 = 76, + ENCODING_RK1048 = 99, + ENCODING_ISO8859_9 = 57, + ENCODING_MULELAO1 = 100, + ENCODING_ISO2022_CN_EXT = 34, + ENCODING_IBMCP1133 = 101, + ENCODING_EBCDIC_1130 = 165, + ENCODING_TIS620 = 102, + ENCODING_MSANSI = 69, + ENCODING_WINDOWS874 = 103, + ENCODING_EBCDIC_870 = 152, + ENCODING_JISX0201 = 107, + ENCODING_TCVN = 105, + ENCODING_JP = 106, + ENCODING_JOHAB = 45, + ENCODING_ISO2022_JPMS = 27, + ENCODING_JISX0212 = 109, + ENCODING_KOREAN = 113, + ENCODING_IBM856 = 114, + ENCODING_IBM1124 = 118, + ENCODING_CP936 = 30, + ENCODING_IBM1129 = 119, + ENCODING_IBM1162 = 121, + ENCODING_CP437 = 123, + ENCODING_CP1256 = ENCODING_MSARAB, + ENCODING_MAC_ROMAN = ENCODING_MACINTOSH, + ENCODING_CP1258 = ENCODING_WINDOWS1258, + ENCODING_CP1255 = ENCODING_MSHEBR, + ENCODING_CP1254 = ENCODING_MSTURK, + ENCODING_ATARI = ENCODING_ATARIST, + ENCODING_CP1253 = ENCODING_MSGREEK, + ENCODING_CP1252 = ENCODING_MSANSI, + ENCODING_CP1257 = ENCODING_WINBALTRIM, + ENCODING_CP1251 = ENCODING_MSCYRL, + ENCODING_CP1250 = ENCODING_MSEE, + ENCODING_BIG5HKSCS = ENCODING_BIG5HKSCS_2008, + ENCODING_GB18030 = ENCODING_GB18030_2022, +}; diff --git a/lib/generated/indexes.hpp.shippet b/lib/generated/indexes.hpp.shippet new file mode 100644 index 00000000..410bf868 --- /dev/null +++ b/lib/generated/indexes.hpp.shippet @@ -0,0 +1,217 @@ +namespace reiconv::encoding +{ + enum class Encodings + { + ISO2022_JP3 = 193, + SHIFT_JISX0213 = 192, + EUC_JISX0213 = 191, + EBCDIC_12712 = 189, + EBCDIC_4971 = 188, + EBCDIC_1166 = 187, + EBCDIC_1160 = 184, + EBCDIC_1158 = 183, + EBCDIC_1155 = 180, + EBCDIC_1153 = 178, + EBCDIC_1147 = 175, + EBCDIC_1145 = 173, + EBCDIC_1144 = 172, + EBCDIC_1143 = 171, + EBCDIC_1142 = 170, + EBCDIC_1137 = 167, + EBCDIC_1132 = 166, + EBCDIC_1123 = 164, + EBCDIC_1122 = 163, + EBCDIC_1112 = 162, + EBCDIC_1097 = 161, + EBCDIC_1025 = 158, + EBCDIC_905 = 156, + EBCDIC_500 = 150, + EBCDIC_425 = 149, + EBCDIC_424 = 148, + EBCDIC_285 = 145, + EBCDIC_284 = 144, + EBCDIC_282 = 143, + EBCDIC_278 = 141, + EBCDIC_277 = 140, + CP1125 = 137, + CP869 = 136, + CP861 = 132, + EBCDIC_1047 = 160, + CP857 = 129, + EBCDIC_423 = 147, + CP853 = 127, + ISO8859_8 = 56, + EBCDIC_1154 = 179, + GB1988_80 = 110, + EBCDIC_1140 = 168, + ISO8859_6 = 54, + ISO8859_3 = 51, + IBM922 = 115, + ISO8859_1 = 49, + ISO8859_10 = 58, + DEC_HANYU = 48, + DEC_KANJI = 47, + ISO8859_4 = 52, + SHIFT_JIS = 22, + IBM1131 = 79, + EBCDIC_880 = 155, + BIG5HKSCS_2001 = 40, + MSEE = 67, + ISO8859_7 = 55, + TDS565 = 195, + EBCDIC_1148 = 176, + IBM1161 = 120, + EBCDIC_037 = 138, + CP775 = 125, + BIG5HKSCS_1999 = 39, + EUC_TW = 36, + EBCDIC_297 = 146, + UHC = 44, + EBCDIC_1156 = 181, + GB18030_2022 = 32, + UTF32 = 11, + ATARIST = 196, + CP864 = 134, + GB2312_80 = 111, + UTF16LE = 10, + EBCDIC_1149 = 177, + UTF16 = 8, + UCS4LE = 7, + EBCDIC_924 = 157, + EUC_KR = 43, + EBCDIC_1026 = 159, + GB18030_2005 = 31, + UCS4_INTERNAL = 17, + KOI8T = 97, + EBCDIC_280 = 142, + UCS2LE = 4, + WINDOWS1258 = 75, + EBCDIC_1157 = 182, + UTF8 = 1, + CP865 = 135, + UCS4 = 5, + CP858 = 130, + HZ = 35, + CP863 = 133, + ISO2022_KR = 46, + C99 = 19, + IBM1163 = 122, + ISO2022_CN = 33, + UTF32LE = 13, + ASCII = 0, + IBM862 = 77, + UTF7 = 14, + WINDOWS950 = 38, + UCS2 = 2, + ISO8859_14 = 61, + IBM943 = 116, + CP737 = 124, + ISO2022_JP1 = 25, + UCS2_SWAPPED = 16, + KOI8_R = 64, + UCS4_SWAPPED = 18, + RISCOS_LATIN1 = 197, + JAVA = 20, + BIG5 = 37, + UTF16BE = 9, + EBCDIC_871 = 153, + UTF32BE = 12, + GEORGIANACADEMY = 95, + IBM932 = 23, + CP860 = 131, + MAC_ICELAND = 82, + ISO2022_JP = 24, + BIG5HKSCS_2004 = 41, + GB2312 = 28, + GBK = 29, + ISO8859_5 = 53, + BIG5HKSCS_2008 = 42, + CP852 = 126, + UCS4BE = 6, + IBM866 = 78, + EBCDIC_875 = 154, + MAC_CROATIAN = 83, + MAC_UKRAINE = 86, + EUC_JP = 21, + ISO2022_JP2 = 26, + ISO8859_11 = 59, + KOI8_U = 65, + EBCDIC_1141 = 169, + EBCDIC_838 = 151, + MSGREEK = 70, + UCS2BE = 3, + ISO8859_13 = 60, + BIG5_2003 = 194, + JISX0208 = 108, + EBCDIC_1146 = 174, + ISO8859_15 = 62, + ISO8859_16 = 63, + IBM1046 = 117, + KOI8_RU = 66, + CNGBISOIR165 = 112, + MSCYRL = 68, + MSTURK = 71, + EBCDIC_1165 = 186, + MSHEBR = 72, + CP855 = 128, + MSARAB = 73, + VISCII = 104, + WINBALTRIM = 74, + EBCDIC_273 = 139, + MACINTOSH = 80, + MAC_CENTRALEUROPE = 81, + MAC_CYRILLIC = 85, + MAC_GREEK = 87, + MAC_ARABIC = 90, + MAC_TURKISH = 88, + EBCDIC_1164 = 185, + MAC_HEBREW = 89, + EBCDIC_16804 = 190, + MAC_THAI = 91, + HPROMAN8 = 92, + UCS2_INTERNAL = 15, + NEXTSTEP = 93, + ARMSCII8 = 94, + ISO8859_2 = 50, + GEORGIANPS = 96, + PT154 = 98, + MAC_ROMANIA = 84, + IBM850 = 76, + RK1048 = 99, + ISO8859_9 = 57, + MULELAO1 = 100, + ISO2022_CN_EXT = 34, + IBMCP1133 = 101, + EBCDIC_1130 = 165, + TIS620 = 102, + MSANSI = 69, + WINDOWS874 = 103, + EBCDIC_870 = 152, + JISX0201 = 107, + TCVN = 105, + JP = 106, + JOHAB = 45, + ISO2022_JPMS = 27, + JISX0212 = 109, + KOREAN = 113, + IBM856 = 114, + IBM1124 = 118, + CP936 = 30, + IBM1129 = 119, + IBM1162 = 121, + CP437 = 123, + CP1256 = MSARAB, + MAC_ROMAN = MACINTOSH, + CP1258 = WINDOWS1258, + CP1255 = MSHEBR, + CP1254 = MSTURK, + ATARI = ATARIST, + CP1253 = MSGREEK, + CP1252 = MSANSI, + CP1257 = WINBALTRIM, + CP1251 = MSCYRL, + CP1250 = MSEE, + BIG5HKSCS = BIG5HKSCS_2008, + GB18030 = GB18030_2022, + }; +} // reiconv::encoding diff --git a/lib/hz.h b/lib/hz.h deleted file mode 100644 index 77c9e7bd..00000000 --- a/lib/hz.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * HZ - */ - -/* Specification: RFC 1842, RFC 1843 */ - -/* - * The state is 1 in GB mode, 0 in ASCII mode. - */ - -static int -hz_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - state_t state = conv->istate; - unsigned int count = 0; - unsigned char c; - for (;;) { - c = *s; - if (c == '~') { - if (n < count+2) - goto none; - c = s[1]; - if (state == 0) { - if (c == '~') { - *pwc = (ucs4_t) '~'; - conv->istate = state; - return count+2; - } - if (c == '{') { - state = 1; - s += 2; count += 2; - if (n < count+1) - goto none; - continue; - } - if (c == '\n') { - s += 2; count += 2; - if (n < count+1) - goto none; - continue; - } - } else { - if (c == '}') { - state = 0; - s += 2; count += 2; - if (n < count+1) - goto none; - continue; - } - } - goto ilseq; - } - break; - } - if (state == 0) { - *pwc = (ucs4_t) c; - conv->istate = state; - return count+1; - } else { - int ret; - if (n < count+2) - goto none; - ret = gb2312_mbtowc(conv,pwc,s,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - conv->istate = state; - return count+2; - } - -none: - conv->istate = state; - return RET_TOOFEW(count); - -ilseq: - conv->istate = state; - return RET_SHIFT_ILSEQ(count); -} - -static int -hz_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - state_t state = conv->ostate; - unsigned char buf[2]; - int ret; - - /* Code set 0 (ASCII or GB 1988-89) */ - ret = ascii_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] < 0x80) { - int count = (state ? 3 : 1); - if (n < count) - return RET_TOOSMALL; - if (state) { - r[0] = '~'; - r[1] = '}'; - r += 2; - state = 0; - } - r[0] = buf[0]; - conv->ostate = state; - return count; - } - } - - /* Code set 1 (GB 2312-1980) */ - ret = gb2312_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state ? 2 : 4); - if (n < count) - return RET_TOOSMALL; - if (!state) { - r[0] = '~'; - r[1] = '{'; - r += 2; - state = 1; - } - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = state; - return count; - } - } - - return RET_ILUNI; -} - -static int -hz_reset (conv_t conv, unsigned char *r, size_t n) -{ - state_t state = conv->ostate; - if (state) { - if (n < 2) - return RET_TOOSMALL; - r[0] = '~'; - r[1] = '}'; - /* conv->ostate = 0; will be done by the caller */ - return 2; - } else - return 0; -} diff --git a/lib/iconv.c b/lib/iconv.c new file mode 100644 index 00000000..d2cd52e4 --- /dev/null +++ b/lib/iconv.c @@ -0,0 +1,299 @@ +/** + * @file encoding.h + * @brief Encoding structure definition. + * @copyright Copyright (C) 1999-2008, 2011, 2016, 2018, 2020, 2022-2023 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#include + +#include +#include +#include +#include + +#include "all_encodings.h" +#include "codepage_to_ei.h" +#include "encoding.h" +#include "loop_funcs.h" +#include "loops.h" + +/* + * Alias lookup function. + * Defines + * struct alias { int name; unsigned int encoding_index; }; + * const struct alias * aliases_lookup (const char *str, unsigned int len); + * #define MAX_WORD_LENGTH ... + */ +#include "generated/aliases.h" + +#define TEMP_BUFFER_SIZE 4096 + +_CPPP_API struct VersionInfo reiconv_version = {VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH}; + +_CPPP_API size_t reiconv_name_canonicalize(const char *name, char *outbuf) +{ + char *bp = outbuf; + const char *cp = name; + for (; *cp; cp++, bp++) + { + char c = (char)*cp; + if (c >= 'a' && c <= 'z') // Uppercase. + { + c -= 'a' - 'A'; + } + if (c == '-' || c == '_') // Ignore '-' and '_'. + { + bp--; + } + else + { + *bp = c; + } + } + *bp = '\0'; + return bp - outbuf; +} + +_CPPP_API int reiconv_lookup_from_name(const char *encoding) +{ + char buf[MAX_WORD_LENGTH + 2]; + size_t buf_len = reiconv_name_canonicalize(encoding, buf); + + const struct alias *ap = aliases_lookup(buf, buf_len); + return ap ? ap->encoding_index : -1; +} + +_CPPP_API int reiconv_lookup_from_codepage(int codepage) +{ + return codepage_to_eindex[codepage] - 1; +} + +_CPPP_API reiconv_t reiconv_open_from_index(int fromcode, int tocode, enum ConvertFlag flags) +{ + struct conv_struct *cd = (struct conv_struct *)malloc(sizeof(struct conv_struct)); + if (cd == NULL) + { + errno = ENOMEM; + return (reiconv_t)(-1); + } + + // Initialize the input and output functions. + cd->iindex = fromcode; + cd->ifuncs = all_encodings[fromcode].ifuncs; + cd->oindex = tocode; + cd->ofuncs = all_encodings[tocode].ofuncs; + + // Initialize the loop functions. + cd->lfuncs.loop_convert = unicode_loop_convert; + cd->lfuncs.loop_reset = unicode_loop_reset; + + // Initialize the states. + cd->istate = 0; + cd->ostate = 0; + cd->ibyteorder = 0; + + // Initialize the operation flags. + cd->discard_ilseq = flags & REICONV_DISCARD_ILSEQ; + + return cd; +} + +_CPPP_API reiconv_t reiconv_open_from_codepage(int fromcode, int tocode, enum ConvertFlag flags) +{ + int from_index = reiconv_lookup_from_codepage(fromcode); + int to_index = reiconv_lookup_from_codepage(tocode); + + if (from_index == -1 || to_index == -1) + { + errno = EINVAL; + return (reiconv_t)(-1); + } + return reiconv_open_from_index(from_index, to_index, flags); +} + +_CPPP_API reiconv_t reiconv_open_from_name(const char *fromcode, const char *tocode, enum ConvertFlag flags) +{ + int from_index = reiconv_lookup_from_name(fromcode); + int to_index = reiconv_lookup_from_name(tocode); + + if (from_index == -1 || to_index == -1) + { + errno = EINVAL; + return (reiconv_t)(-1); + } + return reiconv_open_from_index(from_index, to_index, flags); +} + +_CPPP_API reiconv_t reiconv_open(const char *tocode, const char *fromcode) +{ + char fromcode_buf[MAX_WORD_LENGTH + 2]; + char tocode_buf[MAX_WORD_LENGTH + 2]; + + size_t fromcode_len = reiconv_name_canonicalize(fromcode, fromcode_buf); + size_t tocode_len = reiconv_name_canonicalize(tocode, tocode_buf); + + enum ConvertFlag flag = REICONV_NO_FLAGS; + + for (size_t i = 0; i < fromcode_len; i++) + { + if (fromcode_buf[i] == '/') + { + fromcode_buf[i] = '\0'; + if (i + 7 < fromcode_len && memcmp(fromcode_buf + i + 1, "/IGNORE", 8) == 0) + { + flag |= REICONV_DISCARD_ILSEQ; + } + } + } + + for (size_t i = 0; i < tocode_len; i++) + { + if (tocode_buf[i] == '/') + { + tocode_buf[i] = '\0'; + if (i + 7 < tocode_len && memcmp(tocode_buf + i + 1, "/IGNORE", 7) == 0) + { + flag |= REICONV_DISCARD_ILSEQ; + } + } + } + + int from_index = reiconv_lookup_from_name(fromcode_buf); + int to_index = reiconv_lookup_from_name(tocode_buf); + if (from_index == -1 || to_index == -1) + { + errno = EINVAL; + return (reiconv_t)(-1); + } + + return reiconv_open_from_index(from_index, to_index, flag); +} + +_CPPP_API size_t reiconv_iconv(reiconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) +{ + if (inbuf == NULL || *inbuf == NULL) + { + return ((conv_t)cd)->lfuncs.loop_reset(cd, outbuf, outbytesleft); + } + return ((conv_t)cd)->lfuncs.loop_convert(cd, (const char **)inbuf, inbytesleft, outbuf, outbytesleft); +} + +_CPPP_API int reiconv_handle_close(reiconv_t icd) +{ + free(icd); + return 0; +} + +_CPPP_API size_t reiconv_result_size(reiconv_t cd, const char *start, size_t inlength) +{ + size_t count = 0; + char tmpbuf[TEMP_BUFFER_SIZE]; + char *inptr = (char *)start; + size_t insize = inlength; + while (insize > 0) + { + char *outptr = tmpbuf; + size_t outsize = TEMP_BUFFER_SIZE; + size_t res = reiconv_iconv(cd, &inptr, &insize, &outptr, &outsize); + if (res == (size_t)(-1) && errno != E2BIG) + { + if (errno == EINVAL) + { + errno = EILSEQ; + } + return (size_t)(-1); + } + count += outptr - tmpbuf; + } + char *outptr = tmpbuf; + size_t outsize = TEMP_BUFFER_SIZE; + size_t res = reiconv_iconv(cd, NULL, NULL, &outptr, &outsize); + if (res == (size_t)(-1)) + { + // Return to the initial state. + reiconv_iconv(cd, NULL, NULL, NULL, NULL); + return (size_t)(-1); + } + reiconv_iconv(cd, NULL, NULL, NULL, NULL); + return count + outptr - tmpbuf; +} + +_CPPP_API int reiconv_convert_static_size(reiconv_t cd, const char *input_data, size_t input_length, char *output_data, + size_t output_length) +{ + char *inptr = (char *)input_data; + size_t insize = input_length; + char *outptr = output_data; + size_t outsize = output_length; + while (insize > 0) + { + size_t res = reiconv_iconv(cd, &inptr, &insize, &outptr, &outsize); + if (res == (size_t)(-1)) + { + if (errno == EINVAL) + { + break; + } + else + { + return -1; + } + } + } + if (reiconv_iconv(cd, NULL, NULL, &outptr, &outsize) == (size_t)(-1)) + { + return -1; + } + return 0; +} + +_CPPP_API int reiconv_convert(reiconv_t cd, const char *input_data, size_t input_length, char **output_data_ptr, + size_t *output_length_ptr) +{ + size_t output_length = reiconv_result_size(cd, input_data, input_length); + if (output_length == (size_t)(-1)) + { + return -1; + } + + if (output_length_ptr != NULL) + { + *output_length_ptr = output_length; + } + + if (output_data_ptr == NULL) + { + errno = EINVAL; + return -1; + } + + *output_data_ptr = + (*output_data_ptr == NULL ? (char *)malloc(output_length) : (char *)realloc(*output_data_ptr, output_length)); + + if (reiconv_convert_static_size(cd, input_data, input_length, *output_data_ptr, output_length) == -1) + { + free(*output_data_ptr); + *output_data_ptr = NULL; + return -1; + } + + return 0; +} diff --git a/lib/iconv.cpp b/lib/iconv.cpp deleted file mode 100644 index 98c3183e..00000000 --- a/lib/iconv.cpp +++ /dev/null @@ -1,659 +0,0 @@ -/* - * Copyright (C) 1999-2008, 2011, 2016, 2018, 2020, 2022-2023 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -#include - -#include -#include -#include -#include - -namespace cppp -{ -namespace base -{ -namespace reiconv -{ - -#if ENABLE_EXTRA -/* - * Consider all system dependent encodings, for any system, - * and the extra encodings. - */ -#define USE_AIX -#define USE_OSF1 -#define USE_DOS -#define USE_ZOS -#define USE_EXTRA -#else -/* - * Consider those system dependent encodings that are needed for the - * current system. - */ -#ifdef _AIX -#define USE_AIX -#endif -#if defined(__osf__) || defined(VMS) -#define USE_OSF1 -#endif -#if defined(__DJGPP__) || (defined(_WIN32) && (defined(_MSC_VER) || defined(__MINGW32__))) -#define USE_DOS -#endif -/* Enable the EBCDIC encodings not only on z/OS but also on Linux/s390, for - easier interoperability between z/OS and Linux/s390. */ -#if defined(__MVS__) || (defined(__linux__) && (defined(__s390__) || defined(__s390x__))) -#define USE_ZOS -#endif -#endif - -/* - * Data type for general conversion loop. - */ -struct loop_funcs -{ - size_t (*loop_convert)(iconv_t icd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); - size_t (*loop_reset)(iconv_t icd, char **outbuf, size_t *outbytesleft); -}; - -/* - * Converters. - */ -#include "converters.h" - -/* - * Table of all supported encodings. - */ -struct encoding -{ - struct mbtowc_funcs ifuncs; /* conversion multibyte -> unicode */ - struct wctomb_funcs ofuncs; /* conversion unicode -> multibyte */ - int oflags; /* flags for unicode -> multibyte conversion */ - int codepage; /* codepage number */ -}; -#define DEFALIAS(xxx_alias, xxx) /* nothing */ -enum -{ -#define DEFENCODING(xxx_names, codepage, xxx, xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2) ei_##xxx, -#include "encodings.def" -#ifdef USE_AIX -#include "encodings_aix.def" -#endif -#ifdef USE_OSF1 -#include "encodings_osf1.def" -#endif -#ifdef USE_DOS -#include "encodings_dos.def" -#endif -#ifdef USE_ZOS -#include "encodings_zos.def" -#endif -#ifdef USE_EXTRA -#include "encodings_extra.def" -#endif -#undef DEFENCODING - ei_for_broken_compilers_that_dont_like_trailing_commas -}; -#include "flags.h" -static struct encoding const all_encodings[] = { -#define DEFENCODING(xxx_names, codepage, xxx, xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2) \ - {xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2, ei_##xxx##_oflags, codepage}, -#include "encodings.def" -#ifdef USE_AIX -#include "encodings_aix.def" -#endif -#ifdef USE_OSF1 -#include "encodings_osf1.def" -#endif -#ifdef USE_DOS -#include "encodings_dos.def" -#endif -#ifdef USE_ZOS -#include "encodings_zos.def" -#endif -#ifdef USE_EXTRA -#include "encodings_extra.def" -#endif -#undef DEFENCODING -}; -#undef DEFALIAS - -int lookup_by_codepage(int codepage) -{ - for(size_t i = 0; i < sizeof(all_encodings) / sizeof(all_encodings[0]); i++) - { - if(all_encodings[i].codepage == codepage) - { - return i; - } - } - return -1; -} - -/* - * Conversion loops. - */ -#include "loops.h" - -/* - * Alias lookup function. - * Defines - * struct alias { int name; unsigned int encoding_index; }; - * const struct alias * HashPool::aliases_lookup (const char *str, unsigned int len); - * #define MAX_WORD_LENGTH ... - */ -#if defined _AIX -#include "aliases_sysaix.h" -#elif defined hpux || defined __hpux -#include "aliases_syshpux.h" -#elif defined __osf__ -#include "aliases_sysosf1.h" -#elif defined __sun -#include "aliases_syssolaris.h" -#else -#include "aliases.h" -#endif - -/* - * System dependent alias lookup function. - * Defines - * const struct alias * aliases2_lookup (const char *str); - */ -#if defined(USE_AIX) || defined(USE_OSF1) || defined(USE_DOS) || defined(USE_ZOS) || defined(USE_EXTRA) /* || ... */ -struct stringpool2_t -{ -#define S(tag, name, encoding_index) char stringpool_##tag[sizeof(name)]; -#include "aliases2.h" -#undef S -}; -static const struct stringpool2_t stringpool2_contents = { -#define S(tag, name, encoding_index) name, -#include "aliases2.h" -#undef S -}; -#define stringpool2 ((const char *)&stringpool2_contents) -static const struct alias sysdep_aliases[] = { -#define S(tag, name, encoding_index) {(int)(size_t)(void*)&((struct stringpool2_t *)0)->stringpool_##tag, encoding_index}, -#include "aliases2.h" -#undef S -}; -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif - static const struct alias * - aliases2_lookup(const char *str) -{ - const struct alias *ptr; - unsigned int count; - for (ptr = sysdep_aliases, count = sizeof(sysdep_aliases) / sizeof(sysdep_aliases[0]); count > 0; ptr++, count--) - if (!strcmp(str, stringpool2 + ptr->name)) - return ptr; - return NULL; -} -#else -#define aliases2_lookup(str) NULL -#define stringpool2 NULL -#endif - -#if 0 - /* Like !strcasecmp, except that the both strings can be assumed to be ASCII - and the first string can be assumed to be in uppercase. */ - static int strequal (const char* str1, const char* str2) - { - unsigned char c1; - unsigned char c2; - for (;;) { - c1 = * (unsigned char *) str1++; - c2 = * (unsigned char *) str2++; - if (c1 == 0) - break; - if (c2 >= 'a' && c2 <= 'z') - c2 -= 'a'-'A'; - if (c1 != c2) - break; - } - return (c1 == c2); - } -#endif - -iconv_t iconv_open(const char *tocode, const char *fromcode) -{ - struct conv_struct *cd; - unsigned int from_index; - unsigned int from_surface; - unsigned int to_index; - unsigned int to_surface; - int discard_ilseq; - -#include "iconv_open1.h" - - cd = (struct conv_struct *)malloc(sizeof(struct conv_struct)); - if (cd == NULL) - { - errno = ENOMEM; - return (iconv_t)(-1); - } - -#include "iconv_open2.h" - - return (iconv_t)cd; -invalid: - errno = EINVAL; - return (iconv_t)(-1); -} - -iconv_t iconv_open(int tocode_cp, int fromcode_cp, bool strict) -{ - struct conv_struct *cd; - unsigned int from_index; - unsigned int from_surface; - unsigned int to_index; - unsigned int to_surface; - int discard_ilseq = (int)!strict; - - from_surface = ICONV_SURFACE_NONE; - to_surface = ICONV_SURFACE_NONE; - - to_index = lookup_by_codepage(tocode_cp); - from_index = lookup_by_codepage(fromcode_cp); - - if(to_index == -1 || from_index == -1 || tocode_cp == -1 || fromcode_cp == -1) - { - errno = EINVAL; - return (iconv_t)(-1); - } - - cd = (struct conv_struct *)malloc(sizeof(struct conv_struct)); - if (cd == NULL) - { - errno = ENOMEM; - return (iconv_t)(-1); - } - - #include "iconv_open2.h" - - return (iconv_t)cd; -} - -size_t iconv(iconv_t icd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) -{ - conv_t cd = (conv_t)icd; - if (inbuf == NULL || *inbuf == NULL) - return cd->lfuncs.loop_reset(icd, outbuf, outbytesleft); - else - return cd->lfuncs.loop_convert(icd, (const char **)inbuf, inbytesleft, outbuf, outbytesleft); -} - -int iconv_close(iconv_t icd) -{ - conv_t cd = (conv_t)icd; - free(cd); - return 0; -} - -/* Bit mask of all valid surfaces. */ -#define ALL_SURFACES (ICONV_SURFACE_EBCDIC_ZOS_UNIX) - -int iconvctl(iconv_t icd, int request, void *argument) -{ - conv_t cd = (conv_t)icd; - switch (request) - { - case ICONV_TRIVIALP: - *(int *)argument = ((cd->lfuncs.loop_convert == unicode_loop_convert && cd->iindex == cd->oindex && - cd->isurface == cd->osurface) - ? 1 - : 0); - return 0; - case ICONV_GET_DISCARD_ILSEQ: - *(int *)argument = cd->discard_ilseq; - return 0; - case ICONV_SET_DISCARD_ILSEQ: - cd->discard_ilseq = (*(const int *)argument ? 1 : 0); - return 0; - case ICONV_SET_HOOKS: - if (argument != NULL) - { - cd->hooks = *(const struct iconv_hooks *)argument; - } - else - { - cd->hooks.uc_hook = NULL; - cd->hooks.data = NULL; - } - return 0; - case ICONV_SET_FALLBACKS: - if (argument != NULL) - { - cd->fallbacks = *(const struct iconv_fallbacks *)argument; - } - else - { - cd->fallbacks.mb_to_uc_fallback = NULL; - cd->fallbacks.uc_to_mb_fallback = NULL; - cd->fallbacks.data = NULL; - } - return 0; - case ICONV_GET_FROM_SURFACE: - *(unsigned int *)argument = cd->isurface; - return 0; - case ICONV_SET_FROM_SURFACE: - if ((*(const unsigned int *)argument & ~ALL_SURFACES) == 0) - { - cd->isurface = *(const unsigned int *)argument; - return 0; - } - else - { - errno = EINVAL; - return -1; - } - case ICONV_GET_TO_SURFACE: - *(unsigned int *)argument = cd->osurface; - return 0; - case ICONV_SET_TO_SURFACE: - if ((*(const unsigned int *)argument & ~ALL_SURFACES) == 0) - { - cd->osurface = *(const unsigned int *)argument; - return 0; - } - else - { - errno = EINVAL; - return -1; - } - default: - errno = EINVAL; - return -1; - } -} - -/* An alias after its name has been converted from 'int' to 'const char*'. */ -struct nalias -{ - const char *name; - unsigned int encoding_index; -}; - -static int compare_by_index(const void *arg1, const void *arg2) -{ - const struct nalias *alias1 = (const struct nalias *)arg1; - const struct nalias *alias2 = (const struct nalias *)arg2; - return (int)alias1->encoding_index - (int)alias2->encoding_index; -} - -static int compare_by_name(const void *arg1, const void *arg2) -{ - const char *name1 = *(const char *const *)arg1; - const char *name2 = *(const char *const *)arg2; - /* Compare alphabetically, but put "CS" names at the end. */ - int sign = strcmp(name1, name2); - if (sign != 0) - { - sign = ((name1[0] == 'C' && name1[1] == 'S') - (name2[0] == 'C' && name2[1] == 'S')) * 4 + (sign >= 0 ? 1 : -1); - } - return sign; -} - -void iconvlist(int (*do_one)(unsigned int namescount, const char *const *names, void *data), void *data) -{ -#define aliascount1 sizeof(aliases) / sizeof(aliases[0]) -#ifndef aliases2_lookup -#define aliascount2 sizeof(sysdep_aliases) / sizeof(sysdep_aliases[0]) -#else -#define aliascount2 0 -#endif -#define aliascount (aliascount1 + aliascount2) - struct nalias aliasbuf[aliascount]; - const char *namesbuf[aliascount]; - size_t num_aliases; - { - /* Put all existing aliases into a buffer. */ - size_t i; - size_t j; - j = 0; - for (i = 0; i < aliascount1; i++) - { - const struct alias *p = &aliases[i]; - if (p->name >= 0) - { - aliasbuf[j].name = stringpool + p->name; - aliasbuf[j].encoding_index = p->encoding_index; - j++; - } - } -#ifndef aliases2_lookup - for (i = 0; i < aliascount2; i++) - { - aliasbuf[j].name = stringpool2 + sysdep_aliases[i].name; - aliasbuf[j].encoding_index = sysdep_aliases[i].encoding_index; - j++; - } -#endif - num_aliases = j; - } - /* Sort by encoding_index. */ - if (num_aliases > 1) - qsort(aliasbuf, num_aliases, sizeof(struct nalias), compare_by_index); - { - /* Process all aliases with the same encoding_index together. */ - size_t j; - j = 0; - while (j < num_aliases) - { - unsigned int ei = aliasbuf[j].encoding_index; - size_t i = 0; - do - namesbuf[i++] = aliasbuf[j++].name; - while (j < num_aliases && aliasbuf[j].encoding_index == ei); - if (i > 1) - qsort(namesbuf, i, sizeof(const char *), compare_by_name); - /* Call the callback. */ - if (do_one(i, namesbuf, data)) - break; - } - } -#undef aliascount -#undef aliascount2 -#undef aliascount1 -} - -/* version number: (major<<8) + minor */ -int reiconv_version = (2 << 8) + 1; - -constexpr size_t tmpbufsize = 4096; - -int iconv_string(const iconv_t& cd, const char *start, const char *end, char **resultp, - size_t *lengthp) -{ - size_t length; - char* result; - /* Determine the length we need. */ - { - size_t count = 0; - char tmpbuf[tmpbufsize]; - char* inptr = (char*)start; - size_t insize = end - start; - while (insize > 0) - { - char *outptr = tmpbuf; - size_t outsize = tmpbufsize; - size_t res = iconv(cd, &inptr, &insize, &outptr, &outsize); - if (res == (size_t)(-1) && errno != E2BIG) - { - return (errno == EINVAL ? EILSEQ : errno); - } - count += outptr - tmpbuf; - } - { - char *outptr = tmpbuf; - size_t outsize = tmpbufsize; - size_t res = iconv(cd, NULL, NULL, &outptr, &outsize); - if (res == (size_t)(-1)) - { - return errno; - } - count += outptr - tmpbuf; - } - length = count; - } - if (lengthp != NULL) - { - *lengthp = length; - } - if (resultp == NULL) - { - /* If resultp is nullptr, we can't save results. */ - return 0; - } - result = (*resultp == NULL ? (char*)malloc(length) : (char*)realloc(*resultp, length)); - *resultp = result; - if (length == 0) - { - return 0; - } - if (result == NULL) - { - return (errno = ENOMEM); - } - iconv(cd, NULL, NULL, NULL, NULL); /* return to the initial state */ - /* Do the conversion for real. */ - { - char* inptr = (char*)start; - size_t insize = end - start; - char* outptr = result; - size_t outsize = length; - while (insize > 0) - { - size_t res = iconv(cd, &inptr, &insize, &outptr, &outsize); - if (res == (size_t)(-1)) - { - if (errno == EINVAL) - { - break; - } - else - { - return errno; - } - } - } - { - size_t res = iconv(cd, NULL, NULL, &outptr, &outsize); - if (res == (size_t)(-1)) - { - return errno; - } - } - if (outsize != 0) - { - abort(); - } - } - return 0; -} - -int iconv_string(const char* tocode, const char* fromcode, const char* start, - const char* end, char** resultp, size_t* lengthp) -{ - iconv_t cd = iconv_open(tocode, fromcode); - if (cd == (iconv_t)(-1)) - { - if (errno != EINVAL) - { - return -1; - } - -#pragma region autodetect - /* Unsupported fromcode or tocode. Check whether the caller requested - autodetection. */ - if (!strcmp(fromcode, "autodetect_utf8")) - { - int ret; - /* Try UTF-8 first. There are very few ISO-8859-1 inputs that would - be valid UTF-8, but many UTF-8 inputs are valid ISO-8859-1. */ - ret = iconv_string(tocode, "UTF-8", start, end, resultp, lengthp); - if (!(ret < 0 && errno == EILSEQ)) - return ret; - ret = iconv_string(tocode, "ISO-8859-1", start, end, resultp, lengthp); - return ret; - } - if (!strcmp(fromcode, "autodetect_jp")) - { - int ret; - /* Try 7-bit encoding first. If the input contains bytes >= 0x80, - it will fail. */ - ret = iconv_string(tocode, "ISO-2022-JP-2", start, end, resultp, lengthp); - if (!(ret < 0 && errno == EILSEQ)) - return ret; - /* Try EUC-JP next. Short SHIFT_JIS inputs may come out wrong. This - is unavoidable. People will condemn SHIFT_JIS. - If we tried SHIFT_JIS first, then some short EUC-JP inputs would - come out wrong, and people would condemn EUC-JP and Unix, which - would not be good. */ - ret = iconv_string(tocode, "EUC-JP", start, end, resultp, lengthp); - if (!(ret < 0 && errno == EILSEQ)) - return ret; - /* Finally try SHIFT_JIS. */ - ret = iconv_string(tocode, "SHIFT_JIS", start, end, resultp, lengthp); - return ret; - } - if (!strcmp(fromcode, "autodetect_kr")) - { - int ret; - /* Try 7-bit encoding first. If the input contains bytes >= 0x80, - it will fail. */ - ret = iconv_string(tocode, "ISO-2022-KR", start, end, resultp, lengthp); - if (!(ret < 0 && errno == EILSEQ)) - return ret; - /* Finally try EUC-KR. */ - ret = iconv_string(tocode, "EUC-KR", start, end, resultp, lengthp); - return ret; - } -#pragma endregion - - errno = EINVAL; - return -1; - } - - int ret = iconv_string(cd, start, end, resultp, lengthp); - iconv_close(cd); - return ret; -} - -int iconv_string(int tocode_cp, int fromcode_cp, const char* start, - const char* end, char** resultp, size_t* lengthp, bool strict) -{ - iconv_t cd = iconv_open(tocode_cp, fromcode_cp, strict); - if (cd == (iconv_t)(-1)) - { - return errno; - } - - int ret = iconv_string(cd, start, end, resultp, lengthp); - iconv_close(cd); - return ret; -} - -} // namespace reiconv -} // namespace base -} // namespace cppp diff --git a/lib/iconv_open1.h b/lib/iconv_open1.h deleted file mode 100644 index 1f4aa4dc..00000000 --- a/lib/iconv_open1.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 1999-2008, 2011, 2018, 2020, 2023 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* Part 1 of iconv_open. - Input: const char* tocode, const char* fromcode. - Output: - unsigned int from_index; - unsigned int from_surface; - unsigned int to_index; - unsigned int to_surface; - int discard_ilseq; - Jumps to 'invalid' in case of errror. - */ -{ - char buf[MAX_WORD_LENGTH + 9 + 9 + 1]; - const char *cp; - char *bp; - const struct alias *ap; - unsigned int count; - - from_surface = ICONV_SURFACE_NONE; - to_surface = ICONV_SURFACE_NONE; - discard_ilseq = 0; - - /* Before calling HashPool::aliases_lookup, convert the input string to upper case, - * and check whether it's entirely ASCII (we call gperf with option "-7" - * to achieve a smaller table) and non-empty. If it's not entirely ASCII, - * or if it's too long, it is not a valid encoding name. - */ - - /* Search tocode in the table. */ - for (cp = tocode, bp = buf, count = MAX_WORD_LENGTH + 9 + 9 + 1;; cp++, bp++) - { - unsigned char c = (unsigned char)*cp; - if (c >= 0x80) - goto invalid; - if (c >= 'a' && c <= 'z') - c -= 'a' - 'A'; - *bp = c; - if (c == '\0') - break; - if (--count == 0) - goto invalid; - } - for (;;) - { - char *sp = bp; - int parsed_ignore = 0; - if (sp - buf > 7 && memcmp(sp - 7, "/IGNORE", 7) == 0) - { - sp = sp - 7; - parsed_ignore = 1; - } - if (sp > buf && memcmp(sp - 1, "/", 1) == 0) - { - bp = sp - 1; - } - else if (sp - buf >= 9 && memcmp(sp - 9, "/ZOS_UNIX", 9) == 0) - { - bp = sp - 9; - to_surface = ICONV_SURFACE_EBCDIC_ZOS_UNIX; - } - else - break; - *bp = '\0'; - if (parsed_ignore) - discard_ilseq = 1; - break; - } - ap = HashPool::aliases_lookup(buf, bp - buf); - if (ap == NULL) - { - ap = aliases2_lookup(buf); - if (ap == NULL) - goto invalid; - } - to_index = ap->encoding_index; - - /* Search fromcode in the table. */ - for (cp = fromcode, bp = buf, count = MAX_WORD_LENGTH + 9 + 9 + 1;; cp++, bp++) - { - unsigned char c = (unsigned char)*cp; - if (c >= 0x80) - goto invalid; - if (c >= 'a' && c <= 'z') - c -= 'a' - 'A'; - *bp = c; - if (c == '\0') - break; - if (--count == 0) - goto invalid; - } - for (;;) - { - char *sp = bp; - int parsed_ignore = 0; - if (sp - buf > 7 && memcmp(sp - 7, "/IGNORE", 7) == 0) - { - sp = sp - 7; - parsed_ignore = 1; - } - if (sp > buf && memcmp(sp - 1, "/", 1) == 0) - { - bp = sp - 1; - } - else if (sp - buf >= 9 && memcmp(sp - 9, "/ZOS_UNIX", 9) == 0) - { - bp = sp - 9; - from_surface = ICONV_SURFACE_EBCDIC_ZOS_UNIX; - } - else - break; - *bp = '\0'; - if (parsed_ignore) - discard_ilseq = 1; - break; - } - ap = HashPool::aliases_lookup(buf, bp - buf); - if (ap == NULL) - { - ap = aliases2_lookup(buf); - if (ap == NULL) - goto invalid; - } - from_index = ap->encoding_index; -} diff --git a/lib/iconv_open2.h b/lib/iconv_open2.h deleted file mode 100644 index 55cf7be2..00000000 --- a/lib/iconv_open2.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 1999-2009, 2023 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* Part 2 of iconv_open. - Input: - struct conv_struct * cd; - unsigned int from_index; - unsigned int from_surface; - unsigned int to_index; - unsigned int to_surface; - int discard_ilseq; - Output: none. - Side effects: Fills cd. - */ - -cd->iindex = from_index; -cd->ifuncs = all_encodings[from_index].ifuncs; -cd->oindex = to_index; -cd->ofuncs = all_encodings[to_index].ofuncs; -cd->oflags = all_encodings[to_index].oflags; -/* Initialize the loop functions. */ -cd->lfuncs.loop_convert = unicode_loop_convert; -cd->lfuncs.loop_reset = unicode_loop_reset; -/* Initialize the surfaces. */ -cd->isurface = from_surface; -cd->osurface = to_surface; -/* Initialize the states. */ -memset(&cd->istate, '\0', sizeof(state_t)); -memset(&cd->ostate, '\0', sizeof(state_t)); -/* Initialize the operation flags. */ -cd->discard_ilseq = discard_ilseq; -cd->fallbacks.mb_to_uc_fallback = NULL; -cd->fallbacks.uc_to_mb_fallback = NULL; -cd->fallbacks.data = NULL; -cd->hooks.uc_hook = NULL; -cd->hooks.data = NULL; -/* Done. */ diff --git a/lib/iso2022_cn.h b/lib/iso2022_cn.h deleted file mode 100644 index c2986119..00000000 --- a/lib/iso2022_cn.h +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * ISO-2022-CN - */ - -/* Specification: RFC 1922 */ - -#define ESC 0x1b -#define SO 0x0e -#define SI 0x0f - -/* - * The state is composed of one of the following values - */ -#define STATE_ASCII 0 -#define STATE_TWOBYTE 1 -/* - * and one of the following values, << 8 - */ -#define STATE2_NONE 0 -#define STATE2_DESIGNATED_GB2312 1 -#define STATE2_DESIGNATED_CNS11643_1 2 -/* - * and one of the following values, << 16 - */ -#define STATE3_NONE 0 -#define STATE3_DESIGNATED_CNS11643_2 1 - -#define SPLIT_STATE \ - unsigned int state1 = state & 0xff, state2 = (state >> 8) & 0xff, state3 = state >> 16 -#define COMBINE_STATE \ - state = (state3 << 16) | (state2 << 8) | state1 - -static int -iso2022_cn_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - state_t state = conv->istate; - SPLIT_STATE; - int count = 0; - unsigned char c; - for (;;) { - c = *s; - if (c == ESC) { - if (n < count+4) - goto none; - if (s[1] == '$') { - if (s[2] == ')') { - if (s[3] == 'A') { - state2 = STATE2_DESIGNATED_GB2312; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - if (s[3] == 'G') { - state2 = STATE2_DESIGNATED_CNS11643_1; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - } - if (s[2] == '*') { - if (s[3] == 'H') { - state3 = STATE3_DESIGNATED_CNS11643_2; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - } - } - if (s[1] == 'N') { - switch (state3) { - case STATE3_NONE: - goto ilseq; - case STATE3_DESIGNATED_CNS11643_2: - if (s[2] < 0x80 && s[3] < 0x80) { - int ret = cns11643_2_mbtowc(conv,pwc,s+2,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+4; - } else - goto ilseq; - default: abort(); - } - } - goto ilseq; - } - if (c == SO) { - if (state2 != STATE2_DESIGNATED_GB2312 && state2 != STATE2_DESIGNATED_CNS11643_1) - goto ilseq; - state1 = STATE_TWOBYTE; - s++; count++; - if (n < count+1) - goto none; - continue; - } - if (c == SI) { - state1 = STATE_ASCII; - s++; count++; - if (n < count+1) - goto none; - continue; - } - break; - } - switch (state1) { - case STATE_ASCII: - if (c < 0x80) { - int ret = ascii_mbtowc(conv,pwc,s,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - if (*pwc == 0x000a || *pwc == 0x000d) { - state2 = STATE2_NONE; state3 = STATE3_NONE; - } - COMBINE_STATE; - conv->istate = state; - return count+1; - } else - goto ilseq; - case STATE_TWOBYTE: - if (n < count+2) - goto none; - if (s[0] < 0x80 && s[1] < 0x80) { - int ret; - switch (state2) { - case STATE2_NONE: - goto ilseq; - case STATE2_DESIGNATED_GB2312: - ret = gb2312_mbtowc(conv,pwc,s,2); break; - case STATE2_DESIGNATED_CNS11643_1: - ret = cns11643_1_mbtowc(conv,pwc,s,2); break; - default: abort(); - } - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+2; - } else - goto ilseq; - default: abort(); - } - -none: - COMBINE_STATE; - conv->istate = state; - return RET_TOOFEW(count); - -ilseq: - COMBINE_STATE; - conv->istate = state; - return RET_SHIFT_ILSEQ(count); -} - -static int -iso2022_cn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - state_t state = conv->ostate; - SPLIT_STATE; - unsigned char buf[3]; - int ret; - - /* There is no need to handle Unicode 3.1 tag characters and to look for - "zh-CN" or "zh-TW" tags, because GB2312 and CNS11643 are disjoint. */ - - /* Try ASCII. */ - ret = ascii_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] < 0x80) { - int count = (state1 == STATE_ASCII ? 1 : 2); - if (n < count) - return RET_TOOSMALL; - if (state1 != STATE_ASCII) { - r[0] = SI; - r += 1; - state1 = STATE_ASCII; - } - r[0] = buf[0]; - if (wc == 0x000a || wc == 0x000d) { - state2 = STATE2_NONE; state3 = STATE3_NONE; - } - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - /* Try GB 2312-1980. */ - ret = gb2312_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state2 == STATE2_DESIGNATED_GB2312 ? 0 : 4) + (state1 == STATE_TWOBYTE ? 0 : 1) + 2; - if (n < count) - return RET_TOOSMALL; - if (state2 != STATE2_DESIGNATED_GB2312) { - r[0] = ESC; - r[1] = '$'; - r[2] = ')'; - r[3] = 'A'; - r += 4; - state2 = STATE2_DESIGNATED_GB2312; - } - if (state1 != STATE_TWOBYTE) { - r[0] = SO; - r += 1; - state1 = STATE_TWOBYTE; - } - r[0] = buf[0]; - r[1] = buf[1]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - ret = cns11643_wctomb(conv,buf,wc,3); - if (ret != RET_ILUNI) { - if (ret != 3) abort(); - - /* Try CNS 11643-1992 Plane 1. */ - if (buf[0] == 1 && buf[1] < 0x80 && buf[2] < 0x80) { - int count = (state2 == STATE2_DESIGNATED_CNS11643_1 ? 0 : 4) + (state1 == STATE_TWOBYTE ? 0 : 1) + 2; - if (n < count) - return RET_TOOSMALL; - if (state2 != STATE2_DESIGNATED_CNS11643_1) { - r[0] = ESC; - r[1] = '$'; - r[2] = ')'; - r[3] = 'G'; - r += 4; - state2 = STATE2_DESIGNATED_CNS11643_1; - } - if (state1 != STATE_TWOBYTE) { - r[0] = SO; - r += 1; - state1 = STATE_TWOBYTE; - } - r[0] = buf[1]; - r[1] = buf[2]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - - /* Try CNS 11643-1992 Plane 2. */ - if (buf[0] == 2 && buf[1] < 0x80 && buf[2] < 0x80) { - int count = (state3 == STATE3_DESIGNATED_CNS11643_2 ? 0 : 4) + 4; - if (n < count) - return RET_TOOSMALL; - if (state3 != STATE3_DESIGNATED_CNS11643_2) { - r[0] = ESC; - r[1] = '$'; - r[2] = '*'; - r[3] = 'H'; - r += 4; - state3 = STATE3_DESIGNATED_CNS11643_2; - } - r[0] = ESC; - r[1] = 'N'; - r[2] = buf[1]; - r[3] = buf[2]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - return RET_ILUNI; -} - -static int -iso2022_cn_reset (conv_t conv, unsigned char *r, size_t n) -{ - state_t state = conv->ostate; - SPLIT_STATE; - (void)state2; - (void)state3; - if (state1 != STATE_ASCII) { - if (n < 1) - return RET_TOOSMALL; - r[0] = SI; - /* conv->ostate = 0; will be done by the caller */ - return 1; - } else - return 0; -} - -#undef COMBINE_STATE -#undef SPLIT_STATE -#undef STATE3_DESIGNATED_CNS11643_2 -#undef STATE3_NONE -#undef STATE2_DESIGNATED_CNS11643_1 -#undef STATE2_DESIGNATED_GB2312 -#undef STATE2_NONE -#undef STATE_TWOBYTE -#undef STATE_ASCII diff --git a/lib/iso2022_cnext.h b/lib/iso2022_cnext.h deleted file mode 100644 index 52a0b26b..00000000 --- a/lib/iso2022_cnext.h +++ /dev/null @@ -1,589 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * ISO-2022-CN-EXT - */ - -/* Specification: RFC 1922 */ - -#define ESC 0x1b -#define SO 0x0e -#define SI 0x0f - -/* - * The state is composed of one of the following values - */ -#define STATE_ASCII 0 -#define STATE_TWOBYTE 1 -/* - * and one of the following values, << 8 - */ -#define STATE2_NONE 0 -#define STATE2_DESIGNATED_GB2312 1 -#define STATE2_DESIGNATED_CNS11643_1 2 -#define STATE2_DESIGNATED_ISO_IR_165 3 -/* - * and one of the following values, << 16 - */ -#define STATE3_NONE 0 -#define STATE3_DESIGNATED_CNS11643_2 1 -/* - * and one of the following values, << 24 - */ -#define STATE4_NONE 0 -#define STATE4_DESIGNATED_CNS11643_3 1 -#define STATE4_DESIGNATED_CNS11643_4 2 -#define STATE4_DESIGNATED_CNS11643_5 3 -#define STATE4_DESIGNATED_CNS11643_6 4 -#define STATE4_DESIGNATED_CNS11643_7 5 - -#define SPLIT_STATE \ - unsigned int state1 = state & 0xff, state2 = (state >> 8) & 0xff, state3 = (state >> 16) & 0xff, state4 = state >> 24 -#define COMBINE_STATE \ - state = (state4 << 24) | (state3 << 16) | (state2 << 8) | state1 - -static int -iso2022_cn_ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - state_t state = conv->istate; - SPLIT_STATE; - int count = 0; - unsigned char c; - for (;;) { - c = *s; - if (c == ESC) { - if (n < count+4) - goto none; - if (s[1] == '$') { - if (s[2] == ')') { - if (s[3] == 'A') { - state2 = STATE2_DESIGNATED_GB2312; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - if (s[3] == 'G') { - state2 = STATE2_DESIGNATED_CNS11643_1; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - if (s[3] == 'E') { - state2 = STATE2_DESIGNATED_ISO_IR_165; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - } - if (s[2] == '*') { - if (s[3] == 'H') { - state3 = STATE3_DESIGNATED_CNS11643_2; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - } - if (s[2] == '+') { - if (s[3] == 'I') { - state4 = STATE4_DESIGNATED_CNS11643_3; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - if (s[3] == 'J') { - state4 = STATE4_DESIGNATED_CNS11643_4; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - if (s[3] == 'K') { - state4 = STATE4_DESIGNATED_CNS11643_5; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - if (s[3] == 'L') { - state4 = STATE4_DESIGNATED_CNS11643_6; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - if (s[3] == 'M') { - state4 = STATE4_DESIGNATED_CNS11643_7; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - } - } - if (s[1] == 'N') { - switch (state3) { - case STATE3_NONE: - goto ilseq; - case STATE3_DESIGNATED_CNS11643_2: - if (s[2] < 0x80 && s[3] < 0x80) { - int ret = cns11643_2_mbtowc(conv,pwc,s+2,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+4; - } else - goto ilseq; - default: abort(); - } - } - if (s[1] == 'O') { - switch (state4) { - case STATE4_NONE: - goto ilseq; - case STATE4_DESIGNATED_CNS11643_3: - if (s[2] < 0x80 && s[3] < 0x80) { - int ret = cns11643_3_mbtowc(conv,pwc,s+2,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+4; - } else - goto ilseq; - case STATE4_DESIGNATED_CNS11643_4: - if (s[2] < 0x80 && s[3] < 0x80) { - int ret = cns11643_4_mbtowc(conv,pwc,s+2,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+4; - } else - goto ilseq; - case STATE4_DESIGNATED_CNS11643_5: - if (s[2] < 0x80 && s[3] < 0x80) { - int ret = cns11643_5_mbtowc(conv,pwc,s+2,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+4; - } else - goto ilseq; - case STATE4_DESIGNATED_CNS11643_6: - if (s[2] < 0x80 && s[3] < 0x80) { - int ret = cns11643_6_mbtowc(conv,pwc,s+2,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+4; - } else - goto ilseq; - case STATE4_DESIGNATED_CNS11643_7: - if (s[2] < 0x80 && s[3] < 0x80) { - int ret = cns11643_7_mbtowc(conv,pwc,s+2,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+4; - } else - goto ilseq; - default: abort(); - } - } - goto ilseq; - } - if (c == SO) { - if (state2 != STATE2_DESIGNATED_GB2312 && state2 != STATE2_DESIGNATED_CNS11643_1 && state2 != STATE2_DESIGNATED_ISO_IR_165) - goto ilseq; - state1 = STATE_TWOBYTE; - s++; count++; - if (n < count+1) - goto none; - continue; - } - if (c == SI) { - state1 = STATE_ASCII; - s++; count++; - if (n < count+1) - goto none; - continue; - } - break; - } - switch (state1) { - case STATE_ASCII: - if (c < 0x80) { - int ret = ascii_mbtowc(conv,pwc,s,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - if (*pwc == 0x000a || *pwc == 0x000d) { - state2 = STATE2_NONE; state3 = STATE3_NONE; state4 = STATE3_NONE; - } - COMBINE_STATE; - conv->istate = state; - return count+1; - } else - goto ilseq; - case STATE_TWOBYTE: - if (n < count+2) - goto none; - if (s[0] < 0x80 && s[1] < 0x80) { - int ret; - switch (state2) { - case STATE2_NONE: - goto ilseq; - case STATE2_DESIGNATED_GB2312: - ret = gb2312_mbtowc(conv,pwc,s,2); break; - case STATE2_DESIGNATED_CNS11643_1: - ret = cns11643_1_mbtowc(conv,pwc,s,2); break; - case STATE2_DESIGNATED_ISO_IR_165: - ret = isoir165_mbtowc(conv,pwc,s,2); break; - default: abort(); - } - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+2; - } else - goto ilseq; - default: abort(); - } - -none: - COMBINE_STATE; - conv->istate = state; - return RET_TOOFEW(count); - -ilseq: - COMBINE_STATE; - conv->istate = state; - return RET_SHIFT_ILSEQ(count); -} - -static int -iso2022_cn_ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - state_t state = conv->ostate; - SPLIT_STATE; - unsigned char buf[3]; - int ret; - - /* There is no need to handle Unicode 3.1 tag characters and to look for - "zh-CN" or "zh-TW" tags, because GB2312 and CNS11643 are disjoint. */ - - /* Try ASCII. */ - ret = ascii_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] < 0x80) { - int count = (state1 == STATE_ASCII ? 1 : 2); - if (n < count) - return RET_TOOSMALL; - if (state1 != STATE_ASCII) { - r[0] = SI; - r += 1; - state1 = STATE_ASCII; - } - r[0] = buf[0]; - if (wc == 0x000a || wc == 0x000d) { - state2 = STATE2_NONE; state3 = STATE3_NONE; state4 = STATE3_NONE; - } - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - /* Try GB 2312-1980. */ - ret = gb2312_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state2 == STATE2_DESIGNATED_GB2312 ? 0 : 4) + (state1 == STATE_TWOBYTE ? 0 : 1) + 2; - if (n < count) - return RET_TOOSMALL; - if (state2 != STATE2_DESIGNATED_GB2312) { - r[0] = ESC; - r[1] = '$'; - r[2] = ')'; - r[3] = 'A'; - r += 4; - state2 = STATE2_DESIGNATED_GB2312; - } - if (state1 != STATE_TWOBYTE) { - r[0] = SO; - r += 1; - state1 = STATE_TWOBYTE; - } - r[0] = buf[0]; - r[1] = buf[1]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - ret = cns11643_wctomb(conv,buf,wc,3); - if (ret != RET_ILUNI) { - if (ret != 3) abort(); - - /* Try CNS 11643-1992 Plane 1. */ - if (buf[0] == 1 && buf[1] < 0x80 && buf[2] < 0x80) { - int count = (state2 == STATE2_DESIGNATED_CNS11643_1 ? 0 : 4) + (state1 == STATE_TWOBYTE ? 0 : 1) + 2; - if (n < count) - return RET_TOOSMALL; - if (state2 != STATE2_DESIGNATED_CNS11643_1) { - r[0] = ESC; - r[1] = '$'; - r[2] = ')'; - r[3] = 'G'; - r += 4; - state2 = STATE2_DESIGNATED_CNS11643_1; - } - if (state1 != STATE_TWOBYTE) { - r[0] = SO; - r += 1; - state1 = STATE_TWOBYTE; - } - r[0] = buf[1]; - r[1] = buf[2]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - - /* Try CNS 11643-1992 Plane 2. */ - if (buf[0] == 2 && buf[1] < 0x80 && buf[2] < 0x80) { - int count = (state3 == STATE3_DESIGNATED_CNS11643_2 ? 0 : 4) + 4; - if (n < count) - return RET_TOOSMALL; - if (state3 != STATE3_DESIGNATED_CNS11643_2) { - r[0] = ESC; - r[1] = '$'; - r[2] = '*'; - r[3] = 'H'; - r += 4; - state3 = STATE3_DESIGNATED_CNS11643_2; - } - r[0] = ESC; - r[1] = 'N'; - r[2] = buf[1]; - r[3] = buf[2]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - - /* Try CNS 11643-1992 Plane 3. */ - if (buf[0] == 3 && buf[1] < 0x80 && buf[2] < 0x80) { - int count = (state4 == STATE4_DESIGNATED_CNS11643_3 ? 0 : 4) + 4; - if (n < count) - return RET_TOOSMALL; - if (state4 != STATE4_DESIGNATED_CNS11643_3) { - r[0] = ESC; - r[1] = '$'; - r[2] = '+'; - r[3] = 'I'; - r += 4; - state4 = STATE4_DESIGNATED_CNS11643_3; - } - r[0] = ESC; - r[1] = 'O'; - r[2] = buf[1]; - r[3] = buf[2]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - - /* Try CNS 11643-1992 Plane 4. */ - if (buf[0] == 4 && buf[1] < 0x80 && buf[2] < 0x80) { - int count = (state4 == STATE4_DESIGNATED_CNS11643_4 ? 0 : 4) + 4; - if (n < count) - return RET_TOOSMALL; - if (state4 != STATE4_DESIGNATED_CNS11643_4) { - r[0] = ESC; - r[1] = '$'; - r[2] = '+'; - r[3] = 'J'; - r += 4; - state4 = STATE4_DESIGNATED_CNS11643_4; - } - r[0] = ESC; - r[1] = 'O'; - r[2] = buf[1]; - r[3] = buf[2]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - - /* Try CNS 11643-1992 Plane 5. */ - if (buf[0] == 5 && buf[1] < 0x80 && buf[2] < 0x80) { - int count = (state4 == STATE4_DESIGNATED_CNS11643_5 ? 0 : 4) + 4; - if (n < count) - return RET_TOOSMALL; - if (state4 != STATE4_DESIGNATED_CNS11643_5) { - r[0] = ESC; - r[1] = '$'; - r[2] = '+'; - r[3] = 'K'; - r += 4; - state4 = STATE4_DESIGNATED_CNS11643_5; - } - r[0] = ESC; - r[1] = 'O'; - r[2] = buf[1]; - r[3] = buf[2]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - - /* Try CNS 11643-1992 Plane 6. */ - if (buf[0] == 6 && buf[1] < 0x80 && buf[2] < 0x80) { - int count = (state4 == STATE4_DESIGNATED_CNS11643_6 ? 0 : 4) + 4; - if (n < count) - return RET_TOOSMALL; - if (state4 != STATE4_DESIGNATED_CNS11643_6) { - r[0] = ESC; - r[1] = '$'; - r[2] = '+'; - r[3] = 'L'; - r += 4; - state4 = STATE4_DESIGNATED_CNS11643_6; - } - r[0] = ESC; - r[1] = 'O'; - r[2] = buf[1]; - r[3] = buf[2]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - - /* Try CNS 11643-1992 Plane 7. */ - if (buf[0] == 7 && buf[1] < 0x80 && buf[2] < 0x80) { - int count = (state4 == STATE4_DESIGNATED_CNS11643_7 ? 0 : 4) + 4; - if (n < count) - return RET_TOOSMALL; - if (state4 != STATE4_DESIGNATED_CNS11643_7) { - r[0] = ESC; - r[1] = '$'; - r[2] = '+'; - r[3] = 'M'; - r += 4; - state4 = STATE4_DESIGNATED_CNS11643_7; - } - r[0] = ESC; - r[1] = 'O'; - r[2] = buf[1]; - r[3] = buf[2]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - - } - - /* Try ISO-IR-165. */ - ret = isoir165_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state2 == STATE2_DESIGNATED_ISO_IR_165 ? 0 : 4) + (state1 == STATE_TWOBYTE ? 0 : 1) + 2; - if (n < count) - return RET_TOOSMALL; - if (state2 != STATE2_DESIGNATED_ISO_IR_165) { - r[0] = ESC; - r[1] = '$'; - r[2] = ')'; - r[3] = 'E'; - r += 4; - state2 = STATE2_DESIGNATED_ISO_IR_165; - } - if (state1 != STATE_TWOBYTE) { - r[0] = SO; - r += 1; - state1 = STATE_TWOBYTE; - } - r[0] = buf[0]; - r[1] = buf[1]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - return RET_ILUNI; -} - -static int -iso2022_cn_ext_reset (conv_t conv, unsigned char *r, size_t n) -{ - state_t state = conv->ostate; - SPLIT_STATE; - (void)state2; - (void)state3; - (void)state4; - if (state1 != STATE_ASCII) { - if (n < 1) - return RET_TOOSMALL; - r[0] = SI; - /* conv->ostate = 0; will be done by the caller */ - return 1; - } else - return 0; -} - -#undef COMBINE_STATE -#undef SPLIT_STATE -#undef STATE4_DESIGNATED_CNS11643_7 -#undef STATE4_DESIGNATED_CNS11643_6 -#undef STATE4_DESIGNATED_CNS11643_5 -#undef STATE4_DESIGNATED_CNS11643_4 -#undef STATE4_DESIGNATED_CNS11643_3 -#undef STATE4_NONE -#undef STATE3_DESIGNATED_CNS11643_2 -#undef STATE3_NONE -#undef STATE2_DESIGNATED_ISO_IR_165 -#undef STATE2_DESIGNATED_CNS11643_1 -#undef STATE2_DESIGNATED_GB2312 -#undef STATE2_NONE -#undef STATE_TWOBYTE -#undef STATE_ASCII diff --git a/lib/iso2022_jp.h b/lib/iso2022_jp.h deleted file mode 100644 index c9924b87..00000000 --- a/lib/iso2022_jp.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * ISO-2022-JP - */ - -/* Specification: RFC 1468 */ - -#define ESC 0x1b - -/* - * The state can be one of the following values. - */ -#define STATE_ASCII 0 -#define STATE_JISX0201ROMAN 1 -#define STATE_JISX0208 2 - -static int -iso2022_jp_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - state_t state = conv->istate; - int count = 0; - unsigned char c; - for (;;) { - c = *s; - if (c == ESC) { - if (n < count+3) - goto none; - if (s[1] == '(') { - if (s[2] == 'B') { - state = STATE_ASCII; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - if (s[2] == 'J') { - state = STATE_JISX0201ROMAN; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - goto ilseq; - } - if (s[1] == '$') { - if (s[2] == '@' || s[2] == 'B') { - /* We don't distinguish JIS X 0208-1978 and JIS X 0208-1983. */ - state = STATE_JISX0208; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - goto ilseq; - } - goto ilseq; - } - break; - } - switch (state) { - case STATE_ASCII: - if (c < 0x80) { - int ret = ascii_mbtowc(conv,pwc,s,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - conv->istate = state; - return count+1; - } else - goto ilseq; - case STATE_JISX0201ROMAN: - if (c < 0x80) { - int ret = jisx0201_mbtowc(conv,pwc,s,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - conv->istate = state; - return count+1; - } else - goto ilseq; - case STATE_JISX0208: - if (n < count+2) - goto none; - if (s[0] < 0x80 && s[1] < 0x80) { - int ret = jisx0208_mbtowc(conv,pwc,s,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - conv->istate = state; - return count+2; - } else - goto ilseq; - default: abort(); - } - -none: - conv->istate = state; - return RET_TOOFEW(count); - -ilseq: - conv->istate = state; - return RET_SHIFT_ILSEQ(count); -} - -static int -iso2022_jp_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - state_t state = conv->ostate; - unsigned char buf[2]; - int ret; - - /* Try ASCII. */ - ret = ascii_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] < 0x80) { - int count = (state == STATE_ASCII ? 1 : 4); - if (n < count) - return RET_TOOSMALL; - if (state != STATE_ASCII) { - r[0] = ESC; - r[1] = '('; - r[2] = 'B'; - r += 3; - state = STATE_ASCII; - } - r[0] = buf[0]; - conv->ostate = state; - return count; - } - } - - /* Try JIS X 0201-1976 Roman. */ - ret = jisx0201_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] < 0x80) { - int count = (state == STATE_JISX0201ROMAN ? 1 : 4); - if (n < count) - return RET_TOOSMALL; - if (state != STATE_JISX0201ROMAN) { - r[0] = ESC; - r[1] = '('; - r[2] = 'J'; - r += 3; - state = STATE_JISX0201ROMAN; - } - r[0] = buf[0]; - conv->ostate = state; - return count; - } - } - - /* Try JIS X 0208-1990 in place of JIS X 0208-1978 and JIS X 0208-1983. */ - ret = jisx0208_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state == STATE_JISX0208 ? 2 : 5); - if (n < count) - return RET_TOOSMALL; - if (state != STATE_JISX0208) { - r[0] = ESC; - r[1] = '$'; - r[2] = 'B'; - r += 3; - state = STATE_JISX0208; - } - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = state; - return count; - } - } - - return RET_ILUNI; -} - -static int -iso2022_jp_reset (conv_t conv, unsigned char *r, size_t n) -{ - state_t state = conv->ostate; - if (state != STATE_ASCII) { - if (n < 3) - return RET_TOOSMALL; - r[0] = ESC; - r[1] = '('; - r[2] = 'B'; - /* conv->ostate = 0; will be done by the caller */ - return 3; - } else - return 0; -} - -#undef STATE_JISX0208 -#undef STATE_JISX0201ROMAN -#undef STATE_ASCII diff --git a/lib/iso2022_jp1.h b/lib/iso2022_jp1.h deleted file mode 100644 index a322882e..00000000 --- a/lib/iso2022_jp1.h +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * ISO-2022-JP-1 - */ - -/* Specification: RFC 2237 */ - -#define ESC 0x1b - -/* - * The state can be one of the following values. - */ -#define STATE_ASCII 0 -#define STATE_JISX0201ROMAN 1 -#define STATE_JISX0208 2 -#define STATE_JISX0212 3 - -static int -iso2022_jp1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - state_t state = conv->istate; - int count = 0; - unsigned char c; - for (;;) { - c = *s; - if (c == ESC) { - if (n < count+3) - goto none; - if (s[1] == '(') { - if (s[2] == 'B') { - state = STATE_ASCII; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - if (s[2] == 'J') { - state = STATE_JISX0201ROMAN; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - goto ilseq; - } - if (s[1] == '$') { - if (s[2] == '@' || s[2] == 'B') { - /* We don't distinguish JIS X 0208-1978 and JIS X 0208-1983. */ - state = STATE_JISX0208; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - if (s[2] == '(') { - if (n < count+4) - goto none; - if (s[3] == 'D') { - state = STATE_JISX0212; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - } - goto ilseq; - } - goto ilseq; - } - break; - } - switch (state) { - case STATE_ASCII: - if (c < 0x80) { - int ret = ascii_mbtowc(conv,pwc,s,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - conv->istate = state; - return count+1; - } else - goto ilseq; - case STATE_JISX0201ROMAN: - if (c < 0x80) { - int ret = jisx0201_mbtowc(conv,pwc,s,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - conv->istate = state; - return count+1; - } else - goto ilseq; - case STATE_JISX0208: - if (n < count+2) - goto none; - if (s[0] < 0x80 && s[1] < 0x80) { - int ret = jisx0208_mbtowc(conv,pwc,s,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - conv->istate = state; - return count+2; - } else - goto ilseq; - case STATE_JISX0212: - if (n < count+2) - goto none; - if (s[0] < 0x80 && s[1] < 0x80) { - int ret = jisx0212_mbtowc(conv,pwc,s,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - conv->istate = state; - return count+2; - } else - goto ilseq; - default: abort(); - } - -none: - conv->istate = state; - return RET_TOOFEW(count); - -ilseq: - conv->istate = state; - return RET_SHIFT_ILSEQ(count); -} - -static int -iso2022_jp1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - state_t state = conv->ostate; - unsigned char buf[2]; - int ret; - - /* Try ASCII. */ - ret = ascii_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] < 0x80) { - int count = (state == STATE_ASCII ? 1 : 4); - if (n < count) - return RET_TOOSMALL; - if (state != STATE_ASCII) { - r[0] = ESC; - r[1] = '('; - r[2] = 'B'; - r += 3; - state = STATE_ASCII; - } - r[0] = buf[0]; - conv->ostate = state; - return count; - } - } - - /* Try JIS X 0201-1976 Roman. */ - ret = jisx0201_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] < 0x80) { - int count = (state == STATE_JISX0201ROMAN ? 1 : 4); - if (n < count) - return RET_TOOSMALL; - if (state != STATE_JISX0201ROMAN) { - r[0] = ESC; - r[1] = '('; - r[2] = 'J'; - r += 3; - state = STATE_JISX0201ROMAN; - } - r[0] = buf[0]; - conv->ostate = state; - return count; - } - } - - /* Try JIS X 0208-1990 in place of JIS X 0208-1978 and JIS X 0208-1983. */ - ret = jisx0208_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state == STATE_JISX0208 ? 2 : 5); - if (n < count) - return RET_TOOSMALL; - if (state != STATE_JISX0208) { - r[0] = ESC; - r[1] = '$'; - r[2] = 'B'; - r += 3; - state = STATE_JISX0208; - } - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = state; - return count; - } - } - - /* Try JIS X 0212-1990. */ - ret = jisx0212_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state == STATE_JISX0212 ? 2 : 6); - if (n < count) - return RET_TOOSMALL; - if (state != STATE_JISX0212) { - r[0] = ESC; - r[1] = '$'; - r[2] = '('; - r[3] = 'D'; - r += 4; - state = STATE_JISX0212; - } - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = state; - return count; - } - } - - return RET_ILUNI; -} - -static int -iso2022_jp1_reset (conv_t conv, unsigned char *r, size_t n) -{ - state_t state = conv->ostate; - if (state != STATE_ASCII) { - if (n < 3) - return RET_TOOSMALL; - r[0] = ESC; - r[1] = '('; - r[2] = 'B'; - /* conv->ostate = 0; will be done by the caller */ - return 3; - } else - return 0; -} - -#undef STATE_JISX0212 -#undef STATE_JISX0208 -#undef STATE_JISX0201ROMAN -#undef STATE_ASCII diff --git a/lib/iso2022_jp2.h b/lib/iso2022_jp2.h deleted file mode 100644 index 6e374103..00000000 --- a/lib/iso2022_jp2.h +++ /dev/null @@ -1,692 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * ISO-2022-JP-2 - */ - -/* Specification: RFC 1554 */ -/* ESC '(' 'I' for JISX0201 Katakana is an extension not found in RFC 1554 or - CJK.INF, but implemented in glibc-2.1 and qt-2.0. */ - -#define ESC 0x1b - -/* - * The state is composed of one of the following values - */ -#define STATE_ASCII 0 -#define STATE_JISX0201ROMAN 1 -#define STATE_JISX0201KATAKANA 2 -#define STATE_JISX0208 3 -#define STATE_JISX0212 4 -#define STATE_GB2312 5 -#define STATE_KSC5601 6 -/* - * and one of the following values, << 8 - */ -#define STATE_G2_NONE 0 -#define STATE_G2_ISO8859_1 1 -#define STATE_G2_ISO8859_7 2 - -#define SPLIT_STATE \ - unsigned int state1 = state & 0xff, state2 = state >> 8 -#define COMBINE_STATE \ - state = (state2 << 8) | state1 - -static int -iso2022_jp2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - state_t state = conv->istate; - SPLIT_STATE; - int count = 0; - unsigned char c; - for (;;) { - c = *s; - if (c == ESC) { - if (n < count+3) - goto none; - if (s[1] == '(') { - if (s[2] == 'B') { - state1 = STATE_ASCII; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - if (s[2] == 'J') { - state1 = STATE_JISX0201ROMAN; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - if (s[2] == 'I') { - state1 = STATE_JISX0201KATAKANA; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - goto ilseq; - } - if (s[1] == '$') { - if (s[2] == '@' || s[2] == 'B') { - /* We don't distinguish JIS X 0208-1978 and JIS X 0208-1983. */ - state1 = STATE_JISX0208; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - if (s[2] == 'A') { - state1 = STATE_GB2312; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - if (s[2] == '(') { - if (n < count+4) - goto none; - if (s[3] == 'D') { - state1 = STATE_JISX0212; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - if (s[3] == 'C') { - state1 = STATE_KSC5601; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - goto ilseq; - } - goto ilseq; - } - if (s[1] == '.') { - if (n < count+3) - goto none; - if (s[2] == 'A') { - state2 = STATE_G2_ISO8859_1; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - if (s[2] == 'F') { - state2 = STATE_G2_ISO8859_7; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - goto ilseq; - } - if (s[1] == 'N') { - switch (state2) { - case STATE_G2_NONE: - goto ilseq; - case STATE_G2_ISO8859_1: - if (s[2] < 0x80) { - unsigned char buf = s[2]+0x80; - int ret = iso8859_1_mbtowc(conv,pwc,&buf,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - COMBINE_STATE; - conv->istate = state; - return count+3; - } else - goto ilseq; - case STATE_G2_ISO8859_7: - if (s[2] < 0x80) { - unsigned char buf = s[2]+0x80; - int ret = iso8859_7_mbtowc(conv,pwc,&buf,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - COMBINE_STATE; - conv->istate = state; - return count+3; - } else - goto ilseq; - default: abort(); - } - } - goto ilseq; - } - break; - } - switch (state1) { - case STATE_ASCII: - if (c < 0x80) { - int ret = ascii_mbtowc(conv,pwc,s,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - if (*pwc == 0x000a || *pwc == 0x000d) - state2 = STATE_G2_NONE; - COMBINE_STATE; - conv->istate = state; - return count+1; - } else - goto ilseq; - case STATE_JISX0201ROMAN: - if (c < 0x80) { - int ret = jisx0201_mbtowc(conv,pwc,s,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - if (*pwc == 0x000a || *pwc == 0x000d) - state2 = STATE_G2_NONE; - COMBINE_STATE; - conv->istate = state; - return count+1; - } else - goto ilseq; - case STATE_JISX0201KATAKANA: - if (c < 0x80) { - unsigned char buf = c+0x80; - int ret = jisx0201_mbtowc(conv,pwc,&buf,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - COMBINE_STATE; - conv->istate = state; - return count+1; - } else - goto ilseq; - case STATE_JISX0208: - if (n < count+2) - goto none; - if (s[0] < 0x80 && s[1] < 0x80) { - int ret = jisx0208_mbtowc(conv,pwc,s,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+2; - } else - goto ilseq; - case STATE_JISX0212: - if (n < count+2) - goto none; - if (s[0] < 0x80 && s[1] < 0x80) { - int ret = jisx0212_mbtowc(conv,pwc,s,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+2; - } else - goto ilseq; - case STATE_GB2312: - if (n < count+2) - goto none; - if (s[0] < 0x80 && s[1] < 0x80) { - int ret = gb2312_mbtowc(conv,pwc,s,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+2; - } else - goto ilseq; - case STATE_KSC5601: - if (n < count+2) - goto none; - if (s[0] < 0x80 && s[1] < 0x80) { - int ret = ksc5601_mbtowc(conv,pwc,s,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+2; - } else - goto ilseq; - default: abort(); - } - -none: - COMBINE_STATE; - conv->istate = state; - return RET_TOOFEW(count); - -ilseq: - COMBINE_STATE; - conv->istate = state; - return RET_SHIFT_ILSEQ(count); -} - -#undef COMBINE_STATE -#undef SPLIT_STATE - -/* - * The state can also contain one of the following values, << 16. - * Values >= STATE_TAG_LANGUAGE are temporary tag parsing states. - */ -#define STATE_TAG_NONE 0 -#define STATE_TAG_LANGUAGE 4 -#define STATE_TAG_LANGUAGE_j 5 -#define STATE_TAG_LANGUAGE_ja 1 -#define STATE_TAG_LANGUAGE_k 6 -#define STATE_TAG_LANGUAGE_ko 2 -#define STATE_TAG_LANGUAGE_z 7 -#define STATE_TAG_LANGUAGE_zh 3 - -#define SPLIT_STATE \ - unsigned int state1 = state & 0xff, state2 = (state >> 8) & 0xff, state3 = state >> 16 -#define COMBINE_STATE \ - state = (state3 << 16) | (state2 << 8) | state1 - -static int -iso2022_jp2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - state_t state = conv->ostate; - SPLIT_STATE; - unsigned char buf[2]; - int ret; - /* This defines the conversion preferences depending on the current - langauge tag. */ - enum conversion { none = 0, european, japanese, chinese, korean, other }; - static const unsigned int conversion_lists[STATE_TAG_LANGUAGE] = { - /* STATE_TAG_NONE */ - japanese + (european << 3) + (chinese << 6) + (korean << 9) + (other << 12), - /* STATE_TAG_LANGUAGE_ja */ - japanese + (european << 3) + (chinese << 6) + (korean << 9) + (other << 12), - /* STATE_TAG_LANGUAGE_ko */ - korean + (european << 3) + (japanese << 6) + (chinese << 9) + (other << 12), - /* STATE_TAG_LANGUAGE_zh */ - chinese + (european << 3) + (japanese << 6) + (korean << 9) + (other << 12) - }; - unsigned int conversion_list; - - /* Handle Unicode tag characters (range U+E0000..U+E007F). */ - if ((wc >> 7) == (0xe0000 >> 7)) { - char c = wc & 0x7f; - if (c >= 'A' && c <= 'Z') - c += 'a'-'A'; - switch (c) { - case 0x01: - state3 = STATE_TAG_LANGUAGE; - COMBINE_STATE; - conv->ostate = state; - return 0; - case 'j': - if (state3 == STATE_TAG_LANGUAGE) { - state3 = STATE_TAG_LANGUAGE_j; - COMBINE_STATE; - conv->ostate = state; - return 0; - } - break; - case 'a': - if (state3 == STATE_TAG_LANGUAGE_j) { - state3 = STATE_TAG_LANGUAGE_ja; - COMBINE_STATE; - conv->ostate = state; - return 0; - } - break; - case 'k': - if (state3 == STATE_TAG_LANGUAGE) { - state3 = STATE_TAG_LANGUAGE_k; - COMBINE_STATE; - conv->ostate = state; - return 0; - } - break; - case 'o': - if (state3 == STATE_TAG_LANGUAGE_k) { - state3 = STATE_TAG_LANGUAGE_ko; - COMBINE_STATE; - conv->ostate = state; - return 0; - } - break; - case 'z': - if (state3 == STATE_TAG_LANGUAGE) { - state3 = STATE_TAG_LANGUAGE_z; - COMBINE_STATE; - conv->ostate = state; - return 0; - } - break; - case 'h': - if (state3 == STATE_TAG_LANGUAGE_z) { - state3 = STATE_TAG_LANGUAGE_zh; - COMBINE_STATE; - conv->ostate = state; - return 0; - } - break; - case 0x7f: - state3 = STATE_TAG_NONE; - COMBINE_STATE; - conv->ostate = state; - return 0; - default: - break; - } - /* Other tag characters reset the tag parsing state or are ignored. */ - if (state3 >= STATE_TAG_LANGUAGE) - state3 = STATE_TAG_NONE; - COMBINE_STATE; - conv->ostate = state; - return 0; - } - if (state3 >= STATE_TAG_LANGUAGE) - state3 = STATE_TAG_NONE; - - /* Try ASCII. */ - ret = ascii_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] < 0x80) { - int count = (state1 == STATE_ASCII ? 1 : 4); - if (n < count) - return RET_TOOSMALL; - if (state1 != STATE_ASCII) { - r[0] = ESC; - r[1] = '('; - r[2] = 'B'; - r += 3; - state1 = STATE_ASCII; - } - r[0] = buf[0]; - if (wc == 0x000a || wc == 0x000d) - state2 = STATE_G2_NONE; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - conversion_list = conversion_lists[state3]; - - do { - switch (conversion_list & ((1 << 3) - 1)) { - - case european: - - /* Try ISO-8859-1. */ - ret = iso8859_1_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] >= 0x80) { - int count = (state2 == STATE_G2_ISO8859_1 ? 3 : 6); - if (n < count) - return RET_TOOSMALL; - if (state2 != STATE_G2_ISO8859_1) { - r[0] = ESC; - r[1] = '.'; - r[2] = 'A'; - r += 3; - state2 = STATE_G2_ISO8859_1; - } - r[0] = ESC; - r[1] = 'N'; - r[2] = buf[0]-0x80; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - /* Try ISO-8859-7. */ - ret = iso8859_7_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] >= 0x80) { - int count = (state2 == STATE_G2_ISO8859_7 ? 3 : 6); - if (n < count) - return RET_TOOSMALL; - if (state2 != STATE_G2_ISO8859_7) { - r[0] = ESC; - r[1] = '.'; - r[2] = 'F'; - r += 3; - state2 = STATE_G2_ISO8859_7; - } - r[0] = ESC; - r[1] = 'N'; - r[2] = buf[0]-0x80; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - break; - - case japanese: - - /* Try JIS X 0201-1976 Roman. */ - ret = jisx0201_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] < 0x80) { - int count = (state1 == STATE_JISX0201ROMAN ? 1 : 4); - if (n < count) - return RET_TOOSMALL; - if (state1 != STATE_JISX0201ROMAN) { - r[0] = ESC; - r[1] = '('; - r[2] = 'J'; - r += 3; - state1 = STATE_JISX0201ROMAN; - } - r[0] = buf[0]; - if (wc == 0x000a || wc == 0x000d) - state2 = STATE_G2_NONE; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - /* Try JIS X 0208-1990 in place of JIS X 0208-1978 and - JIS X 0208-1983. */ - ret = jisx0208_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state1 == STATE_JISX0208 ? 2 : 5); - if (n < count) - return RET_TOOSMALL; - if (state1 != STATE_JISX0208) { - r[0] = ESC; - r[1] = '$'; - r[2] = 'B'; - r += 3; - state1 = STATE_JISX0208; - } - r[0] = buf[0]; - r[1] = buf[1]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - /* Try JIS X 0212-1990. */ - ret = jisx0212_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state1 == STATE_JISX0212 ? 2 : 6); - if (n < count) - return RET_TOOSMALL; - if (state1 != STATE_JISX0212) { - r[0] = ESC; - r[1] = '$'; - r[2] = '('; - r[3] = 'D'; - r += 4; - state1 = STATE_JISX0212; - } - r[0] = buf[0]; - r[1] = buf[1]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - break; - - case chinese: - - /* Try GB 2312-1980. */ - ret = gb2312_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state1 == STATE_GB2312 ? 2 : 5); - if (n < count) - return RET_TOOSMALL; - if (state1 != STATE_GB2312) { - r[0] = ESC; - r[1] = '$'; - r[2] = 'A'; - r += 3; - state1 = STATE_GB2312; - } - r[0] = buf[0]; - r[1] = buf[1]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - break; - - case korean: - - /* Try KS C 5601-1992. */ - ret = ksc5601_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state1 == STATE_KSC5601 ? 2 : 6); - if (n < count) - return RET_TOOSMALL; - if (state1 != STATE_KSC5601) { - r[0] = ESC; - r[1] = '$'; - r[2] = '('; - r[3] = 'C'; - r += 4; - state1 = STATE_KSC5601; - } - r[0] = buf[0]; - r[1] = buf[1]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - break; - - case other: - - /* Try JIS X 0201-1976 Kana. This is not officially part of - ISO-2022-JP-2, according to RFC 1554. Therefore we try this - only after all other attempts. */ - ret = jisx0201_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] >= 0x80) { - int count = (state1 == STATE_JISX0201KATAKANA ? 1 : 4); - if (n < count) - return RET_TOOSMALL; - if (state1 != STATE_JISX0201KATAKANA) { - r[0] = ESC; - r[1] = '('; - r[2] = 'I'; - r += 3; - state1 = STATE_JISX0201KATAKANA; - } - r[0] = buf[0]-0x80; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - break; - - default: - abort(); - } - - conversion_list = conversion_list >> 3; - } while (conversion_list != 0); - - return RET_ILUNI; -} - -static int -iso2022_jp2_reset (conv_t conv, unsigned char *r, size_t n) -{ - state_t state = conv->ostate; - SPLIT_STATE; - (void)state2; - (void)state3; - if (state1 != STATE_ASCII) { - if (n < 3) - return RET_TOOSMALL; - r[0] = ESC; - r[1] = '('; - r[2] = 'B'; - /* conv->ostate = 0; will be done by the caller */ - return 3; - } else - return 0; -} - -#undef COMBINE_STATE -#undef SPLIT_STATE -#undef STATE_TAG_LANGUAGE_zh -#undef STATE_TAG_LANGUAGE_z -#undef STATE_TAG_LANGUAGE_ko -#undef STATE_TAG_LANGUAGE_k -#undef STATE_TAG_LANGUAGE_ja -#undef STATE_TAG_LANGUAGE_j -#undef STATE_TAG_LANGUAGE -#undef STATE_TAG_NONE -#undef STATE_G2_ISO8859_7 -#undef STATE_G2_ISO8859_1 -#undef STATE_G2_NONE -#undef STATE_KSC5601 -#undef STATE_GB2312 -#undef STATE_JISX0212 -#undef STATE_JISX0208 -#undef STATE_JISX0201KATAKANA -#undef STATE_JISX0201ROMAN -#undef STATE_ASCII diff --git a/lib/iso2022_jpms.h b/lib/iso2022_jpms.h deleted file mode 100644 index 62347be2..00000000 --- a/lib/iso2022_jpms.h +++ /dev/null @@ -1,445 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2011-2012, 2016, 2018 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * ISO-2022-JP-MS - * alias CP50221 - * - * This is an extension of ISO-2022-JP-1 with larger character sets. - * It uses ESC $ B and ESC $ ( D to denote *extensions* of JIS X 0208 and - * JIS X 0212, respectively. This violates the principles of ISO 2022, - * where - * 1. character sets to be used by ISO 2022 have to be registered at the - * ISO IR registry , - * 2. different character sets are designated by different escape - * sequences. - * It's a typical instance of the "embrace and extend" strategy by Microsoft - * . - */ - -/* - * Windows has three encodings CP50220, CP50221, CP50222. - * The common parts are: - * - US-ASCII (0x00..0x7F) - * - JIS X 0208 extended by - * - one row (0x2D), - * - a private use area (rows 0x75..0x7E = U+E000..U+E3AB), - * enabled with ESC $ B, disabled with ESC ( B. - * - JIS X 0212 extended by - * - two rows (0x73..0x74), - * - a private use area (rows 0x75..0x7E = U+E3AC..U+E757), - * enabled with ESC $ ( D, disabled with ESC ( B. - * They differ in the handling of JIS X 0201 characters (halfwidth Katakana) - * in the conversion direction Unicode -> CP5022x: - * * CP50220 maps the halfwidth Katakana to fullwidth Katakana characters. - * * CP50221 contains the JIS X 0201 halfwidth Katakana characters, - * enabled with ESC ( I, disabled with ESC ( B. - * * CP50222 contains the JIS X 0201 halfwidth Katakana characters, - * enabled with ESC ( J 0x0E, disabled with ESC ( B. - * In the conversion direction CP5022x -> Unicode, all three operate the same: - * - ESC ( I is supported and understood. - * - ESC ( J 0x0E is not accepted. (Tested on Windows XP SP3.) - * Conclusion: - * - CP50222 should not be used, because the multibyte sequence that it - * produces cannot be parsed by either of the three encodings. - * - CP50221 is preferrable to CP50220, because it can faithfully represent - * the halfwidth Katakana characters. - * We therefore implement CP50221. As an extension, in the mbtowc conversion - * direction, we support also ESC ( J 0x0E, just in case. - */ - -#include "cp50221_0208_ext.h" -#include "cp50221_0212_ext.h" - -#define ESC 0x1b -#define SO 0x0e -#define SI 0x0f - -/* - * The state can be one of the following values. - */ -#define STATE_ASCII 0 /* Esc ( B */ -#define STATE_JISX0201ROMAN 1 /* Esc ( J */ /* only in mbtowc direction */ -#define STATE_JISX0201KATAKANA 2 /* Esc ( I */ -#define STATE_JISX0208MS 3 /* Esc $ @ or Esc $ B */ -#define STATE_JISX0212MS 4 /* Esc $ ( D */ - -static int -iso2022_jpms_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - state_t state = conv->istate; - int count = 0; - unsigned char c; - for (;;) { - c = *s; - if (c == ESC) { - if (n < count+3) - goto none; - if (s[1] == '(') { - if (s[2] == 'B') { - state = STATE_ASCII; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - if (s[2] == 'I') { - state = STATE_JISX0201KATAKANA; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - if (s[2] == 'J') { - state = STATE_JISX0201ROMAN; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - goto ilseq; - } - if (s[1] == '$') { - if (s[2] == '@' || s[2] == 'B') { - /* We don't distinguish JIS X 0208-1978 and JIS X 0208-1983. */ - state = STATE_JISX0208MS; - s += 3; count += 3; - if (n < count+1) - goto none; - continue; - } - if (s[2] == '(') { - if (n < count+4) - goto none; - if (s[3] == 'D') { - state = STATE_JISX0212MS; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - } - goto ilseq; - } - goto ilseq; - } - if (c == SO) { - if (state == STATE_JISX0201ROMAN) - state = STATE_JISX0201KATAKANA; - s += 1; count += 1; - if (n < count+1) - goto none; - continue; - } - if (c == SI) { - if (state == STATE_JISX0201KATAKANA) - state = STATE_JISX0201ROMAN; - s += 1; count += 1; - if (n < count+1) - goto none; - continue; - } - break; - } - switch (state) { - case STATE_ASCII: - if (c < 0x80) { - int ret = ascii_mbtowc(conv,pwc,s,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - conv->istate = state; - return count+1; - } else - goto ilseq; - case STATE_JISX0201ROMAN: - if (c < 0x80) { - int ret = jisx0201_mbtowc(conv,pwc,s,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - conv->istate = state; - return count+1; - } else - goto ilseq; - case STATE_JISX0201KATAKANA: - if (c < 0x80) { - unsigned char buf = c+0x80; - int ret = jisx0201_mbtowc(conv,pwc,&buf,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); - conv->istate = state; - return count+1; - } else - goto ilseq; - case STATE_JISX0208MS: - if (n < count+2) - goto none; - if (s[0] < 0x80 && s[1] < 0x80) { - int ret; - if (s[0] < 0x75) { - if (s[0] == 0x2d) { - /* Extension of JIS X 0208. */ - if (s[1] >= 0x21 && s[1] <= 0x79) { - unsigned char i = (s[1] - 0x21) + 1; - ret = cp50221_0208_ext_mbtowc(conv,pwc,&i,1); - if (ret == 1) - ret = 2; - } else - ret = RET_ILSEQ; - } else { - /* JIS X 0208. */ - ret = jisx0208_mbtowc(conv,pwc,s,2); - } - } else { - /* Extension of JIS X 0208. - 0x{75..7E}{21..8E} maps to U+E000..U+E3AB. - But some rows maps to characters present in CP932. */ - if (s[0] <= 0x7e && (s[1] >= 0x21 && s[1] <= 0x7e)) { - unsigned short wc = 0xfffd; - if (s[0] >= 0x79 && s[0] <= 0x7c) - wc = cp932ext_2uni_pageed[(s[0] - 0x79) * 94 + (s[1] - 0x21)]; - if (wc == 0xfffd) - wc = (s[0] - 0x75) * 94 + (s[1] - 0x21) + 0xe000; - *pwc = wc; - ret = 2; - } else - ret = RET_ILSEQ; - } - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - conv->istate = state; - return count+2; - } else - goto ilseq; - case STATE_JISX0212MS: - if (n < count+2) - goto none; - if (s[0] < 0x80 && s[1] < 0x80) { - int ret; - if (s[0] < 0x73) { - /* JIS X 0212. */ - ret = jisx0212_mbtowc(conv,pwc,s,2); - } else { - if (s[0] < 0x75) { - /* Extension of JIS X 0212. */ - if (s[1] >= 0x21 && s[1] <= 0x7e) { - unsigned char i = (s[0] - 0x73) * 94 + (s[1] - 0x21) + 1; - ret = cp50221_0212_ext_mbtowc(conv,pwc,&i,1); - if (ret == 1) - ret = 2; - } else - ret = RET_ILSEQ; - } else { - /* Extension of JIS X 0208. - 0x{75..7E}{21..8E} maps to U+E3AC..U+E757. */ - if (s[0] <= 0x7e && (s[1] >= 0x21 && s[1] <= 0x7e)) { - *pwc = (s[0] - 0x75) * 94 + (s[1] - 0x21) + 0xe3ac; - ret = 2; - } else - ret = RET_ILSEQ; - } - } - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - conv->istate = state; - return count+2; - } else - goto ilseq; - default: abort(); - } - -none: - conv->istate = state; - return RET_TOOFEW(count); - -ilseq: - conv->istate = state; - return RET_SHIFT_ILSEQ(count); -} - -static int -iso2022_jpms_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - state_t state = conv->ostate; - unsigned char buf[2]; - int ret; - - /* Try ASCII. */ - ret = ascii_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] < 0x80) { - int count = (state == STATE_ASCII ? 1 : 4); - if (n < count) - return RET_TOOSMALL; - if (state != STATE_ASCII) { - r[0] = ESC; - r[1] = '('; - r[2] = 'B'; - r += 3; - state = STATE_ASCII; - } - r[0] = buf[0]; - conv->ostate = state; - return count; - } - } - - /* Try JIS X 0201-1976 Katakana. */ - ret = jisx0201_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] >= 0x80) { - int count = (state == STATE_JISX0201KATAKANA ? 1 : 4); - if (n < count) - return RET_TOOSMALL; - if (state != STATE_JISX0201KATAKANA) { - r[0] = ESC; - r[1] = '('; - r[2] = 'I'; - r += 3; - state = STATE_JISX0201KATAKANA; - } - r[0] = buf[0]-0x80; - conv->ostate = state; - return count; - } - } - - /* Try JIS X 0208-1990, in place of JIS X 0208-1978 and JIS X 0208-1983, - and the extensions mentioned above. */ - if (wc >= 0xe000 && wc < 0xe3ac) { - unsigned short i = wc - 0xe000; - buf[0] = (i / 94) + 0x75; - buf[1] = (i % 94) + 0x21; - ret = 2; - } else { - ret = jisx0208_wctomb(conv,buf,wc,2); - if (ret == RET_ILUNI) { - /* Extension of JIS X 0208. */ - unsigned char i; - ret = cp50221_0208_ext_wctomb(conv,&i,wc,1); - if (ret == 1) { - buf[0] = 0x2d; - buf[1] = i-1 + 0x21; - ret = 2; - } else if (wc == 0x663B) { - buf[0] = 0x7a; - buf[1] = 0x36; - ret = 2; - } else if (wc == 0xffe2) { - buf[0] = 0x7c; - buf[1] = 0x7b; - ret = 2; - } else if (wc == 0xffe4) { - buf[0] = 0x7c; - buf[1] = 0x7c; - ret = 2; - } - } - } - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state == STATE_JISX0208MS ? 2 : 5); - if (n < count) - return RET_TOOSMALL; - if (state != STATE_JISX0208MS) { - r[0] = ESC; - r[1] = '$'; - r[2] = 'B'; - r += 3; - state = STATE_JISX0208MS; - } - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = state; - return count; - } - } - - /* Try JIS X 0212-1990 and the extensions mentioned above. */ - if (wc >= 0xe3ac && wc < 0xe758) { - unsigned short i = wc - 0xe3ac; - buf[0] = (i / 94) + 0x75; - buf[1] = (i % 94) + 0x21; - ret = 2; - } else { - ret = jisx0212_wctomb(conv,buf,wc,2); - if (ret == RET_ILUNI) { - /* Extension of JIS X 0212. */ - unsigned char i; - ret = cp50221_0212_ext_wctomb(conv,&i,wc,1); - if (ret == 1) { - i -= 1; - buf[0] = (i / 94) + 0x73; - buf[1] = (i % 94) + 0x21; - ret = 2; - } - } - } - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state == STATE_JISX0212MS ? 2 : 6); - if (n < count) - return RET_TOOSMALL; - if (state != STATE_JISX0212MS) { - r[0] = ESC; - r[1] = '$'; - r[2] = '('; - r[3] = 'D'; - r += 4; - state = STATE_JISX0212MS; - } - r[0] = buf[0]; - r[1] = buf[1]; - conv->ostate = state; - return count; - } - } - - return RET_ILUNI; -} - -static int -iso2022_jpms_reset (conv_t conv, unsigned char *r, size_t n) -{ - state_t state = conv->ostate; - if (state != STATE_ASCII) { - if (n < 3) - return RET_TOOSMALL; - r[0] = ESC; - r[1] = '('; - r[2] = 'B'; - /* conv->ostate = 0; will be done by the caller */ - return 3; - } else - return 0; -} - -#undef STATE_JISX0212MS -#undef STATE_JISX0208MS -#undef STATE_JISX0201KATAKANA -#undef STATE_JISX0201ROMAN -#undef STATE_ASCII diff --git a/lib/iso2022_kr.h b/lib/iso2022_kr.h deleted file mode 100644 index d44f2216..00000000 --- a/lib/iso2022_kr.h +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * ISO-2022-KR - */ - -/* Specification: RFC 1557 */ - -/* Note: CJK.INF says the SO designator needs to appear only once at the - beginning of a text, but to decrease the risk of ambiguities, when - producing ISO-2022-KR, we repeat the designator in every line containing - SO characters. RFC 1557 does not mandate this. */ - -#define ESC 0x1b -#define SO 0x0e -#define SI 0x0f - -/* - * The state is composed of one of the following values - */ -#define STATE_ASCII 0 -#define STATE_TWOBYTE 1 -/* - * and one of the following values, << 8 - */ -#define STATE2_NONE 0 -#define STATE2_DESIGNATED_KSC5601 1 - -#define SPLIT_STATE \ - unsigned int state1 = state & 0xff, state2 = state >> 8 -#define COMBINE_STATE \ - state = (state2 << 8) | state1 - -static int -iso2022_kr_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - state_t state = conv->istate; - SPLIT_STATE; - int count = 0; - unsigned char c; - for (;;) { - c = *s; - if (c == ESC) { - if (n < count+4) - goto none; - if (s[1] == '$') { - if (s[2] == ')') { - if (s[3] == 'C') { - state2 = STATE2_DESIGNATED_KSC5601; - s += 4; count += 4; - if (n < count+1) - goto none; - continue; - } - } - } - goto ilseq; - } - if (c == SO) { - if (state2 != STATE2_DESIGNATED_KSC5601) - goto ilseq; - state1 = STATE_TWOBYTE; - s++; count++; - if (n < count+1) - goto none; - continue; - } - if (c == SI) { - state1 = STATE_ASCII; - s++; count++; - if (n < count+1) - goto none; - continue; - } - break; - } - switch (state1) { - case STATE_ASCII: - if (c < 0x80) { - int ret = ascii_mbtowc(conv,pwc,s,1); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 1) abort(); -#if 0 /* Accept ISO-2022-KR according to CJK.INF. */ - if (*pwc == 0x000a || *pwc == 0x000d) - state2 = STATE2_NONE; -#endif - COMBINE_STATE; - conv->istate = state; - return count+1; - } else - goto ilseq; - case STATE_TWOBYTE: - if (n < count+2) - goto none; - if (state2 != STATE2_DESIGNATED_KSC5601) abort(); - if (s[0] < 0x80 && s[1] < 0x80) { - int ret = ksc5601_mbtowc(conv,pwc,s,2); - if (ret == RET_ILSEQ) - goto ilseq; - if (ret != 2) abort(); - COMBINE_STATE; - conv->istate = state; - return count+2; - } else - goto ilseq; - default: abort(); - } - -none: - COMBINE_STATE; - conv->istate = state; - return RET_TOOFEW(count); - -ilseq: - COMBINE_STATE; - conv->istate = state; - return RET_SHIFT_ILSEQ(count); -} - -static int -iso2022_kr_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - state_t state = conv->ostate; - SPLIT_STATE; - unsigned char buf[2]; - int ret; - - /* Try ASCII. */ - ret = ascii_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - if (ret != 1) abort(); - if (buf[0] < 0x80) { - int count = (state1 == STATE_ASCII ? 1 : 2); - if (n < count) - return RET_TOOSMALL; - if (state1 != STATE_ASCII) { - r[0] = SI; - r += 1; - state1 = STATE_ASCII; - } - r[0] = buf[0]; - if (wc == 0x000a || wc == 0x000d) - state2 = STATE2_NONE; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - /* Try KS C 5601-1992. */ - ret = ksc5601_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (buf[0] < 0x80 && buf[1] < 0x80) { - int count = (state2 == STATE2_DESIGNATED_KSC5601 ? 0 : 4) + (state1 == STATE_TWOBYTE ? 0 : 1) + 2; - if (n < count) - return RET_TOOSMALL; - if (state2 != STATE2_DESIGNATED_KSC5601) { - r[0] = ESC; - r[1] = '$'; - r[2] = ')'; - r[3] = 'C'; - r += 4; - state2 = STATE2_DESIGNATED_KSC5601; - } - if (state1 != STATE_TWOBYTE) { - r[0] = SO; - r += 1; - state1 = STATE_TWOBYTE; - } - r[0] = buf[0]; - r[1] = buf[1]; - COMBINE_STATE; - conv->ostate = state; - return count; - } - } - - return RET_ILUNI; -} - -static int -iso2022_kr_reset (conv_t conv, unsigned char *r, size_t n) -{ - state_t state = conv->ostate; - SPLIT_STATE; - (void)state2; - if (state1 != STATE_ASCII) { - if (n < 1) - return RET_TOOSMALL; - r[0] = SI; - /* conv->ostate = 0; will be done by the caller */ - return 1; - } else - return 0; -} - -#undef COMBINE_STATE -#undef SPLIT_STATE -#undef STATE2_DESIGNATED_KSC5601 -#undef STATE2_NONE -#undef STATE_TWOBYTE -#undef STATE_ASCII diff --git a/lib/iso646_cn.h b/lib/iso646_cn.h deleted file mode 100644 index 9a2f6e7d..00000000 --- a/lib/iso646_cn.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * ISO646-CN - * also known as GB_1988-80 - */ - -static int -iso646_cn_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - if (c < 0x80) { - if (c == 0x24) - *pwc = (ucs4_t) 0x00a5; - else if (c == 0x7e) - *pwc = (ucs4_t) 0x203e; - else - *pwc = (ucs4_t) c; - return 1; - } - return RET_ILSEQ; -} - -static int -iso646_cn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc < 0x0080 && !(wc == 0x0024 || wc == 0x007e)) { - *r = wc; - return 1; - } - if (wc == 0x00a5) { - *r = 0x24; - return 1; - } - if (wc == 0x203e) { - *r = 0x7e; - return 1; - } - return RET_ILUNI; -} diff --git a/lib/iso646_jp.h b/lib/iso646_jp.h deleted file mode 100644 index f5e0581b..00000000 --- a/lib/iso646_jp.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * ISO646-JP - * also known as JIS_C6220-1969-RO - */ - -/* This is the lower half of JIS_X0201. */ - -static int -iso646_jp_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - if (c < 0x80) { - if (c == 0x5c) - *pwc = (ucs4_t) 0x00a5; - else if (c == 0x7e) - *pwc = (ucs4_t) 0x203e; - else - *pwc = (ucs4_t) c; - return 1; - } - return RET_ILSEQ; -} - -static int -iso646_jp_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc < 0x0080 && !(wc == 0x005c || wc == 0x007e)) { - *r = wc; - return 1; - } - if (wc == 0x00a5) { - *r = 0x5c; - return 1; - } - if (wc == 0x203e) { - *r = 0x7e; - return 1; - } - return RET_ILUNI; -} diff --git a/lib/iso8859_11.h b/lib/iso8859_11.h deleted file mode 100644 index 22eaf289..00000000 --- a/lib/iso8859_11.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 1999-2004, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * ISO-8859-11 - */ - -static int -iso8859_11_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - if (c < 0xa1) { - *pwc = (ucs4_t) c; - return 1; - } - else if (c <= 0xfb && !(c >= 0xdb && c <= 0xde)) { - *pwc = (ucs4_t) (c + 0x0d60); - return 1; - } - return RET_ILSEQ; -} - -static int -iso8859_11_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc < 0x00a1) { - *r = wc; - return 1; - } - else if (wc >= 0x0e01 && wc <= 0x0e5b && !(wc >= 0x0e3b && wc <= 0x0e3e)) { - *r = wc-0x0d60; - return 1; - } - return RET_ILUNI; -} diff --git a/lib/java.h b/lib/java.h deleted file mode 100644 index 1f0ef85a..00000000 --- a/lib/java.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * JAVA - * This is ISO 8859-1 with \uXXXX escape sequences, denoting Unicode BMP - * characters. Consecutive pairs of \uXXXX escape sequences in the surrogate - * range, as in UTF-16, denote Unicode characters outside the BMP. - */ - -static int -java_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c; - ucs4_t wc, wc2; - int i; - - c = s[0]; - if (c != '\\') { - *pwc = c; - return 1; - } - if (n < 2) - return RET_TOOFEW(0); - if (s[1] != 'u') - goto simply_backslash; - wc = 0; - for (i = 2; i < 6; i++) { - if (n <= i) - return RET_TOOFEW(0); - c = s[i]; - if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'Z') - c -= 'A'-10; - else if (c >= 'a' && c <= 'z') - c -= 'a'-10; - else - goto simply_backslash; - wc |= (ucs4_t) c << (4 * (5-i)); - } - if (!(wc >= 0xd800 && wc < 0xe000)) { - *pwc = wc; - return 6; - } - if (wc >= 0xdc00) - goto simply_backslash; - if (n < 7) - return RET_TOOFEW(0); - if (s[6] != '\\') - goto simply_backslash; - if (n < 8) - return RET_TOOFEW(0); - if (s[7] != 'u') - goto simply_backslash; - wc2 = 0; - for (i = 8; i < 12; i++) { - if (n <= i) - return RET_TOOFEW(0); - c = s[i]; - if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'Z') - c -= 'A'-10; - else if (c >= 'a' && c <= 'z') - c -= 'a'-10; - else - goto simply_backslash; - wc2 |= (ucs4_t) c << (4 * (11-i)); - } - if (!(wc2 >= 0xdc00 && wc2 < 0xe000)) - goto simply_backslash; - *pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00); - return 12; -simply_backslash: - *pwc = '\\'; - return 1; -} - -static int -java_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc < 0x80) { - *r = wc; - return 1; - } else if (wc < 0x10000) { - if (n >= 6) { - unsigned int i; - r[0] = '\\'; - r[1] = 'u'; - i = (wc >> 12) & 0x0f; r[2] = (i < 10 ? '0'+i : 'a'-10+i); - i = (wc >> 8) & 0x0f; r[3] = (i < 10 ? '0'+i : 'a'-10+i); - i = (wc >> 4) & 0x0f; r[4] = (i < 10 ? '0'+i : 'a'-10+i); - i = wc & 0x0f; r[5] = (i < 10 ? '0'+i : 'a'-10+i); - return 6; - } else - return RET_TOOSMALL; - } else if (wc < 0x110000) { - if (n >= 12) { - ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10); - ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff); - unsigned int i; - r[0] = '\\'; - r[1] = 'u'; - i = (wc1 >> 12) & 0x0f; r[2] = (i < 10 ? '0'+i : 'a'-10+i); - i = (wc1 >> 8) & 0x0f; r[3] = (i < 10 ? '0'+i : 'a'-10+i); - i = (wc1 >> 4) & 0x0f; r[4] = (i < 10 ? '0'+i : 'a'-10+i); - i = wc1 & 0x0f; r[5] = (i < 10 ? '0'+i : 'a'-10+i); - r[6] = '\\'; - r[7] = 'u'; - i = (wc2 >> 12) & 0x0f; r[8] = (i < 10 ? '0'+i : 'a'-10+i); - i = (wc2 >> 8) & 0x0f; r[9] = (i < 10 ? '0'+i : 'a'-10+i); - i = (wc2 >> 4) & 0x0f; r[10] = (i < 10 ? '0'+i : 'a'-10+i); - i = wc2 & 0x0f; r[11] = (i < 10 ? '0'+i : 'a'-10+i); - return 12; - } else - return RET_TOOSMALL; - } - return RET_ILUNI; -} diff --git a/lib/jisx0201.h b/lib/jisx0201.h deleted file mode 100644 index 11d1e6a5..00000000 --- a/lib/jisx0201.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * JISX0201.1976-0 - */ - -static int -jisx0201_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - if (c < 0x80) { - if (c == 0x5c) - *pwc = (ucs4_t) 0x00a5; - else if (c == 0x7e) - *pwc = (ucs4_t) 0x203e; - else - *pwc = (ucs4_t) c; - return 1; - } else { - if (c >= 0xa1 && c < 0xe0) { - *pwc = (ucs4_t) c + 0xfec0; - return 1; - } - } - return RET_ILSEQ; -} - -static int -jisx0201_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc < 0x0080 && !(wc == 0x005c || wc == 0x007e)) { - *r = wc; - return 1; - } - if (wc == 0x00a5) { - *r = 0x5c; - return 1; - } - if (wc == 0x203e) { - *r = 0x7e; - return 1; - } - if (wc >= 0xff61 && wc < 0xffa0) { - *r = wc - 0xfec0; - return 1; - } - return RET_ILUNI; -} diff --git a/lib/johab.h b/lib/johab.h deleted file mode 100644 index 51432b5f..00000000 --- a/lib/johab.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2007, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * JOHAB - */ - -/* - Conversion between JOHAB codes (s1,s2) and KSX1001 codes (c1,c2): - Example. (s1,s2) = 0xD931, (c1,c2) = 0x2121. - (s1,s2) = 0xDEF1, (c1,c2) = 0x2C71. - (s1,s2) = 0xE031, (c1,c2) = 0x4A21. - (s1,s2) = 0xF9FE, (c1,c2) = 0x7D7E. - 0xD9 <= s1 <= 0xDE || 0xE0 <= s1 <= 0xF9, - 0x31 <= s2 <= 0x7E || 0x91 <= s2 <= 0xFE, - 0x21 <= c1 <= 0x2C || 0x4A <= c1 <= 0x7D, - 0x21 <= c2 <= 0x7E. - Invariant: - 94*(s1 < 0xE0 ? 2*s1-0x1B2 : 2*s1-0x197) + (s2 < 0x91 ? s2-0x31 : s2-0x43) - = 94*(c1-0x21)+(c2-0x21) - Conversion (s1,s2) -> (c1,c2): - t1 := (s1 < 0xE0 ? 2*s1-0x1B2 : 2*s1-0x197) - t2 := (s2 < 0x91 ? s2-0x31 : s2-0x43) - c1 := t1 + (t2 < 0x5E ? 0 : 1) + 0x21 - c2 := (t2 < 0x5E ? t2 : t2-0x5E) + 0x21 - Conversion (c1,c2) -> (s1,s2): - t := (c1 < 0x4A ? (c1-0x21+0x1B2) : (c1-0x21+0x197)) - s1 := t >> 1 - t2 := (t & 1) * 0x5E + (c2 - 0x21) - s2 := (t2 < 0x4E ? t2+0x31 : t2+0x43) - */ - -static int -johab_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - if (c < 0x80) { - if (c == 0x5c) - *pwc = (ucs4_t) 0x20a9; - else - *pwc = (ucs4_t) c; - return 1; - } else if (c < 0xd8) { - return johab_hangul_mbtowc(conv,pwc,s,n); - } else { - unsigned char s1, s2; - s1 = c; - if ((s1 >= 0xd9 && s1 <= 0xde) || (s1 >= 0xe0 && s1 <= 0xf9)) { - if (n < 2) - return RET_TOOFEW(0); - s2 = s[1]; - if ((s2 >= 0x31 && s2 <= 0x7e) || (s2 >= 0x91 && s2 <= 0xfe)) { - /* In KSC 5601, now KS X 1001, the region s1 = 0xDA, 0xA1 <= s2 <= 0xD3 - contains the 51 Jamo (Hangul letters). But in the Johab encoding, - they have been moved to the Hangul section, see - johab_hangul_page31. */ - if (!(s1 == 0xda && (s2 >= 0xa1 && s2 <= 0xd3))) { - unsigned char t1 = (s1 < 0xe0 ? 2*(s1-0xd9) : 2*s1-0x197); - unsigned char t2 = (s2 < 0x91 ? s2-0x31 : s2-0x43); - unsigned char buf[2]; - buf[0] = t1 + (t2 < 0x5e ? 0 : 1) + 0x21; - buf[1] = (t2 < 0x5e ? t2 : t2-0x5e) + 0x21; - return ksc5601_mbtowc(conv,pwc,buf,2); - } - } - } - return RET_ILSEQ; - } -} - -static int -johab_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[2]; - int ret; - - /* Try ASCII variation. */ - if (wc < 0x0080 && wc != 0x005c) { - *r = wc; - return 1; - } - if (wc == 0x20a9) { - *r = 0x5c; - return 1; - } - - /* Try JOHAB Hangul table before KSC5601 table, because the KSC5601 table - contains some (2350 out of 11172) Hangul syllables (rows 0x30XX..0x48XX), - and we want the search to return the JOHAB Hangul table entry. */ - - /* Try JOHAB Hangul. */ - ret = johab_hangul_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - r[0] = buf[0]; - r[1] = buf[1]; - return 2; - } - - /* Try KSC5601, now KS X 1001. */ - ret = ksc5601_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - unsigned char c1, c2; - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - c1 = buf[0]; - c2 = buf[1]; - if (((c1 >= 0x21 && c1 <= 0x2c) || (c1 >= 0x4a && c1 <= 0x7d)) - && (c2 >= 0x21 && c2 <= 0x7e)) { - unsigned int t = (c1 < 0x4A ? (c1-0x21+0x1B2) : (c1-0x21+0x197)); - unsigned char t2 = ((t & 1) ? 0x5e : 0) + (c2 - 0x21); - r[0] = t >> 1; - r[1] = (t2 < 0x4e ? t2+0x31 : t2+0x43); - return 2; - } - } - - return RET_ILUNI; -} diff --git a/lib/locale_charset.c b/lib/locale_charset.c new file mode 100644 index 00000000..4698faf9 --- /dev/null +++ b/lib/locale_charset.c @@ -0,0 +1,144 @@ +/** + * @file locale_charset.c + * @brief Detect the locale charset. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#include "cppp/reiconv.h" + +#include "cppp/cppp-platform.h" + +#include +#include +#include +#include +#include + +#include "localecharset/lc_types.h" +#include "localecharset/lc_utils.h" + +#if IS_DARWIN7 +#include +#endif // IS_DARWIN7 + +#if HAVE_LANGINFO_CODESET +#include +#endif // HAVE_LANGINFO_CODESET + +#if IS_WINDOWS_NATIVE || __has_cygwin__ +#define WIN32_LEAN_AND_MEAN +#include "localecharset/windows_getcp.h" + +#include + +/* + * For the use of setlocale() below, the Gnulib override in setlocale.c is + * not needed; see the platform lists in setlocale_null.m4. + */ +#undef setlocale +#endif // IS_WINDOWS_NATIVE || __has_cygwin__ + +#if !HAVE_LANGINFO_CODESET && !WINDOWS_NATIVE +#include "localecharset/locale_table.h" +#endif // !HAVE_LANGINFO_CODESET && !WINDOWS_NATIVE + +_CPPP_API const char *locale_charset() +{ +#if IS_WINDOWS_NATIVE + return windows_getcp(); +#endif // IS_WINDOWS_NATIVE + +#if IS_MACOSX || __has_beos__ || __has_haiku__ || __has_android__ + /* + * On Mac OS X, all modern locales use the UTF-8 encoding. + * BeOS, Haiku and Android have a single locale, and it has UTF-8 encoding. + */ + return "UTF-8"; +#endif // IS_MACOSX || __has_beos__ || __has_haiku__ || __has_android__ + + const char *codeset = NULL; + +#if HAVE_LANGINFO_CODESET + return nl_langinfo(CODESET); +#endif // HAVE_LANGINFO_CODESET + +#if __has_cygwin__ + return windows_getcp(); +#endif // __has_cygwin__ + + const char *locale = NULL; + GET_LOCALE(locale); + +#if locale_table_defined + // The locale_table is sorted. Perform a binary search. + size_t hi = LOCALE_TABLE_SIZE; + size_t lo = 0; + while (lo < hi) + { + /* + * Invariant: + * for i < lo, strcmp (locale_table[i].locale, locale) < 0, + * for i >= hi, strcmp (locale_table[i].locale, locale) > 0. + */ + size_t mid = (hi + lo) >> 1; // >= lo, < hi + int cmp = strcmp(locale_table[mid].locale, locale); + if (cmp < 0) + { + lo = mid + 1; + } + else if (cmp > 0) + { + hi = mid; + } + else + { + // Found an i with strcmp (locale_table[i].locale, locale) == 0. + codeset = locale_table[mid].canonical; + goto done_table_lookup; + } + } +#endif // locale_table_defined + // Cannot find the locale in the table, try to split it. + const char *p = strchr(locale, '.'); + if (p == NULL) + { + // No dot. + return REICONV_DEFAULT_CHARSET; + } + + // Split the locale into two parts. + codeset = p + 1; + return codeset; + +#if locale_table_defined +done_table_lookup: +#endif + +#if IS_DARWIN7 + /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8" + (the default codeset) does not work when MB_CUR_MAX is 1. */ + if (strcmp(codeset, "UTF-8") == 0 && MB_CUR_MAX_L(uselocale(NULL)) <= 1) + { + codeset = "ASCII"; + } +#endif // DARWIN7 + + return codeset; +} diff --git a/lib/iso8859_1.h b/lib/locale_charset.cpp similarity index 61% rename from lib/iso8859_1.h rename to lib/locale_charset.cpp index c35ceeb9..b95b8264 100644 --- a/lib/iso8859_1.h +++ b/lib/locale_charset.cpp @@ -1,5 +1,9 @@ +/** + * @file locale_charset.cpp + * @brief Detect the locale charset. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,28 +17,21 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ISO-8859-1 - */ +#include -static int -iso8859_1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - *pwc = (ucs4_t) c; - return 1; -} +#include + +#include -static int -iso8859_1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +namespace reiconv +{ +_CPPP_API std::string_view locale_charset() { - if (wc < 0x0100) { - *r = wc; - return 1; - } - return RET_ILUNI; + // The return value of C function is statically allocated. + return ::locale_charset(); } +} // namespace reiconv diff --git a/lib/ascii.h b/lib/localecharset/lc_types.h similarity index 59% rename from lib/ascii.h rename to lib/localecharset/lc_types.h index 93674567..81ac392d 100644 --- a/lib/ascii.h +++ b/lib/localecharset/lc_types.h @@ -1,5 +1,9 @@ +/** + * @file lc_types.h + * @brief Types for locale charset. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,31 +17,19 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* - * ASCII - */ +#ifndef _LC_TYPES_H_ +#define _LC_TYPES_H_ -static int -ascii_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - return RET_ILSEQ; -} +#define REICONV_DEFAULT_CHARSET "UTF-8" -static int -ascii_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) +struct locale_table_entry { - if (wc < 0x0080) { - *r = wc; - return 1; - } - return RET_ILUNI; -} + const char locale[17 + 1]; + const char canonical[11 + 1]; +}; + +#endif // _LC_TYPES_H_ diff --git a/lib/localecharset/lc_utils.h b/lib/localecharset/lc_utils.h new file mode 100644 index 00000000..f396175b --- /dev/null +++ b/lib/localecharset/lc_utils.h @@ -0,0 +1,59 @@ +/** + * @file lc_utils.h + * @brief Utilities for locale charset. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _LC_UTILS_H_ +#define _LC_UTILS_H_ + +#include + +#if defined(__APPLE__) && defined(__MACH__) +#define IS_MACOSX 1 +#else +#define IS_MACOSX 0 +#endif // defined(__APPLE__) && defined(__MACH__) + +#define IS_DARWIN7 (__has_macos__ && IS_MACOSX && HAVE_LANGINFO_CODESET) + +#define IS_WINDOWS_NATIVE (__has_windows__ && !__has_cygwin__) + +#define IS_INVALID_LOCALE(locale) (locale == NULL || locale[0] == '\0') + +#define GET_LOCALE(locale) \ + do \ + { \ + locale = getenv("LC_ALL"); \ + if (IS_INVALID_LOCALE(locale)) \ + { \ + locale = getenv("LC_CTYPE"); \ + if (IS_INVALID_LOCALE(locale)) \ + { \ + locale = getenv("LANG"); \ + if (IS_INVALID_LOCALE(locale)) \ + { \ + locale = setlocale(LC_CTYPE, NULL); \ + } \ + } \ + } \ + } while (0) + +#endif // _LC_UTILS_H_ diff --git a/lib/localecharset/locale_table.h b/lib/localecharset/locale_table.h new file mode 100644 index 00000000..d6edd5ac --- /dev/null +++ b/lib/localecharset/locale_table.h @@ -0,0 +1,118 @@ +/** + * @file locale_table.h + * @brief A mapping from locale name to canonical encoding name. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _LOCALE_TABLE_H_ +#define _LOCALE_TABLE_H_ + +#include "lc_types.h" + +#include + +#define locale_table_defined 1 + +// Table of platform-dependent mappings, sorted in ascending order. +static const struct locale_table_entry locale_table[] = { +#if __has_freebsd__ + {"cs_CZ.ISO_8859-2", "ISO-8859-2"}, + {"da_DK.DIS_8859-15", "ISO-8859-15"}, + {"da_DK.ISO_8859-1", "ISO-8859-1"}, + {"de_AT.DIS_8859-15", "ISO-8859-15"}, + {"de_AT.ISO_8859-1", "ISO-8859-1"}, + {"de_CH.DIS_8859-15", "ISO-8859-15"}, + {"de_CH.ISO_8859-1", "ISO-8859-1"}, + {"de_DE.DIS_8859-15", "ISO-8859-15"}, + {"de_DE.ISO_8859-1", "ISO-8859-1"}, + {"en_AU.DIS_8859-15", "ISO-8859-15"}, + {"en_AU.ISO_8859-1", "ISO-8859-1"}, + {"en_CA.DIS_8859-15", "ISO-8859-15"}, + {"en_CA.ISO_8859-1", "ISO-8859-1"}, + {"en_GB.DIS_8859-15", "ISO-8859-15"}, + {"en_GB.ISO_8859-1", "ISO-8859-1"}, + {"en_US.DIS_8859-15", "ISO-8859-15"}, + {"en_US.ISO_8859-1", "ISO-8859-1"}, + {"es_ES.DIS_8859-15", "ISO-8859-15"}, + {"es_ES.ISO_8859-1", "ISO-8859-1"}, + {"fi_FI.DIS_8859-15", "ISO-8859-15"}, + {"fi_FI.ISO_8859-1", "ISO-8859-1"}, + {"fr_BE.DIS_8859-15", "ISO-8859-15"}, + {"fr_BE.ISO_8859-1", "ISO-8859-1"}, + {"fr_CA.DIS_8859-15", "ISO-8859-15"}, + {"fr_CA.ISO_8859-1", "ISO-8859-1"}, + {"fr_CH.DIS_8859-15", "ISO-8859-15"}, + {"fr_CH.ISO_8859-1", "ISO-8859-1"}, + {"fr_FR.DIS_8859-15", "ISO-8859-15"}, + {"fr_FR.ISO_8859-1", "ISO-8859-1"}, + {"hr_HR.ISO_8859-2", "ISO-8859-2"}, + {"hu_HU.ISO_8859-2", "ISO-8859-2"}, + {"is_IS.DIS_8859-15", "ISO-8859-15"}, + {"is_IS.ISO_8859-1", "ISO-8859-1"}, + {"it_CH.DIS_8859-15", "ISO-8859-15"}, + {"it_CH.ISO_8859-1", "ISO-8859-1"}, + {"it_IT.DIS_8859-15", "ISO-8859-15"}, + {"it_IT.ISO_8859-1", "ISO-8859-1"}, + {"ja_JP.EUC", "EUC-JP"}, + {"ja_JP.SJIS", "SHIFT_JIS"}, + {"ja_JP.Shift_JIS", "SHIFT_JIS"}, + {"ko_KR.EUC", "EUC-KR"}, + {"la_LN.ASCII", "ASCII"}, + {"la_LN.DIS_8859-15", "ISO-8859-15"}, + {"la_LN.ISO_8859-1", "ISO-8859-1"}, + {"la_LN.ISO_8859-2", "ISO-8859-2"}, + {"la_LN.ISO_8859-4", "ISO-8859-4"}, + {"lt_LN.ASCII", "ASCII"}, + {"lt_LN.DIS_8859-15", "ISO-8859-15"}, + {"lt_LN.ISO_8859-1", "ISO-8859-1"}, + {"lt_LN.ISO_8859-2", "ISO-8859-2"}, + {"lt_LT.ISO_8859-4", "ISO-8859-4"}, + {"nl_BE.DIS_8859-15", "ISO-8859-15"}, + {"nl_BE.ISO_8859-1", "ISO-8859-1"}, + {"nl_NL.DIS_8859-15", "ISO-8859-15"}, + {"nl_NL.ISO_8859-1", "ISO-8859-1"}, + {"no_NO.DIS_8859-15", "ISO-8859-15"}, + {"no_NO.ISO_8859-1", "ISO-8859-1"}, + {"pl_PL.ISO_8859-2", "ISO-8859-2"}, + {"pt_PT.DIS_8859-15", "ISO-8859-15"}, + {"pt_PT.ISO_8859-1", "ISO-8859-1"}, + {"ru_RU.CP866", "CP866"}, + {"ru_RU.ISO_8859-5", "ISO-8859-5"}, + {"ru_RU.KOI8-R", "KOI8-R"}, + {"ru_SU.CP866", "CP866"}, + {"ru_SU.ISO_8859-5", "ISO-8859-5"}, + {"ru_SU.KOI8-R", "KOI8-R"}, + {"sl_SI.ISO_8859-2", "ISO-8859-2"}, + {"sv_SE.DIS_8859-15", "ISO-8859-15"}, + {"sv_SE.ISO_8859-1", "ISO-8859-1"}, + {"uk_UA.KOI8-U", "KOI8-U"}, + {"zh_CN.EUC", "GB2312"}, + {"zh_TW.BIG5", "BIG5"}, + {"zh_TW.Big5", "BIG5"} +#else +#undef locale_table_defined +#define locale_table_defined 0 + {"", ""} +#endif // __has_freebsd__ +}; + +#define LOCALE_TABLE_SIZE (sizeof(locale_table) / sizeof(struct locale_table_entry)) + +#endif // _LOCALE_TABLE_H_ diff --git a/lib/localecharset/windows_getcp.h b/lib/localecharset/windows_getcp.h new file mode 100644 index 00000000..60c27688 --- /dev/null +++ b/lib/localecharset/windows_getcp.h @@ -0,0 +1,347 @@ +/** + * @file windows_getcp.h + * @brief Get the current code page for Windows. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _WINDOWS_GETCP_H_ +#define _WINDOWS_GETCP_H_ + +#include + +#if !__has_windows__ +#error This file is only for Windows. +#endif + +#include + +static const char *windows_getcp() +{ +#ifdef _CONSOLE + UINT cp = GetConsoleOutputCP(); +#else + UINT cp = GetACP(); +#endif + switch (cp) + { + // Unicode + case 65001: + return "UTF-8"; + case 1200: + return "UCS2-LE"; + case 1201: + // On .NET, it's unicodeFFFE. But IANA says it's UNICODE11. + return "UNICODE11"; + case 12000: + return "UCS4-LE"; + case 12001: + return "UCS4-BE"; + case 65000: + return "UTF-7"; + + // CJK + case 936: + // cppp-reiconv's GB2312, GBK, CP936 is different. + return "CP936"; + case 950: + return "BIG5"; + case 10002: // We don't support it yet. + return "X-MAC-CHINESETRAD"; + case 10008: // We don't support it yet. + return "X-MAC-CHINESESIMP"; + case 20000: // We don't support it yet. + return "X-CHINESE_CNS"; + case 20002: // We don't support it yet. + return "X_CHINESE-ETEN"; + case 20936: // We don't support it yet. + return "X-CP20936"; + case 50227: + return "ISO-2022-CN"; + // case 50229: abort(); + // case 50935: abort(); + // case 50936: abort(); + // case 50937: abort(); + case 51936: + return "EUC-CN"; + // case 51950: abort(); + case 52936: + return "HZ-GB-2312"; + case 54936: + return "GB18030"; + case 932: + return "SHIFT_JIS"; + case 10001: // We don't support it yet. + return "X-MAC-JAPANESE"; + case 20290: // We don't support it yet. + return "IBM290"; + case 20932: + // .NET says it's EUC-JP. But EUC-JP is CP51932. + return "EUC-JP"; + case 50220: + return "ISO-2022-JP"; + case 50221: + return "ISO-2022-JP-MS"; + case 50222: + return "ISO-2022-JP"; + // case 50930: abort(); + // case 50931: abort(); + // case 50939: abort(); + case 51932: + return "EUC-JP"; + case 949: + return "KS_C_5601-1987"; + case 1361: + return "JOHAB"; + case 10003: // We don't support it yet. + return "X-MAC-KOREAN"; + case 20833: // We don't support it yet. + return "X-EBCDIC-KOREANEXTENDED"; + case 20949: + return "X-CP20949"; + case 50225: + return "ISO-2022-KR"; + // case 50933: abort(); + case 51949: + return "EUC-KR"; + + // Others + case 37: + return "IBM037"; + case 437: + return "IBM437"; + case 500: + return "IBM500"; + case 708: + // ASMO-708 alias to CP28596, but .NET uses it for CP708. + return "ASMO-708"; + // case 709: abort(); + // case 710: abort(); + case 720: // We don't support it yet. + return "DOS-720"; + case 737: + return "IBM737"; + case 775: + return "IBM775"; + case 850: + return "IBM850"; + case 852: + return "IBM852"; + case 855: + return "IBM855"; + case 857: + return "IBM857"; + case 858: + return "IBM00858"; + case 860: + return "IBM860"; + case 861: + return "IBM861"; + case 862: + return "DOS-862"; + case 863: + return "IBM863"; + case 864: + return "IBM864"; + case 865: + return "IBM865"; + case 866: + return "CP866"; + case 869: + return "IBM869"; + case 870: + return "IBM870"; + case 874: + return "WINDOWS-874"; + case 875: + return "CP875"; + case 1026: + return "IBM1026"; + case 1140: + return "IBM1140"; + case 1141: + return "IBM01141"; + case 1142: + return "IBM01142"; + case 1143: + return "IBM01143"; + case 1144: + return "IBM01144"; + case 1145: + return "IBM01145"; + case 1146: + return "IBM01146"; + case 1147: + return "IBM01147"; + case 1148: + return "IBM01148"; + case 1149: + return "IBM01149"; + case 1250: + return "WINDOWS-1250"; + case 1251: + return "WINDOWS-1251"; + case 1252: + return "WINDOWS-1252"; + case 1253: + return "WINDOWS-1253"; + case 1254: + return "WINDOWS-1254"; + case 1255: + return "WINDOWS-1255"; + case 1256: + return "WINDOWS-1256"; + case 1257: + return "WINDOWS-1257"; + case 1258: + return "VISCII"; + case 10000: + return "MACINTOSH"; + case 10004: + return "X-MAC-ARABIC"; + case 10005: + return "X-MAC-HEBREW"; + case 10006: + return "X-MAC-GREEK"; + case 10007: + return "X-MAC-CYRILLIC"; + case 10010: + return "X-MAC-ROMANIAN"; + case 10017: + return "X-MAC-UKRAINIAN"; + case 10021: + return "X-MAC-THAI"; + case 10029: + return "X-MAC-CE"; + case 10079: + return "X-MAC-ICELANDIC"; + case 10081: + return "X-MAC-TURKISH"; + case 10082: + return "X-MAC-CROATIAN"; + case 20001: // We don't support it yet. + return "X-CP20001"; + case 20003: // We don't support it yet. + return "X-CP20003"; + case 20004: // We don't support it yet. + return "X-CP20004"; + case 20005: // We don't support it yet. + return "X-CP20005"; + case 20105: // We don't support it yet. + return "X-IA5"; + case 20106: // We don't support it yet. + return "X-IA5-GERMAN"; + case 20107: // We don't support it yet. + return "X-IA5-SWEDISH"; + case 20108: // We don't support it yet. + return "X-IA5-NORWEGIAN"; + case 20127: // We don't support it yet. + // .NET says it's US-ASCII. But US-ASCII is CP367 in IANA. + return "CP20127"; + case 20261: // We don't support it yet. + return "X-CP20261"; + case 20269: // We don't support it yet. + return "X-CP20269"; + case 20273: + return "IBM273"; + case 20277: + return "IBM277"; + case 20278: + return "IBM278"; + case 20280: + return "IBM280"; + case 20284: + return "IBM284"; + case 20285: + return "IBM285"; + case 20297: + return "IBM297"; + case 20420: // We don't support it yet. + return "IBM420"; + case 20423: + return "IBM423"; + case 20424: + return "IBM424"; + case 20866: + return "KOI8-R"; + case 20871: + return "IBM871"; + case 20880: + return "IBM880"; + case 20905: + return "IBM905"; + case 20924: + return "IBM00924"; + case 21025: + return "CP1025"; + // case 21027: abort(); // CP21027 is deprecated. + case 21866: + return "KOI8-RU"; + case 28591: + return "ISO-8859-1"; + case 28592: + return "ISO-8859-2"; + case 28593: + return "ISO-8859-3"; + case 28594: + return "ISO-8859-4"; + case 28595: + return "ISO-8859-5"; + case 28596: + return "ISO-8859-6"; + case 28597: + return "ISO-8859-7"; + case 28598: + return "ISO-8859-8"; + case 28599: + return "ISO-8859-9"; + case 28603: + return "ISO-8859-13"; + case 28605: + return "ISO-8859-15"; + case 29001: // We don't support it yet. + return "X-EUROPA"; + case 38598: + return "ISO-8859-8-I"; + case 57002: // We don't support it yet. + return "X-ISCII-DE"; + case 57003: // We don't support it yet. + return "X-ISCII-BE"; + case 57004: // We don't support it yet. + return "X-ISCII-TA"; + case 57005: // We don't support it yet. + return "X-ISCII-TE"; + case 57006: // We don't support it yet. + return "X-ISCII-AS"; + case 57007: // We don't support it yet. + return "X-ISCII-OR"; + case 57008: // We don't support it yet. + return "X-ISCII-KA"; + case 57009: // We don't support it yet. + return "X-ISCII-MA"; + case 57010: // We don't support it yet. + return "X-ISCII-GU"; + case 57011: // We don't support it yet. + return "X-ISCII-PA"; + default: + return "ASCII"; + } +} + +#endif // _WINDOWS_GETCP_H_ diff --git a/lib/loop_funcs.h b/lib/loop_funcs.h new file mode 100644 index 00000000..1954f2b1 --- /dev/null +++ b/lib/loop_funcs.h @@ -0,0 +1,57 @@ +/** + * @file loop_funcs.h + * @brief Data type for general conversion loop. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _LOOP_FUNCS_H_ +#define _LOOP_FUNCS_H_ + +#include + +#include + +/** + * @brief Data type for general conversion loop. + */ +struct loop_funcs +{ + /** + * @brief Conversion loop. + * @param icd Conversion descriptor. + * @param inbuf Pointer to the input buffer. + * @param inbytesleft Number of bytes available at `inbuf`. + * @param outbuf Pointer to the output buffer. + * @param outbytesleft Number of bytes available at `outbuf`. + * @return Number of bytes written to `outbuf`. + */ + size_t (*loop_convert)(reiconv_t icd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); + + /** + * @brief Reset conversion loop. + * @param icd Conversion descriptor. + * @param outbuf Pointer to the output buffer. + * @param outbytesleft Number of bytes available at `outbuf`. + * @return Number of bytes written to `outbuf`. + */ + size_t (*loop_reset)(reiconv_t icd, char **outbuf, size_t *outbytesleft); +}; + +#endif /* _LOOP_FUNCS_H_ */ diff --git a/lib/loop_unicode.h b/lib/loop_unicode.h index fc5ed3fd..3753ec12 100644 --- a/lib/loop_unicode.h +++ b/lib/loop_unicode.h @@ -1,5 +1,10 @@ +/** + * @file loop_unicode.h + * @brief The conversion loop via Unicode as a pivot encoding. + * @copyright Copyright (C) 1999-2003, 2005-2006, 2008 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 1999-2003, 2005-2006, 2008 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,346 +18,219 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* This file defines the conversion loop via Unicode as a pivot encoding. */ - - -struct uc_to_mb_fallback_locals { - unsigned char* l_outbuf; - size_t l_outbytesleft; - int l_errno; -}; - -static void uc_to_mb_write_replacement (const char *buf, size_t buflen, - void* callback_arg) -{ - struct uc_to_mb_fallback_locals * plocals = - (struct uc_to_mb_fallback_locals *) callback_arg; - /* Do nothing if already encountered an error in a previous call. */ - if (plocals->l_errno == 0) { - /* Attempt to copy the passed buffer to the output buffer. */ - if (plocals->l_outbytesleft < buflen) - plocals->l_errno = E2BIG; - else { - memcpy(plocals->l_outbuf, buf, buflen); - plocals->l_outbuf += buflen; - plocals->l_outbytesleft -= buflen; - } - } -} - -struct mb_to_uc_fallback_locals { - conv_t l_cd; - unsigned char* l_outbuf; - size_t l_outbytesleft; - int l_errno; -}; +#ifndef _LOOPS_UNICODE_H_ +#define _LOOPS_UNICODE_H_ -static void mb_to_uc_write_replacement (const unsigned int *buf, size_t buflen, - void* callback_arg) -{ - struct mb_to_uc_fallback_locals * plocals = - (struct mb_to_uc_fallback_locals *) callback_arg; - /* Do nothing if already encountered an error in a previous call. */ - if (plocals->l_errno == 0) { - /* Attempt to convert the passed buffer to the target encoding. */ - conv_t cd = plocals->l_cd; - unsigned char* outptr = plocals->l_outbuf; - size_t outleft = plocals->l_outbytesleft; - for (; buflen > 0; buf++, buflen--) { - ucs4_t wc = *buf; - int outcount; - if (outleft == 0) { - plocals->l_errno = E2BIG; - break; - } - outcount = cd->ofuncs.xxx_wctomb(cd,outptr,wc,outleft); - if (outcount != RET_ILUNI) - goto outcount_ok; - /* Handle Unicode tag characters (range U+E0000..U+E007F). */ - if ((wc >> 7) == (0xe0000 >> 7)) - goto outcount_zero; - if (cd->discard_ilseq) { - outcount = 0; - goto outcount_ok; - } - else if (cd->fallbacks.uc_to_mb_fallback != NULL) { - struct uc_to_mb_fallback_locals locals; - locals.l_outbuf = outptr; - locals.l_outbytesleft = outleft; - locals.l_errno = 0; - cd->fallbacks.uc_to_mb_fallback(wc, - uc_to_mb_write_replacement, - &locals, - cd->fallbacks.data); - if (locals.l_errno != 0) { - plocals->l_errno = locals.l_errno; - break; - } - outptr = locals.l_outbuf; - outleft = locals.l_outbytesleft; - outcount = 0; - goto outcount_ok; - } - outcount = cd->ofuncs.xxx_wctomb(cd,outptr,0xFFFD,outleft); - if (outcount != RET_ILUNI) - goto outcount_ok; - plocals->l_errno = EILSEQ; - break; - outcount_ok: - if (outcount < 0) { - plocals->l_errno = E2BIG; - break; - } - if (cd->hooks.uc_hook) - (*cd->hooks.uc_hook)(wc, cd->hooks.data); - if (!(outcount <= outleft)) abort(); - outptr += outcount; outleft -= outcount; - outcount_zero: ; - } - plocals->l_outbuf = outptr; - plocals->l_outbytesleft = outleft; - } -} +#include "encoding_indexes.h" +#include "reiconv_defines.h" +#include +#include +#include +#include +#include -static size_t unicode_loop_convert (iconv_t icd, - const char* * inbuf, size_t *inbytesleft, - char* * outbuf, size_t *outbytesleft) +static size_t unicode_loop_convert(reiconv_t icd, const char **inbuf, size_t *inbytesleft, char **outbuf, + size_t *outbytesleft) { - conv_t cd = (conv_t) icd; - size_t result = 0; - const unsigned char* inptr = (const unsigned char*) *inbuf; - size_t inleft = *inbytesleft; - unsigned char* outptr = (unsigned char*) *outbuf; - size_t outleft = *outbytesleft; - while (inleft > 0) { - state_t last_istate = cd->istate; - ucs4_t wc; - int incount; - int outcount; - incount = cd->ifuncs.xxx_mbtowc(cd,&wc,inptr,inleft); - if (incount < 0) { - if ((unsigned int)(-1-incount) % 2 == (unsigned int)(-1-RET_ILSEQ) % 2) { - /* Case 1: invalid input, possibly after a shift sequence */ - incount = DECODE_SHIFT_ILSEQ(incount); - if (cd->discard_ilseq) { - switch (cd->iindex) { - case ei_ucs4: case ei_ucs4be: case ei_ucs4le: - case ei_utf32: case ei_utf32be: case ei_utf32le: - case ei_ucs4internal: case ei_ucs4swapped: - incount += 4; break; - case ei_ucs2: case ei_ucs2be: case ei_ucs2le: - case ei_utf16: case ei_utf16be: case ei_utf16le: - case ei_ucs2internal: case ei_ucs2swapped: - incount += 2; break; - default: - incount += 1; break; - } - goto outcount_zero; + conv_t cd = (conv_t)icd; + size_t result = 0; + const unsigned char *inptr = (const unsigned char *)*inbuf; + size_t inleft = *inbytesleft; + unsigned char *outptr = (unsigned char *)*outbuf; + size_t outleft = *outbytesleft; + while (inleft > 0) + { + state_t last_istate = cd->istate; + ucs4_t wc; + int incount; + int outcount; + incount = cd->ifuncs.xxx_mbtowc(cd, &wc, inptr, inleft); + if (incount < 0) + { + if ((unsigned int)(-1 - incount) % 2 == (unsigned int)(-1 - RET_ILSEQ) % 2) + { + /* Case 1: invalid input, possibly after a shift sequence */ + incount = DECODE_SHIFT_ILSEQ(incount); + if (cd->discard_ilseq) + { + switch (cd->iindex) + { + case ei_ucs4: + case ei_ucs4be: + case ei_ucs4le: + case ei_utf32: + case ei_utf32be: + case ei_utf32le: + case ei_ucs4internal: + case ei_ucs4swapped: + incount += 4; + break; + case ei_ucs2: + case ei_ucs2be: + case ei_ucs2le: + case ei_utf16: + case ei_utf16be: + case ei_utf16le: + case ei_ucs2internal: + case ei_ucs2swapped: + incount += 2; + break; + default: + incount += 1; + break; + } + goto outcount_zero; + } + inptr += incount; + inleft -= incount; + errno = EILSEQ; + result = -1; + break; + } + if (incount == RET_TOOFEW(0)) + { + /* Case 2: not enough bytes available to detect anything */ + errno = EINVAL; + result = -1; + break; + } + /* Case 3: k bytes read, but only a shift sequence */ + incount = DECODE_TOOFEW(incount); } - else if (cd->fallbacks.mb_to_uc_fallback != NULL) { - unsigned int incount2; - struct mb_to_uc_fallback_locals locals; - switch (cd->iindex) { - case ei_ucs4: case ei_ucs4be: case ei_ucs4le: - case ei_utf32: case ei_utf32be: case ei_utf32le: - case ei_ucs4internal: case ei_ucs4swapped: - incount2 = 4; break; - case ei_ucs2: case ei_ucs2be: case ei_ucs2le: - case ei_utf16: case ei_utf16be: case ei_utf16le: - case ei_ucs2internal: case ei_ucs2swapped: - incount2 = 2; break; - default: - incount2 = 1; break; - } - locals.l_cd = cd; - locals.l_outbuf = outptr; - locals.l_outbytesleft = outleft; - locals.l_errno = 0; - cd->fallbacks.mb_to_uc_fallback((const char*)inptr+incount, incount2, - mb_to_uc_write_replacement, - &locals, - cd->fallbacks.data); - if (locals.l_errno != 0) { - inptr += incount; inleft -= incount; - errno = locals.l_errno; + else + { + /* Case 4: k bytes read, making up a wide character */ + if (outleft == 0) + { + cd->istate = last_istate; + errno = E2BIG; + result = -1; + break; + } + outcount = cd->ofuncs.xxx_wctomb(cd, outptr, wc, outleft); + if (outcount != RET_ILUNI) + goto outcount_ok; + /* Handle Unicode tag characters (range U+E0000..U+E007F). */ + if ((wc >> 7) == (0xe0000 >> 7)) + goto outcount_zero; + result++; + if (cd->discard_ilseq) + { + outcount = 0; + goto outcount_ok; + } + outcount = cd->ofuncs.xxx_wctomb(cd, outptr, 0xFFFD, outleft); + if (outcount != RET_ILUNI) + goto outcount_ok; + cd->istate = last_istate; + errno = EILSEQ; result = -1; break; - } - incount += incount2; - outptr = locals.l_outbuf; - outleft = locals.l_outbytesleft; - result += 1; - goto outcount_zero; - } - inptr += incount; inleft -= incount; - errno = EILSEQ; - result = -1; - break; - } - if (incount == RET_TOOFEW(0)) { - /* Case 2: not enough bytes available to detect anything */ - errno = EINVAL; - result = -1; - break; - } - /* Case 3: k bytes read, but only a shift sequence */ - incount = DECODE_TOOFEW(incount); - } else { - /* Case 4: k bytes read, making up a wide character */ - if (outleft == 0) { - cd->istate = last_istate; - errno = E2BIG; - result = -1; - break; - } - outcount = cd->ofuncs.xxx_wctomb(cd,outptr,wc,outleft); - if (outcount != RET_ILUNI) - goto outcount_ok; - /* Handle Unicode tag characters (range U+E0000..U+E007F). */ - if ((wc >> 7) == (0xe0000 >> 7)) - goto outcount_zero; - result++; - if (cd->discard_ilseq) { - outcount = 0; - goto outcount_ok; - } - else if (cd->fallbacks.uc_to_mb_fallback != NULL) { - struct uc_to_mb_fallback_locals locals; - locals.l_outbuf = outptr; - locals.l_outbytesleft = outleft; - locals.l_errno = 0; - cd->fallbacks.uc_to_mb_fallback(wc, - uc_to_mb_write_replacement, - &locals, - cd->fallbacks.data); - if (locals.l_errno != 0) { - cd->istate = last_istate; - errno = locals.l_errno; - return -1; + outcount_ok: + if (outcount < 0) + { + cd->istate = last_istate; + errno = E2BIG; + result = -1; + break; + } + if (!(outcount <= outleft)) + abort(); + outptr += outcount; + outleft -= outcount; } - outptr = locals.l_outbuf; - outleft = locals.l_outbytesleft; - outcount = 0; - goto outcount_ok; - } - outcount = cd->ofuncs.xxx_wctomb(cd,outptr,0xFFFD,outleft); - if (outcount != RET_ILUNI) - goto outcount_ok; - cd->istate = last_istate; - errno = EILSEQ; - result = -1; - break; - outcount_ok: - if (outcount < 0) { - cd->istate = last_istate; - errno = E2BIG; - result = -1; - break; - } - if (cd->hooks.uc_hook) - (*cd->hooks.uc_hook)(wc, cd->hooks.data); - if (!(outcount <= outleft)) abort(); - outptr += outcount; outleft -= outcount; + outcount_zero: + if (!(incount <= inleft)) + abort(); + inptr += incount; + inleft -= incount; } - outcount_zero: - if (!(incount <= inleft)) abort(); - inptr += incount; inleft -= incount; - } - *inbuf = (const char*) inptr; - *inbytesleft = inleft; - *outbuf = (char*) outptr; - *outbytesleft = outleft; - return result; + *inbuf = (const char *)inptr; + *inbytesleft = inleft; + *outbuf = (char *)outptr; + *outbytesleft = outleft; + return result; } -static size_t unicode_loop_reset (iconv_t icd, - char* * outbuf, size_t *outbytesleft) +static size_t unicode_loop_reset(reiconv_t icd, char **outbuf, size_t *outbytesleft) { - conv_t cd = (conv_t) icd; - if (outbuf == NULL || *outbuf == NULL) { - /* Reset the states. */ - memset(&cd->istate,'\0',sizeof(state_t)); - memset(&cd->ostate,'\0',sizeof(state_t)); - return 0; - } else { - size_t result = 0; - if (cd->ifuncs.xxx_flushwc) { - state_t last_istate = cd->istate; - ucs4_t wc; - if (cd->ifuncs.xxx_flushwc(cd, &wc)) { - unsigned char* outptr = (unsigned char*) *outbuf; - size_t outleft = *outbytesleft; - int outcount = cd->ofuncs.xxx_wctomb(cd,outptr,wc,outleft); - if (outcount != RET_ILUNI) - goto outcount_ok; - /* Handle Unicode tag characters (range U+E0000..U+E007F). */ - if ((wc >> 7) == (0xe0000 >> 7)) - goto outcount_zero; - result++; - if (cd->discard_ilseq) { - outcount = 0; - goto outcount_ok; - } - else if (cd->fallbacks.uc_to_mb_fallback != NULL) { - struct uc_to_mb_fallback_locals locals; - locals.l_outbuf = outptr; - locals.l_outbytesleft = outleft; - locals.l_errno = 0; - cd->fallbacks.uc_to_mb_fallback(wc, - uc_to_mb_write_replacement, - &locals, - cd->fallbacks.data); - if (locals.l_errno != 0) { - cd->istate = last_istate; - errno = locals.l_errno; - return -1; - } - outptr = locals.l_outbuf; - outleft = locals.l_outbytesleft; - outcount = 0; - goto outcount_ok; + conv_t cd = (conv_t)icd; + if (outbuf == NULL || *outbuf == NULL) + { + /* Reset the states. */ + memset(&cd->istate, '\0', sizeof(state_t)); + memset(&cd->ostate, '\0', sizeof(state_t)); + return 0; + } + else + { + size_t result = 0; + if (cd->ifuncs.xxx_flushwc) + { + state_t last_istate = cd->istate; + ucs4_t wc; + if (cd->ifuncs.xxx_flushwc(cd, &wc)) + { + unsigned char *outptr = (unsigned char *)*outbuf; + size_t outleft = *outbytesleft; + int outcount = cd->ofuncs.xxx_wctomb(cd, outptr, wc, outleft); + if (outcount != RET_ILUNI) + goto outcount_ok; + /* Handle Unicode tag characters (range U+E0000..U+E007F). */ + if ((wc >> 7) == (0xe0000 >> 7)) + goto outcount_zero; + result++; + if (cd->discard_ilseq) + { + outcount = 0; + goto outcount_ok; + } + outcount = cd->ofuncs.xxx_wctomb(cd, outptr, 0xFFFD, outleft); + if (outcount != RET_ILUNI) + goto outcount_ok; + cd->istate = last_istate; + errno = EILSEQ; + return -1; + outcount_ok: + if (outcount < 0) + { + cd->istate = last_istate; + errno = E2BIG; + return -1; + } + if (!(outcount <= outleft)) + abort(); + outptr += outcount; + outleft -= outcount; + outcount_zero: + *outbuf = (char *)outptr; + *outbytesleft = outleft; + } } - outcount = cd->ofuncs.xxx_wctomb(cd,outptr,0xFFFD,outleft); - if (outcount != RET_ILUNI) - goto outcount_ok; - cd->istate = last_istate; - errno = EILSEQ; - return -1; - outcount_ok: - if (outcount < 0) { - cd->istate = last_istate; - errno = E2BIG; - return -1; + if (cd->ofuncs.xxx_reset) + { + unsigned char *outptr = (unsigned char *)*outbuf; + size_t outleft = *outbytesleft; + int outcount = cd->ofuncs.xxx_reset(cd, outptr, outleft); + if (outcount < 0) + { + errno = E2BIG; + return -1; + } + if (!(outcount <= outleft)) + abort(); + *outbuf = (char *)(outptr + outcount); + *outbytesleft = outleft - outcount; } - if (cd->hooks.uc_hook) - (*cd->hooks.uc_hook)(wc, cd->hooks.data); - if (!(outcount <= outleft)) abort(); - outptr += outcount; - outleft -= outcount; - outcount_zero: - *outbuf = (char*) outptr; - *outbytesleft = outleft; - } - } - if (cd->ofuncs.xxx_reset) { - unsigned char* outptr = (unsigned char*) *outbuf; - size_t outleft = *outbytesleft; - int outcount = cd->ofuncs.xxx_reset(cd,outptr,outleft); - if (outcount < 0) { - errno = E2BIG; - return -1; - } - if (!(outcount <= outleft)) abort(); - *outbuf = (char*) (outptr + outcount); - *outbytesleft = outleft - outcount; + memset(&cd->istate, '\0', sizeof(state_t)); + memset(&cd->ostate, '\0', sizeof(state_t)); + return result; } - memset(&cd->istate,'\0',sizeof(state_t)); - memset(&cd->ostate,'\0',sizeof(state_t)); - return result; - } } + +#endif /* _LOOPS_UNICODE_H_ */ diff --git a/lib/loops.h b/lib/loops.h index 63826a78..115d7be0 100644 --- a/lib/loops.h +++ b/lib/loops.h @@ -1,5 +1,10 @@ +/** + * @file loops.h + * @brief All the loops. + * @copyright Copyright (C) 2000 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 2000 Free Software Foundation, Inc. * This file is part of the cppp-reiconv library. * * The cppp-reiconv library is free software; you can redistribute it @@ -13,10 +18,13 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. + * License along with the cppp-reiconv library; see the file LICENSE. * If not, see . */ -/* This file defines all the loops. */ +#ifndef _LOOPS_H_ +#define _LOOPS_H_ + +#include "loop_unicode.h" // IWYU pragma: export -#include "loop_unicode.h" +#endif /* _LOOPS_H_ */ diff --git a/lib/reiconv.cpp b/lib/reiconv.cpp new file mode 100644 index 00000000..f1bc5972 --- /dev/null +++ b/lib/reiconv.cpp @@ -0,0 +1,74 @@ +/** + * @file reiconv.cpp + * @brief reiconv C++ bindings implementation. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#include + +#include +#include +#include +#include +#include + +#include + +_CPPP_API reiconv::Encoding::Encoding(const char *const name) +{ + _index = ::reiconv_lookup_from_name(name); + if (_index == -1) + { + throw std::invalid_argument("Invalid encoding name."); + } +} + +_CPPP_API reiconv::Encoding::Encoding(const int codepage) +{ + _index = ::reiconv_lookup_from_codepage(codepage); + if (_index == -1) + { + throw std::invalid_argument("Invalid codepage."); + } +} + +_CPPP_API reiconv::VersionInfo reiconv::version{VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH}; + +_CPPP_API std::string reiconv::convert(reiconv::Encoding from, reiconv::Encoding to, const std::string_view input, + enum ConvertFlag flag) +{ + ::reiconv_t cd = ::reiconv_open_from_index(from, to, (enum ::ConvertFlag)flag); + if (cd == (::reiconv_t)(-1)) + { + throw std::system_error(errno, std::system_category(), "reiconv_open_from_index"); + } + std::size_t outlen = ::reiconv_result_size(cd, input.data(), input.size()); + + std::string res(outlen, '\0'); + char *result = const_cast(res.data()); + if (::reiconv_convert_static_size(cd, input.data(), input.size(), result, outlen) != 0) + { + ::reiconv_handle_close(cd); + throw std::system_error(errno, std::system_category(), "reiconv_convert"); + } + + ::reiconv_handle_close(cd); + return std::move(res); +} diff --git a/lib/reiconv_defines.h b/lib/reiconv_defines.h new file mode 100644 index 00000000..9d2b665c --- /dev/null +++ b/lib/reiconv_defines.h @@ -0,0 +1,150 @@ +/** + * @file reiconv_defines.h + * @brief Type definitions for the reiconv implementation. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . + */ + +#ifndef _REICONV_DEFINES_H_ +#define _REICONV_DEFINES_H_ + +#include + +#include "loop_funcs.h" + +/** + * @brief Our own notion of wide character, as UCS-4, according to ISO-10646-1. + */ +typedef unsigned int ucs4_t; + +/** + * @brief State used by a conversion. 0 denotes the initial state. + */ +typedef unsigned int state_t; + +/** + * @brief reiconv_t is an opaque type. This is the real reiconv_t type. + */ +typedef struct conv_struct *conv_t; + +/** + * @brief Data type for conversion multibyte -> unicode + */ +struct mbtowc_funcs +{ + /** + * @brief Converts the byte sequence starting at `s` to a wide character. Up to `n` bytes are + * available at `s`. `n` is >= 1. + * @param conv Conversion structure. + * @param pwc Pointer to the wide character. + * @param s Pointer to the byte sequence. + * @param n Number of bytes available at `s`. + * @return Number of bytes consumed (if a wide character was read), or -1 if invalid, or -2 if + * `n` too small, or RET_SHIFT_ILSEQ(number of bytes consumed) if invalid input after a shift + * sequence was read, or RET_TOOFEW(number of bytes consumed) if only a shift sequence was read. + */ + int (*xxx_mbtowc)(conv_t conv, ucs4_t *pwc, unsigned char const *s, size_t n); + + /** + * @brief Returns to the initial state and stores the pending wide character, if any. + * @param conv Conversion structure. + * @param pwc Pointer to the wide character. + * @return Result is 1 (if a wide character was read) or 0 if none was pending. + */ + int (*xxx_flushwc)(conv_t conv, ucs4_t *pwc); +}; + +/* Return code if invalid input after a shift sequence of n bytes was read. + (xxx_mbtowc) */ +#define RET_SHIFT_ILSEQ(n) (-1 - 2 * (n)) + +/* Return code if invalid. (xxx_mbtowc) */ +#define RET_ILSEQ RET_SHIFT_ILSEQ(0) + +/* Return code if only a shift sequence of n bytes was read. (xxx_mbtowc) */ +#define RET_TOOFEW(n) (-2 - 2 * (n)) + +/* Retrieve the n from the encoded RET_... value. */ +#define DECODE_SHIFT_ILSEQ(r) ((unsigned int)(RET_SHIFT_ILSEQ(0) - (r)) / 2) + +#define DECODE_TOOFEW(r) ((unsigned int)(RET_TOOFEW(0) - (r)) / 2) + +/* Maximum value of n that may be used as argument to RET_SHIFT_ILSEQ or RET_TOOFEW. */ +#define RET_COUNT_MAX ((INT_MAX / 2) - 1) + +/** + * @brief Data type for conversion unicode -> multibyte + */ +struct wctomb_funcs +{ + /** + * @brief Converts the wide character `wc` to the character set xxx, and stores the result + * beginning at `r`. Up to `n` bytes may be written at `r`. `n` is >= 1. + * @param conv Conversion structure. + * @param r Pointer to the result. + * @param wc Wide character to convert. + * @param n Number of bytes available at `r`. + * @return Number of bytes written, or -1 if invalid, or -2 if `n` too small. + */ + int (*xxx_wctomb)(conv_t conv, unsigned char *r, ucs4_t wc, size_t n); + + /** + * @brief Stores a shift sequence returning to the initial state beginning at `r`. Up to `n` + * bytes may be written at `r`. `n` is >= 0. + * @param conv Conversion structure. + * @param r Pointer to the result. + * @param n Number of bytes available at `r`. + * @return Number of bytes written, or -2 if `n` too small. + */ + int (*xxx_reset)(conv_t conv, unsigned char *r, size_t n); +}; + +/* Return code if invalid. (xxx_wctomb) */ +#define RET_ILUNI -1 + +/* Return code if output buffer is too small. (xxx_wctomb, xxx_reset) */ +#define RET_TOOSMALL -2 + +/** + * @brief Contents of a conversion descriptor. + */ +struct conv_struct +{ + struct loop_funcs lfuncs; + /* Input (conversion multibyte -> unicode) */ + int iindex; + struct mbtowc_funcs ifuncs; + state_t ibyteorder; + state_t istate; + /* Output (conversion unicode -> multibyte) */ + int oindex; + struct wctomb_funcs ofuncs; + state_t ostate; + /* Operation flags */ + int discard_ilseq; +}; + +/* [CCS = coded character set] [CJKV.INF chapter 3] */ +typedef struct +{ + unsigned short indx; /* Index into big table. */ + unsigned short used; /* Bitmask of used entries. */ +} Summary16; + +#endif /* _REICONV_DEFINES_H_ */ diff --git a/lib/shift_jisx0213.h b/lib/shift_jisx0213.h deleted file mode 100644 index 5b2d692b..00000000 --- a/lib/shift_jisx0213.h +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (C) 1999-2002 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * SHIFT_JISX0213 - */ - -/* The structure of Shift_JISX0213 is as follows: - - 0x00..0x7F: ISO646-JP, an ASCII variant - - 0x{A1..DF}: JISX0201 Katakana. - - 0x{81..9F,E0..EF}{40..7E,80..FC}: JISX0213 plane 1. - - 0x{F0..FC}{40..7E,80..FC}: JISX0213 plane 2, with irregular row mapping. - - Note that some JISX0213 characters are not contained in Unicode 3.2 - and are therefore best represented as sequences of Unicode characters. -*/ - -#include "jisx0213.h" -#include "flushwc.h" - -static int -shift_jisx0213_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - ucs4_t last_wc = conv->istate; - if (last_wc) { - /* Output the buffered character. */ - conv->istate = 0; - *pwc = last_wc; - return 0; /* Don't advance the input pointer. */ - } else { - unsigned char c = *s; - if (c < 0x80) { - /* Plain ISO646-JP character. */ - if (c == 0x5c) - *pwc = (ucs4_t) 0x00a5; - else if (c == 0x7e) - *pwc = (ucs4_t) 0x203e; - else - *pwc = (ucs4_t) c; - return 1; - } else if (c >= 0xa1 && c <= 0xdf) { - *pwc = c + 0xfec0; - return 1; - } else { - if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc)) { - /* Two byte character. */ - if (n >= 2) { - unsigned char c2 = s[1]; - if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfc)) { - unsigned int c1; - ucs4_t wc; - /* Convert to row and column. */ - if (c < 0xe0) - c -= 0x81; - else - c -= 0xc1; - if (c2 < 0x80) - c2 -= 0x40; - else - c2 -= 0x41; - /* Now 0 <= c <= 0x3b, 0 <= c2 <= 0xbb. */ - c1 = 2 * c; - if (c2 >= 0x5e) - c2 -= 0x5e, c1++; - c2 += 0x21; - if (c1 >= 0x5e) { - /* Handling of JISX 0213 plane 2 rows. */ - if (c1 >= 0x67) - c1 += 230; - else if (c1 >= 0x63 || c1 == 0x5f) - c1 += 168; - else - c1 += 162; - } - wc = jisx0213_to_ucs4(0x121+c1,c2); - if (wc) { - if (wc < 0x80) { - /* It's a combining character. */ - ucs4_t wc1 = jisx0213_to_ucs_combining[wc - 1][0]; - ucs4_t wc2 = jisx0213_to_ucs_combining[wc - 1][1]; - /* We cannot output two Unicode characters at once. So, - output the first character and buffer the second one. */ - *pwc = wc1; - conv->istate = wc2; - } else - *pwc = wc; - return 2; - } - } - } else - return RET_TOOFEW(0); - } - return RET_ILSEQ; - } - } -} - -#define shift_jisx0213_flushwc normal_flushwc - -/* Composition tables for each of the relevant combining characters. */ -static const struct { unsigned short base; unsigned short composed; } shift_jisx0213_comp_table_data[] = { -#define shift_jisx0213_comp_table02e5_idx 0 -#define shift_jisx0213_comp_table02e5_len 1 - { 0x8684, 0x8685 }, /* 0x12B65 = 0x12B64 U+02E5 */ -#define shift_jisx0213_comp_table02e9_idx (shift_jisx0213_comp_table02e5_idx+shift_jisx0213_comp_table02e5_len) -#define shift_jisx0213_comp_table02e9_len 1 - { 0x8680, 0x8686 }, /* 0x12B66 = 0x12B60 U+02E9 */ -#define shift_jisx0213_comp_table0300_idx (shift_jisx0213_comp_table02e9_idx+shift_jisx0213_comp_table02e9_len) -#define shift_jisx0213_comp_table0300_len 5 - { 0x857b, 0x8663 }, /* 0x12B44 = 0x1295C U+0300 */ - { 0x8657, 0x8667 }, /* 0x12B48 = 0x12B38 U+0300 */ - { 0x8656, 0x8669 }, /* 0x12B4A = 0x12B37 U+0300 */ - { 0x864f, 0x866b }, /* 0x12B4C = 0x12B30 U+0300 */ - { 0x8662, 0x866d }, /* 0x12B4E = 0x12B43 U+0300 */ -#define shift_jisx0213_comp_table0301_idx (shift_jisx0213_comp_table0300_idx+shift_jisx0213_comp_table0300_len) -#define shift_jisx0213_comp_table0301_len 4 - { 0x8657, 0x8668 }, /* 0x12B49 = 0x12B38 U+0301 */ - { 0x8656, 0x866a }, /* 0x12B4B = 0x12B37 U+0301 */ - { 0x864f, 0x866c }, /* 0x12B4D = 0x12B30 U+0301 */ - { 0x8662, 0x866e }, /* 0x12B4F = 0x12B43 U+0301 */ -#define shift_jisx0213_comp_table309a_idx (shift_jisx0213_comp_table0301_idx+shift_jisx0213_comp_table0301_len) -#define shift_jisx0213_comp_table309a_len 14 - { 0x82a9, 0x82f5 }, /* 0x12477 = 0x1242B U+309A */ - { 0x82ab, 0x82f6 }, /* 0x12478 = 0x1242D U+309A */ - { 0x82ad, 0x82f7 }, /* 0x12479 = 0x1242F U+309A */ - { 0x82af, 0x82f8 }, /* 0x1247A = 0x12431 U+309A */ - { 0x82b1, 0x82f9 }, /* 0x1247B = 0x12433 U+309A */ - { 0x834a, 0x8397 }, /* 0x12577 = 0x1252B U+309A */ - { 0x834c, 0x8398 }, /* 0x12578 = 0x1252D U+309A */ - { 0x834e, 0x8399 }, /* 0x12579 = 0x1252F U+309A */ - { 0x8350, 0x839a }, /* 0x1257A = 0x12531 U+309A */ - { 0x8352, 0x839b }, /* 0x1257B = 0x12533 U+309A */ - { 0x835a, 0x839c }, /* 0x1257C = 0x1253B U+309A */ - { 0x8363, 0x839d }, /* 0x1257D = 0x12544 U+309A */ - { 0x8367, 0x839e }, /* 0x1257E = 0x12548 U+309A */ - { 0x83f3, 0x83f6 }, /* 0x12678 = 0x12675 U+309A */ -}; - -static int -shift_jisx0213_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - int count = 0; - unsigned short lasttwo = conv->ostate; - - if (lasttwo) { - /* Attempt to combine the last character with this one. */ - unsigned int idx; - unsigned int len; - - if (wc == 0x02e5) - idx = shift_jisx0213_comp_table02e5_idx, - len = shift_jisx0213_comp_table02e5_len; - else if (wc == 0x02e9) - idx = shift_jisx0213_comp_table02e9_idx, - len = shift_jisx0213_comp_table02e9_len; - else if (wc == 0x0300) - idx = shift_jisx0213_comp_table0300_idx, - len = shift_jisx0213_comp_table0300_len; - else if (wc == 0x0301) - idx = shift_jisx0213_comp_table0301_idx, - len = shift_jisx0213_comp_table0301_len; - else if (wc == 0x309a) - idx = shift_jisx0213_comp_table309a_idx, - len = shift_jisx0213_comp_table309a_len; - else - goto not_combining; - - do - if (shift_jisx0213_comp_table_data[idx].base == lasttwo) - break; - while (++idx, --len > 0); - - if (len > 0) { - /* Output the combined character. */ - if (n >= 2) { - lasttwo = shift_jisx0213_comp_table_data[idx].composed; - r[0] = (lasttwo >> 8) & 0xff; - r[1] = lasttwo & 0xff; - conv->ostate = 0; - return 2; - } else - return RET_TOOSMALL; - } - - not_combining: - /* Output the buffered character. */ - if (n < 2) - return RET_TOOSMALL; - r[0] = (lasttwo >> 8) & 0xff; - r[1] = lasttwo & 0xff; - r += 2; - count = 2; - } - - if (wc < 0x80 && wc != 0x5c && wc != 0x7e) { - /* Plain ISO646-JP character. */ - if (n > count) { - r[0] = (unsigned char) wc; - conv->ostate = 0; - return count+1; - } else - return RET_TOOSMALL; - } else if (wc == 0x00a5) { - if (n > count) { - r[0] = 0x5c; - conv->ostate = 0; - return count+1; - } else - return RET_TOOSMALL; - } else if (wc == 0x203e) { - if (n > count) { - r[0] = 0x7e; - conv->ostate = 0; - return count+1; - } else - return RET_TOOSMALL; - } else if (wc >= 0xff61 && wc <= 0xff9f) { - /* Half-width katakana. */ - if (n > count) { - r[0] = wc - 0xfec0; - conv->ostate = 0; - return count+1; - } else - return RET_TOOSMALL; - } else { - unsigned int s1, s2; - unsigned short jch = ucs4_to_jisx0213(wc); - if (jch != 0) { - /* Convert it to shifted representation. */ - s1 = jch >> 8; - s2 = jch & 0x7f; - s1 -= 0x21; - s2 -= 0x21; - if (s1 >= 0x5e) { - /* Handling of JISX 0213 plane 2 rows. */ - if (s1 >= 0xcd) /* rows 0x26E..0x27E */ - s1 -= 102; - else if (s1 >= 0x8b || s1 == 0x87) /* rows 0x228, 0x22C..0x22F */ - s1 -= 40; - else /* rows 0x221, 0x223..0x225 */ - s1 -= 34; - /* Now 0x5e <= s1 <= 0x77. */ - } - if (s1 & 1) - s2 += 0x5e; - s1 = s1 >> 1; - if (s1 < 0x1f) - s1 += 0x81; - else - s1 += 0xc1; - if (s2 < 0x3f) - s2 += 0x40; - else - s2 += 0x41; - if (jch & 0x0080) { - /* A possible match in comp_table_data. We have to buffer it. */ - /* We know it's a JISX 0213 plane 1 character. */ - if (jch & 0x8000) abort(); - conv->ostate = (s1 << 8) | s2; - return count+0; - } - /* Output the shifted representation. */ - if (n >= count+2) { - r[0] = s1; - r[1] = s2; - conv->ostate = 0; - return count+2; - } else - return RET_TOOSMALL; - } - return RET_ILUNI; - } -} - -static int -shift_jisx0213_reset (conv_t conv, unsigned char *r, size_t n) -{ - state_t lasttwo = conv->ostate; - - if (lasttwo) { - if (n < 2) - return RET_TOOSMALL; - r[0] = (lasttwo >> 8) & 0xff; - r[1] = lasttwo & 0xff; - /* conv->ostate = 0; will be done by the caller */ - return 2; - } else - return 0; -} diff --git a/lib/sjis.h b/lib/sjis.h deleted file mode 100644 index 8d2c2ee4..00000000 --- a/lib/sjis.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 1999-2002, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * SHIFT_JIS - */ - -/* - Conversion between SJIS codes (s1,s2) and JISX0208 codes (c1,c2): - Example. (s1,s2) = 0x8140, (c1,c2) = 0x2121. - 0x81 <= s1 <= 0x9F || 0xE0 <= s1 <= 0xEA, - 0x40 <= s2 <= 0x7E || 0x80 <= s2 <= 0xFC, - 0x21 <= c1 <= 0x74, 0x21 <= c2 <= 0x7E. - Invariant: - 94*2*(s1 < 0xE0 ? s1-0x81 : s1-0xC1) + (s2 < 0x80 ? s2-0x40 : s2-0x41) - = 94*(c1-0x21)+(c2-0x21) - Conversion (s1,s2) -> (c1,c2): - t1 := (s1 < 0xE0 ? s1-0x81 : s1-0xC1) - t2 := (s2 < 0x80 ? s2-0x40 : s2-0x41) - c1 := 2*t1 + (t2 < 0x5E ? 0 : 1) + 0x21 - c2 := (t2 < 0x5E ? t2 : t2-0x5E) + 0x21 - Conversion (c1,c2) -> (s1,s2): - t1 := (c1 - 0x21) >> 1 - t2 := ((c1 - 0x21) & 1) * 0x5E + (c2 - 0x21) - s1 := (t1 < 0x1F ? t1+0x81 : t1+0xC1) - s2 := (t2 < 0x3F ? t2+0x40 : t2+0x41) - */ - -static int -sjis_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - if (c < 0x80 || (c >= 0xa1 && c <= 0xdf)) - return jisx0201_mbtowc(conv,pwc,s,n); - else { - unsigned char s1, s2; - s1 = c; - if ((s1 >= 0x81 && s1 <= 0x9f) || (s1 >= 0xe0 && s1 <= 0xea)) { - if (n < 2) - return RET_TOOFEW(0); - s2 = s[1]; - if ((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0x80 && s2 <= 0xfc)) { - unsigned char t1 = (s1 < 0xe0 ? s1-0x81 : s1-0xc1); - unsigned char t2 = (s2 < 0x80 ? s2-0x40 : s2-0x41); - unsigned char buf[2]; - buf[0] = 2*t1 + (t2 < 0x5e ? 0 : 1) + 0x21; - buf[1] = (t2 < 0x5e ? t2 : t2-0x5e) + 0x21; - return jisx0208_mbtowc(conv,pwc,buf,2); - } - } else if (s1 >= 0xf0 && s1 <= 0xf9) { - /* User-defined range. See - * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ - if (n < 2) - return RET_TOOFEW(0); - s2 = s[1]; - if ((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0x80 && s2 <= 0xfc)) { - *pwc = 0xe000 + 188*(s1 - 0xf0) + (s2 < 0x80 ? s2-0x40 : s2-0x41); - return 2; - } - } - return RET_ILSEQ; - } -} - -static int -sjis_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - unsigned char buf[2]; - int ret; - - /* Try JIS X 0201-1976. */ - ret = jisx0201_wctomb(conv,buf,wc,1); - if (ret != RET_ILUNI) { - unsigned char c; - if (ret != 1) abort(); - c = buf[0]; - if (c < 0x80 || (c >= 0xa1 && c <= 0xdf)) { - r[0] = c; - return 1; - } - } - - /* Try JIS X 0208-1990. */ - ret = jisx0208_wctomb(conv,buf,wc,2); - if (ret != RET_ILUNI) { - unsigned char c1, c2; - if (ret != 2) abort(); - if (n < 2) - return RET_TOOSMALL; - c1 = buf[0]; - c2 = buf[1]; - if ((c1 >= 0x21 && c1 <= 0x74) && (c2 >= 0x21 && c2 <= 0x7e)) { - unsigned char t1 = (c1 - 0x21) >> 1; - unsigned char t2 = (((c1 - 0x21) & 1) ? 0x5e : 0) + (c2 - 0x21); - r[0] = (t1 < 0x1f ? t1+0x81 : t1+0xc1); - r[1] = (t2 < 0x3f ? t2+0x40 : t2+0x41); - return 2; - } - } - - /* User-defined range. See - * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ - if (wc >= 0xe000 && wc < 0xe758) { - unsigned char c1, c2; - if (n < 2) - return RET_TOOSMALL; - c1 = (unsigned int) (wc - 0xe000) / 188; - c2 = (unsigned int) (wc - 0xe000) % 188; - r[0] = c1+0xf0; - r[1] = (c2 < 0x3f ? c2+0x40 : c2+0x41); - return 2; - } - - return RET_ILUNI; -} diff --git a/lib/tis620.h b/lib/tis620.h deleted file mode 100644 index 8ffd07e7..00000000 --- a/lib/tis620.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * TIS620.2533-1 - */ - -static int -tis620_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - unsigned char c = *s; - if (c < 0x80) { - *pwc = (ucs4_t) c; - return 1; - } - else if (c >= 0xa1 && c <= 0xfb && !(c >= 0xdb && c <= 0xde)) { - *pwc = (ucs4_t) (c + 0x0d60); - return 1; - } - return RET_ILSEQ; -} - -static int -tis620_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc < 0x0080) { - *r = wc; - return 1; - } - else if (wc >= 0x0e01 && wc <= 0x0e5b && !(wc >= 0x0e3b && wc <= 0x0e3e)) { - *r = wc-0x0d60; - return 1; - } - return RET_ILUNI; -} diff --git a/lib/ucs2.h b/lib/ucs2.h deleted file mode 100644 index 5d4dbcea..00000000 --- a/lib/ucs2.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2011, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * UCS-2 - */ - -/* Here we accept FFFE/FEFF marks as endianness indicators everywhere - in the stream, not just at the beginning. The default is big-endian. */ -/* The state is 0 if big-endian, 1 if little-endian. */ -static int -ucs2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - state_t state = conv->istate; - int count = 0; - for (; n >= 2 && count <= RET_COUNT_MAX && count <= INT_MAX-2;) { - ucs4_t wc = (state ? s[0] + (s[1] << 8) : (s[0] << 8) + s[1]); - if (wc == 0xfeff) { - } else if (wc == 0xfffe) { - state ^= 1; - } else if (wc >= 0xd800 && wc < 0xe000) { - conv->istate = state; - return RET_SHIFT_ILSEQ(count); - } else { - *pwc = wc; - conv->istate = state; - return count+2; - } - s += 2; n -= 2; count += 2; - } - conv->istate = state; - return RET_TOOFEW(count); -} - -/* But we output UCS-2 in big-endian order, without byte-order mark. */ -/* RFC 2152 says: - "ISO/IEC 10646-1:1993(E) specifies that when characters the UCS-2 form are - serialized as octets, that the most significant octet appear first." */ -static int -ucs2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc < 0x10000 && wc != 0xfffe && !(wc >= 0xd800 && wc < 0xe000)) { - if (n >= 2) { - r[0] = (unsigned char) (wc >> 8); - r[1] = (unsigned char) wc; - return 2; - } else - return RET_TOOSMALL; - } else - return RET_ILUNI; -} diff --git a/lib/ucs2be.h b/lib/ucs2be.h deleted file mode 100644 index 17eb6a21..00000000 --- a/lib/ucs2be.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * UCS-2BE = UCS-2 big endian - */ - -static int -ucs2be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - if (n >= 2) { - if (s[0] >= 0xd8 && s[0] < 0xe0) { - return RET_ILSEQ; - } else { - *pwc = (s[0] << 8) + s[1]; - return 2; - } - } - return RET_TOOFEW(0); -} - -static int -ucs2be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc < 0x10000 && !(wc >= 0xd800 && wc < 0xe000)) { - if (n >= 2) { - r[0] = (unsigned char) (wc >> 8); - r[1] = (unsigned char) wc; - return 2; - } else - return RET_TOOSMALL; - } - return RET_ILUNI; -} diff --git a/lib/ucs2internal.h b/lib/ucs2internal.h deleted file mode 100644 index b3be8f1c..00000000 --- a/lib/ucs2internal.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * UCS-2-INTERNAL = UCS-2 with machine dependent endianness and alignment - */ - -static int -ucs2internal_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - if (n >= 2) { - unsigned short x = *(const unsigned short *)s; - if (x >= 0xd800 && x < 0xe000) { - return RET_ILSEQ; - } else { - *pwc = x; - return 2; - } - } - return RET_TOOFEW(0); -} - -static int -ucs2internal_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc < 0x10000 && !(wc >= 0xd800 && wc < 0xe000)) { - if (n >= 2) { - *(unsigned short *)r = wc; - return 2; - } else - return RET_TOOSMALL; - } else - return RET_ILUNI; -} diff --git a/lib/ucs2le.h b/lib/ucs2le.h deleted file mode 100644 index 7f47ec8b..00000000 --- a/lib/ucs2le.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * UCS-2LE = UCS-2 little endian - */ - -static int -ucs2le_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - if (n >= 2) { - if (s[1] >= 0xd8 && s[1] < 0xe0) { - return RET_ILSEQ; - } else { - *pwc = s[0] + (s[1] << 8); - return 2; - } - } - return RET_TOOFEW(0); -} - -static int -ucs2le_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc < 0x10000 && !(wc >= 0xd800 && wc < 0xe000)) { - if (n >= 2) { - r[0] = (unsigned char) wc; - r[1] = (unsigned char) (wc >> 8); - return 2; - } else - return RET_TOOSMALL; - } - return RET_ILUNI; -} diff --git a/lib/ucs2swapped.h b/lib/ucs2swapped.h deleted file mode 100644 index 7114ab6f..00000000 --- a/lib/ucs2swapped.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * UCS-2-SWAPPED = UCS-2-INTERNAL with inverted endianness - */ - -static int -ucs2swapped_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - /* This function assumes that 'unsigned short' has exactly 16 bits. */ - if (sizeof(unsigned short) != 2) abort(); - - if (n >= 2) { - unsigned short x = *(const unsigned short *)s; - x = (x >> 8) | (x << 8); - if (x >= 0xd800 && x < 0xe000) { - return RET_ILSEQ; - } else { - *pwc = x; - return 2; - } - } - return RET_TOOFEW(0); -} - -static int -ucs2swapped_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - /* This function assumes that 'unsigned short' has exactly 16 bits. */ - if (sizeof(unsigned short) != 2) abort(); - - if (wc < 0x10000 && !(wc >= 0xd800 && wc < 0xe000)) { - if (n >= 2) { - unsigned short x = wc; - x = (x >> 8) | (x << 8); - *(unsigned short *)r = x; - return 2; - } else - return RET_TOOSMALL; - } else - return RET_ILUNI; -} diff --git a/lib/ucs4.h b/lib/ucs4.h deleted file mode 100644 index ae254c40..00000000 --- a/lib/ucs4.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2011, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * UCS-4 - */ - -/* Here we accept FFFE0000/0000FEFF marks as endianness indicators everywhere - in the stream, not just at the beginning. The default is big-endian. */ -/* The state is 0 if big-endian, 1 if little-endian. */ -static int -ucs4_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - state_t state = conv->istate; - int count = 0; - for (; n >= 4 && count <= RET_COUNT_MAX && count <= INT_MAX-4;) { - ucs4_t wc = (state - ? s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24) - : (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]); - if (wc == 0x0000feff) { - } else if (wc == 0xfffe0000u) { - state ^= 1; - } else if (wc <= 0x7fffffff) { - *pwc = wc; - conv->istate = state; - return count+4; - } else { - conv->istate = state; - return RET_SHIFT_ILSEQ(count); - } - s += 4; n -= 4; count += 4; - } - conv->istate = state; - return RET_TOOFEW(count); -} - -/* But we output UCS-4 in big-endian order, without byte-order mark. */ -static int -ucs4_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc <= 0x7fffffff) { - if (n >= 4) { - r[0] = (unsigned char) (wc >> 24); - r[1] = (unsigned char) (wc >> 16); - r[2] = (unsigned char) (wc >> 8); - r[3] = (unsigned char) wc; - return 4; - } else - return RET_TOOSMALL; - } else - return RET_ILUNI; -} diff --git a/lib/ucs4le.h b/lib/ucs4le.h deleted file mode 100644 index c089b42e..00000000 --- a/lib/ucs4le.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * UCS-4LE = UCS-4 little endian - */ - -static int -ucs4le_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - if (n >= 4) { - *pwc = s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24); - return 4; - } - return RET_TOOFEW(0); -} - -static int -ucs4le_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (n >= 4) { - r[0] = (unsigned char) wc; - r[1] = (unsigned char) (wc >> 8); - r[2] = (unsigned char) (wc >> 16); - r[3] = (unsigned char) (wc >> 24); - return 4; - } else - return RET_TOOSMALL; -} diff --git a/lib/ucs4swapped.h b/lib/ucs4swapped.h deleted file mode 100644 index 2c123c02..00000000 --- a/lib/ucs4swapped.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 1999-2000, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * UCS-4-SWAPPED = UCS-4-INTERNAL with inverted endianness - */ - -static int -ucs4swapped_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - /* This function assumes that 'unsigned int' has exactly 32 bits. */ - if (sizeof(unsigned int) != 4) abort(); - - if (n >= 4) { - unsigned int x = *(const unsigned int *)s; - x = (x >> 24) | ((x >> 8) & 0xff00) | ((x & 0xff00) << 8) | (x << 24); - *pwc = x; - return 4; - } - return RET_TOOFEW(0); -} - -static int -ucs4swapped_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - /* This function assumes that 'unsigned int' has exactly 32 bits. */ - if (sizeof(unsigned int) != 4) abort(); - - if (n >= 4) { - unsigned int x = wc; - x = (x >> 24) | ((x >> 8) & 0xff00) | ((x & 0xff00) << 8) | (x << 24); - *(unsigned int *)r = x; - return 4; - } else - return RET_TOOSMALL; -} diff --git a/lib/utf16.h b/lib/utf16.h deleted file mode 100644 index 5886bb9f..00000000 --- a/lib/utf16.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * UTF-16 - */ - -/* Specification: RFC 2781 */ - -/* Here we accept FFFE/FEFF marks as endianness indicators everywhere - in the stream, not just at the beginning. (This is contrary to what - RFC 2781 section 3.2 specifies, but it allows concatenation of byte - sequences to work flawlessly, while disagreeing with the RFC behaviour - only for strings containing U+FEFF characters, which is quite rare.) - The default is big-endian. */ -/* The state is 0 if big-endian, 1 if little-endian. */ -static int -utf16_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - state_t state = conv->istate; - int count = 0; - for (; n >= 2 && count <= RET_COUNT_MAX && count <= INT_MAX-2;) { - ucs4_t wc = (state ? s[0] + (s[1] << 8) : (s[0] << 8) + s[1]); - if (wc == 0xfeff) { - } else if (wc == 0xfffe) { - state ^= 1; - } else if (wc >= 0xd800 && wc < 0xdc00) { - if (n >= 4) { - ucs4_t wc2 = (state ? s[2] + (s[3] << 8) : (s[2] << 8) + s[3]); - if (!(wc2 >= 0xdc00 && wc2 < 0xe000)) - goto ilseq; - *pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00); - conv->istate = state; - return count+4; - } else - break; - } else if (wc >= 0xdc00 && wc < 0xe000) { - goto ilseq; - } else { - *pwc = wc; - conv->istate = state; - return count+2; - } - s += 2; n -= 2; count += 2; - } - conv->istate = state; - return RET_TOOFEW(count); - -ilseq: - conv->istate = state; - return RET_SHIFT_ILSEQ(count); -} - -/* We output UTF-16 in big-endian order, with byte-order mark. - See RFC 2781 section 3.3 for a rationale: Some document formats - mandate a BOM; the file concatenation issue is not so severe as - long as the above utf16_mbtowc function is used. */ -/* The state is 0 at the beginning, 1 after the BOM has been written. */ -static int -utf16_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc != 0xfffe && !(wc >= 0xd800 && wc < 0xe000)) { - int count = 0; - if (!conv->ostate) { - if (n >= 2) { - r[0] = 0xFE; - r[1] = 0xFF; - r += 2; n -= 2; count += 2; - } else - return RET_TOOSMALL; - } - if (wc < 0x10000) { - if (n >= 2) { - r[0] = (unsigned char) (wc >> 8); - r[1] = (unsigned char) wc; - conv->ostate = 1; - return count+2; - } else - return RET_TOOSMALL; - } - else if (wc < 0x110000) { - if (n >= 4) { - ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10); - ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff); - r[0] = (unsigned char) (wc1 >> 8); - r[1] = (unsigned char) wc1; - r[2] = (unsigned char) (wc2 >> 8); - r[3] = (unsigned char) wc2; - conv->ostate = 1; - return count+4; - } else - return RET_TOOSMALL; - } - } - return RET_ILUNI; -} diff --git a/lib/utf16be.h b/lib/utf16be.h deleted file mode 100644 index 1a73d3ab..00000000 --- a/lib/utf16be.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * UTF-16BE - */ - -/* Specification: RFC 2781 */ - -static int -utf16be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - int count = 0; - if (n >= 2) { - ucs4_t wc = (s[0] << 8) + s[1]; - if (wc >= 0xd800 && wc < 0xdc00) { - if (n >= 4) { - ucs4_t wc2 = (s[2] << 8) + s[3]; - if (!(wc2 >= 0xdc00 && wc2 < 0xe000)) - goto ilseq; - *pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00); - return count+4; - } - } else if (wc >= 0xdc00 && wc < 0xe000) { - goto ilseq; - } else { - *pwc = wc; - return count+2; - } - } - return RET_TOOFEW(count); - -ilseq: - return RET_SHIFT_ILSEQ(count); -} - -static int -utf16be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (!(wc >= 0xd800 && wc < 0xe000)) { - if (wc < 0x10000) { - if (n >= 2) { - r[0] = (unsigned char) (wc >> 8); - r[1] = (unsigned char) wc; - return 2; - } else - return RET_TOOSMALL; - } - else if (wc < 0x110000) { - if (n >= 4) { - ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10); - ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff); - r[0] = (unsigned char) (wc1 >> 8); - r[1] = (unsigned char) wc1; - r[2] = (unsigned char) (wc2 >> 8); - r[3] = (unsigned char) wc2; - return 4; - } else - return RET_TOOSMALL; - } - } - return RET_ILUNI; -} diff --git a/lib/utf16le.h b/lib/utf16le.h deleted file mode 100644 index 0b6810b0..00000000 --- a/lib/utf16le.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * UTF-16LE - */ - -/* Specification: RFC 2781 */ - -static int -utf16le_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - int count = 0; - if (n >= 2) { - ucs4_t wc = s[0] + (s[1] << 8); - if (wc >= 0xd800 && wc < 0xdc00) { - if (n >= 4) { - ucs4_t wc2 = s[2] + (s[3] << 8); - if (!(wc2 >= 0xdc00 && wc2 < 0xe000)) - goto ilseq; - *pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00); - return count+4; - } - } else if (wc >= 0xdc00 && wc < 0xe000) { - goto ilseq; - } else { - *pwc = wc; - return count+2; - } - } - return RET_TOOFEW(count); - -ilseq: - return RET_SHIFT_ILSEQ(count); -} - -static int -utf16le_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (!(wc >= 0xd800 && wc < 0xe000)) { - if (wc < 0x10000) { - if (n >= 2) { - r[0] = (unsigned char) wc; - r[1] = (unsigned char) (wc >> 8); - return 2; - } else - return RET_TOOSMALL; - } - else if (wc < 0x110000) { - if (n >= 4) { - ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10); - ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff); - r[0] = (unsigned char) wc1; - r[1] = (unsigned char) (wc1 >> 8); - r[2] = (unsigned char) wc2; - r[3] = (unsigned char) (wc2 >> 8); - return 4; - } else - return RET_TOOSMALL; - } - } - return RET_ILUNI; -} diff --git a/lib/utf32.h b/lib/utf32.h deleted file mode 100644 index 3a5215e9..00000000 --- a/lib/utf32.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2008, 2011, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * UTF-32 - */ - -/* Specification: Unicode 3.1 Standard Annex #19 */ - -/* Here we accept FFFE0000/0000FEFF marks as endianness indicators - everywhere in the stream, not just at the beginning. (This is contrary - to what #19 D36c specifies, but it allows concatenation of byte - sequences to work flawlessly, while disagreeing with #19 behaviour - only for strings containing U+FEFF characters, which is quite rare.) - The default is big-endian. */ -/* The state is 0 if big-endian, 1 if little-endian. */ -static int -utf32_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - state_t state = conv->istate; - int count = 0; - for (; n >= 4 && count <= RET_COUNT_MAX && count <= INT_MAX-4;) { - ucs4_t wc = (state - ? s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24) - : (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]); - if (wc == 0x0000feff) { - } else if (wc == 0xfffe0000u) { - state ^= 1; - } else { - if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) { - *pwc = wc; - conv->istate = state; - return count+4; - } else { - conv->istate = state; - return RET_SHIFT_ILSEQ(count); - } - } - s += 4; n -= 4; count += 4; - } - conv->istate = state; - return RET_TOOFEW(count); -} - -/* We output UTF-32 in big-endian order, with byte-order mark. */ -/* The state is 0 at the beginning, 1 after the BOM has been written. */ -static int -utf32_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) { - int count = 0; - if (!conv->ostate) { - if (n >= 4) { - r[0] = 0x00; - r[1] = 0x00; - r[2] = 0xFE; - r[3] = 0xFF; - r += 4; n -= 4; count += 4; - } else - return RET_TOOSMALL; - } - if (wc < 0x110000) { - if (n >= 4) { - r[0] = 0; - r[1] = (unsigned char) (wc >> 16); - r[2] = (unsigned char) (wc >> 8); - r[3] = (unsigned char) wc; - conv->ostate = 1; - return count+4; - } else - return RET_TOOSMALL; - } - } - return RET_ILUNI; -} diff --git a/lib/utf32be.h b/lib/utf32be.h deleted file mode 100644 index c498ca28..00000000 --- a/lib/utf32be.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 1999-2001, 2016 Free Software Foundation, Inc. - * This file is part of the cppp-reiconv library. - * - * The cppp-reiconv library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv library; see the file COPYING. - * If not, see . - */ - -/* - * UTF-32BE - */ - -/* Specification: Unicode 3.1 Standard Annex #19 */ - -static int -utf32be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n) -{ - if (n >= 4) { - ucs4_t wc = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]; - if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) { - *pwc = wc; - return 4; - } else - return RET_ILSEQ; - } - return RET_TOOFEW(0); -} - -static int -utf32be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n) -{ - if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) { - if (n >= 4) { - r[0] = 0; - r[1] = (unsigned char) (wc >> 16); - r[2] = (unsigned char) (wc >> 8); - r[3] = (unsigned char) wc; - return 4; - } else - return RET_TOOSMALL; - } - return RET_ILUNI; -} diff --git a/repo.json b/repo.json new file mode 100644 index 00000000..65657315 --- /dev/null +++ b/repo.json @@ -0,0 +1,18 @@ +{ + "name": "cppp-reiconv", + "maintainer": "ChenPi11 ", + "version": "3.0.0", + "description": "C+++ character set conversion library.", + "license": "LGPL-3.0", + "hooks": { + "build": { + "run": ".rubisco/build.yml" + }, + "dist": { + "run": ".rubisco/dist.yml" + }, + "test": { + "run": ".rubisco/test.yml" + } + } +} diff --git a/setup.cmd b/setup.cmd deleted file mode 100644 index 21bbdf8a..00000000 --- a/setup.cmd +++ /dev/null @@ -1,42 +0,0 @@ -@echo off -rem Setup a repository during individual development. -rem -rem This script requires git program in the PATH. - -rem Copyright (C) 2023 The C++ Plus Project. -rem -rem This program is free software: you can redistribute it and/or modify -rem it under the terms of the GNU Lesser General Public License as published by -rem the Free Software Foundation; either version 3 of the License, or -rem (at your option) any later version. -rem -rem This program is distributed in the hope that it will be useful, -rem but WITHOUT ANY WARRANTY; without even the implied warranty of -rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -rem GNU Lesser General Public License for more details. -rem -rem You should have received a copy of the GNU Lesser General Public License -rem along with this program. If not, see . - -rem Usage: setup.cmd - -if exist .\build-aux ( - echo Success: '.\build-aux' is exists, please don't remove it, and you can develop this package normally. - goto QUIT -) - -if exist ..\build-aux ( - echo Success: '..\build-aux' is exists, please don't remove it, and you can develop this package normally. - goto QUIT -) - -echo Notice: '..\build-aux' for C++ Plus are not exists, cloning it...... -git clone https://github.com/cppp-project/build-aux -if %errorlevel%==0 ( - echo Success: '.\build-aux' cloned successfully, please don't remove it, and you can develop this package normally. -) else ( - echo Error: .\build-aux' cloned failed, you can clone it by yourself or copy it from C++ Plus release source package. - echo Notice: try to run 'git clone https://github.com/cppp-project/build-aux'. -) - -:QUIT diff --git a/setup.sh b/setup.sh deleted file mode 100755 index a6b59979..00000000 --- a/setup.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env sh -# Setup a repository during individual development. -# -# This script requires git program in the PATH. - -# Copyright (C) 2023 The C++ Plus Project. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see . - -# Usage: ./setup.sh -# - -# Usage: text_out [color_id] [level] [msg] -text_out() -{ - echo "\033[$1m$2: $3 \033[0m" -} - -# Usage: execute [command] -execute() -{ - text_out 94 "$1" - $1 - return $? -} - -if test -d './build-aux' -then - text_out 32 "Success" "'./build-aux' is exists, please don't remove it, and you can develop this package normally." - exit 0 -fi - -if test -d '../build-aux' -then - text_out 32 "Success" "'../build-aux' is exists, please don't remove it, and you can develop this package normally." - exit 0 -fi - -text_out 0 "Notice" "'../build-aux' for C++ Plus are not exists, cloning it......" -execute "git clone https://github.com/cppp-project/build-aux" -if [ $? -eq 0 ] -then - text_out 32 "Success" "'./build-aux' cloned successfully, please don't remove it, and you can develop this package normally." -else - text_out 31 "Error" "'./build-aux' cloned failed, you can clone it by yourself or copy it from C++ Plus release source package." - text_out 0 "Notice" "try to run 'git clone https://github.com/cppp-project/build-aux'. " -fi diff --git a/tests/buffer.hpp b/tests/buffer.hpp new file mode 100644 index 00000000..d1a87aa3 --- /dev/null +++ b/tests/buffer.hpp @@ -0,0 +1,237 @@ +/** + * @file buffer.hpp + * @brief A simple buffer class. + * @author ChenPi11 + * @copyright Copyright (C) 2024 The C++ Plus Project + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#pragma once + +#include +#include +#include +#include + +#include "output.hpp" +#include + +class Buffer +{ + private: + Buffer(char *buffer, std::size_t size, const std::string_view id) : id(id), buffer(buffer), size(size) + { + } + + public: + std::string id; + char *buffer; + std::size_t size; + + Buffer() : id(""), buffer(nullptr), size(0) + { + } + + Buffer(Buffer &&other) : id(other.id), buffer(other.buffer), size(other.size) + { + other.buffer = nullptr; + other.size = 0; + other.id = ""; + } + + Buffer(const Buffer &source) : Buffer(source.copy()) + { + } + + Buffer(const std::string_view source, const std::string_view id = "") + { + size = source.size(); + buffer = static_cast(std::malloc(size)); + if (buffer == nullptr) + { + error("malloc", "Unable to allocate buffer."); + } + std::memcpy(buffer, source.data(), size); + this->id = id; + } + + void dump(const std::filesystem::path &output_file_path) const + { + print_stderr("DEBUG: Dumping buffer {} to file {}.\n", colorize(id, CONTROL_UNDERLINE), + colorize(output_file_path.string(), CONTROL_UNDERLINE)); + std::ofstream output_file{output_file_path, std::ios::binary | std::ios::trunc}; + if (!output_file.good()) + { + error(output_file_path.string(), "Unable to open output file."); + } + + output_file.write(buffer, size); + output_file.close(); + } + + constexpr char *data() noexcept + { + return buffer; + } + + constexpr const char *data() const noexcept + { + return buffer; + } + + Buffer &operator=(Buffer &&other) noexcept + { + reset(other.buffer, other.size, other.id); + other.buffer = nullptr; + other.reset(); + return *this; + } + + Buffer &operator=(const Buffer &source) + { + Buffer copy = source.copy(); + reset(copy.buffer); + copy.reset(); + return *this; + } + + Buffer &reset(char *new_buffer = nullptr, const std::size_t new_size = 0, + const std::string_view new_id = "") noexcept + { + std::free(buffer); + buffer = new_buffer; + size = new_size; + id = new_id; + return *this; + } + + Buffer copy() const + { + Buffer res = Buffer::allocate(size, id); + std::memcpy(res.buffer, buffer, size); + return std::move(res); + } + + constexpr operator bool() const + { + return buffer != nullptr; + } + + constexpr bool operator!() const + { + return !buffer; + } + + constexpr bool operator==(const Buffer &other) const + { + // Check if the buffer is the same, but ignore CR and LF. + std::size_t i = 0, j = 0; + while (i < size || j < other.size) + { + i = std::min(i, size); + j = std::min(j, other.size); + if (buffer[i] == '\r' || buffer[i] == '\n') + { + i++; + continue; + } + if (other.buffer[j] == '\r' || other.buffer[j] == '\n') + { + j++; + continue; + } + if (buffer[i] != other.buffer[j]) + { + return false; + } + i++; + j++; + } + return true; + } + + constexpr bool operator!=(const Buffer &other) const + { + return !(*this == other); + } + + void compare_assert(const Buffer &other) const + { + if (*this != other) + { + std::string str_cwd = std::filesystem::current_path().string(); + print_stderr("DEBUG: Dumping 'this.dmp' and 'other.dmp' into '{}' ...\n\tThis: {}\n\tOther: {}\n", + colorize(str_cwd, CONTROL_UNDERLINE), colorize(id, CONTROL_UNDERLINE), + colorize(other.id, CONTROL_UNDERLINE)); + dump(std::filesystem::path("this.dmp")); + other.dump(std::filesystem::path("other.dmp")); + error("compare_assert", "The data is different."); + } + success("compare_assert", "The data is the same."); + } + + void write_stream(std::ostream &stream, bool newline = false, bool flush = true) const + { + stream.write(buffer, size); + if (newline) + { + stream.write("\n", 1); + } + if (flush) + { + stream.flush(); + } + if (!stream.good()) + { + error("write_stream", "Unable to write to stream."); + } + } + + ~Buffer() + { + reset(); + } + + static Buffer allocate(const std::size_t size, const std::string_view id) + { + char *c_buffer = static_cast(std::malloc(size)); + std::memset(c_buffer, 0, size); + if (c_buffer == nullptr) + { + error("malloc", "Unable to allocate buffer."); + } + return Buffer(c_buffer, size, id); + } + + static Buffer read_from_file(const std::filesystem::path &input_file_path, bool binary = true) + { + std::ifstream input_file{input_file_path, binary ? std::ios::binary : std::ios::in}; + if (!input_file.good()) + { + error(input_file_path.string(), "Unable to open file " + input_file_path.string()); + } + + std::size_t size = std::filesystem::file_size(input_file_path); + + Buffer buffer = Buffer::allocate(size, input_file_path.string()); + input_file.read(buffer.buffer, size); + input_file.close(); + return std::move(buffer); + } +}; diff --git a/tests/check-encoding.cpp b/tests/check-encoding.cpp new file mode 100644 index 00000000..c8792129 --- /dev/null +++ b/tests/check-encoding.cpp @@ -0,0 +1,58 @@ +/** + * @file check-encoding.hpp + * @brief Simple check of a Encoding class. + * @author ChenPi11 + * @copyright Copyright (C) 2024 The C++ Plus Project + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#include + +#include +#include + +#include "output.hpp" + +#define COMPARE(name, codepage, index) Encoding(name) == Encoding(codepage) && Encoding(name) == Encoding(index) +#define ASSERT(name, codepage, index) \ + if (!(COMPARE(name, codepage, index))) \ + { \ + error("check-encoding", print_string("name={}, codepage={}, index={} are not equal.", name, \ + std::to_string(codepage), std::to_string((int)index))); \ + } + +int main() +{ + using namespace reiconv; + + ASSERT("ASCII", 367, Encodings::ASCII); + ASSERT("UTF-8", 65001, Encodings::UTF8); + ASSERT("CP936", 936, Encodings::CP936); + ASSERT("ISO-8859-1", 28591, Encodings::ISO8859_1); + ASSERT("MSEE", 1250, Encodings::MSEE); + ASSERT("IBM-850", 850, Encodings::IBM850); + ASSERT("MacRoman", 10000, Encodings::MACINTOSH); + ASSERT("MacRoman", 10000, Encodings::MAC_ROMAN); + ASSERT("PT154", 154, Encodings::PT154); + ASSERT("IBM-856", 856, Encodings::IBM856); + ASSERT("csPC8codepage437", 437, Encodings::CP437); + ASSERT("CP0037", 37, Encodings::EBCDIC_037); + + return EXIT_SUCCESS; +} diff --git a/tests/check-stateful.cpp b/tests/check-stateful.cpp index 1d92b784..30acc4cc 100644 --- a/tests/check-stateful.cpp +++ b/tests/check-stateful.cpp @@ -1,5 +1,10 @@ +/** + * @file check-stateful.hpp + * @brief Simple check of a stateful encoding. + * @author ChenPi11 + * @copyright Copyright (C) 2024 The C++ Plus Project + */ /* - * Copyright (C) 2023 The C++ Plus Project. * This file is part of the cppp-reiconv Library. * * The cppp-reiconv Library is free software; you can redistribute it @@ -13,64 +18,54 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv Library; see the file COPYING. + * License along with the cppp-reiconv Library; see the file LICENSE. * If not, see . */ -/* - Simple check of a stateful encoding. -*/ - -#include +#include #include +#include -#include "file_utils.hpp" +#include "buffer.hpp" +#include "cppp/reiconv.hpp" #include "reiconv-test.hpp" +#include "utils.hpp" +std::filesystem::path datadir; +std::string charset; -std::string replace(const std::string& src, const std::string& from, const std::string& to) -{ - std::string result = src; - size_t pos = 0; - - while ((pos = result.find(from, pos)) != std::string::npos) - { - result.replace(pos, from.length(), to); - pos += to.length(); - } - - return result; -} - -std::string srcdir, charset; - -// Usage: check-stateful SRCDIR CHARSET -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { - if(argc < 3) + if (argc != 3) { - std::cerr << "Usage: check-stateful SRCDIR CHARSET\n"; - return 1; + print_stderr("Usage: check-stateful DATADIR CHARSET\n"); + return EXIT_FAILURE; } - srcdir = argv[1]; + datadir = argv[1]; charset = argv[2]; std::string charsetf = replace(charset, ":", "-"); - if(file_exists(srcdir + "/" + charsetf + "-snippet.alt")) + std::filesystem::path snippet_alt_file { datadir / (charsetf + "-snippet.alt") }; + std::filesystem::path utf8_snippet_file { datadir / (charsetf + "-snippet.UTF-8") }; + + Buffer res, snippet_data; + if (std::filesystem::exists(snippet_alt_file)) { - test::iconv::main(charset, "UTF-8", srcdir + "/" + charsetf + "-snippet.alt", "tmp-snippet"); - assert_compare_file(srcdir + "/" + charsetf + "-snippet.UTF-8", "tmp-snippet"); + res = reiconv_test(charset, reiconv::Encodings::UTF8, snippet_alt_file); + snippet_data = Buffer::read_from_file(utf8_snippet_file); + res.compare_assert(snippet_data); } - test::iconv::main(charset, "UTF-8", srcdir + "/" + charsetf + "-snippet", "tmp-snippet"); - assert_compare_file(srcdir + "/" + charsetf + "-snippet.UTF-8", "tmp-snippet"); - - test::iconv::main("UTF-8", charset, srcdir + "/" + charsetf + "-snippet.UTF-8", "tmp-snippet"); - assert_compare_file(srcdir + "/" + charsetf + "-snippet", "tmp-snippet"); + res = reiconv_test(charset, reiconv::Encodings::UTF8, datadir / (charsetf + "-snippet")); + snippet_data = Buffer::read_from_file(utf8_snippet_file); + res.compare_assert(snippet_data); - remove_file("tmp-snippet"); + res = reiconv_test(reiconv::Encodings::UTF8, charset, utf8_snippet_file); + snippet_data = Buffer::read_from_file(datadir / (charsetf + "-snippet")); + res.compare_assert(snippet_data); success("check-stateful", charset + " OK."); - return 0; + + return EXIT_SUCCESS; } diff --git a/tests/check-stateless.cpp b/tests/check-stateless.cpp index c3735869..b8d78f5d 100644 --- a/tests/check-stateless.cpp +++ b/tests/check-stateless.cpp @@ -1,5 +1,10 @@ +/** + * @file check-stateless.hpp + * @brief Completely check of a stateless encoding. + * @author ChenPi11 + * @copyright Copyright (C) 2024 The C++ Plus Project + */ /* - * Copyright (C) 2023 The C++ Plus Project. * This file is part of the cppp-reiconv Library. * * The cppp-reiconv Library is free software; you can redistribute it @@ -13,115 +18,121 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv Library; see the file COPYING. + * License along with the cppp-reiconv Library; see the file LICENSE. * If not, see . */ -/* - Complete check of a stateless encoding. -*/ - -#include +#include #include +#include #include -#include "file_utils.hpp" +#include "output.hpp" +#include "sort.hpp" #include "table-from.hpp" #include "table-to.hpp" -#include "sort.hpp" #include "uniq-u.hpp" +#include "utils.hpp" -std::string replace(const std::string& src, const std::string& from, const std::string& to) +void check2_pre_process(const std::filesystem::path &input_file_path, const std::filesystem::path &output_file_path) { - std::string result = src; - size_t pos = 0; - - while ((pos = result.find(from, pos)) != std::string::npos) + std::ifstream input_file {input_file_path}; + if (!input_file.good()) { - result.replace(pos, from.length(), to); - pos += to.length(); + error(input_file_path.string(), "Unable to open input file."); + } + std::ofstream output_file {output_file_path, std::ios::trunc}; + if (!output_file.good()) + { + error(output_file_path.string(), "Unable to open output file."); } - return result; -} - -std::string srcdir, charset; + std::string line; + std::regex pattern {"\t.* 0x"}; -void check2_pre_process(const std::string& input_file_path, const std::string& output_file_path) -{ - std::ifstream input_file(input_file_path); - std::ofstream output_file(output_file_path, std::ios::trunc); - - if (input_file.is_open() && output_file.is_open()) + while (std::getline(input_file, line)) { - std::string line; - std::regex pattern("\t.* 0x"); - - while (std::getline(input_file, line)) + if (!std::regex_search(line, pattern)) { - if (!std::regex_search(line, pattern)) - { - output_file << line << '\n'; - } + write_stream(output_file, line + "\n"); } - - input_file.close(); - output_file.close(); - } - else - { - error(input_file_path + " " + output_file_path, "Unable to open file."); } + + input_file.close(); + output_file.close(); } -// Usage: check-stateful SRCDIR CHARSET -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { - if(argc < 3) + std::ios::sync_with_stdio(false); + if (argc != 3 && argc != 4) { - std::cerr << "Usage: check-stateful SRCDIR CHARSET\n"; - return 1; + print_stderr("Usage: check-stateless DATADIR CHARSET [--debug]\n"); + return EXIT_FAILURE; } - srcdir = argv[1]; - charset = argv[2]; + bool debug = false; + if (argc == 4) + { + debug = true; + print_stderr("Debug mode enabled.\n"); + } + std::filesystem::path srcdir = argv[1]; + std::string charset = argv[2]; // Charset, modified for use in filenames. std::string charsetf = replace(charset, ":", "-"); // Iconv in one direction. - test::table_from("tmp-" + charsetf + ".TXT", charset); + std::filesystem::path table_from_file = "tmp-" + charsetf + ".TXT"; + table_from(table_from_file, charset); // Iconv in the other direction. - test::table_to("tmp-" + charsetf + ".INVERSE.UNSORTED.TXT", charset); - sort_file("tmp-" + charsetf + ".INVERSE.UNSORTED.TXT", "tmp-" + charsetf + ".INVERSE.TXT"); + std::filesystem::path table_to_file_unsorted = "tmp-" + charsetf + ".INVERSE.UNSORTED.TXT"; + std::filesystem::path table_to_file = "tmp-" + charsetf + ".INVERSE.TXT"; + table_to(table_to_file_unsorted, charset); + sort_file(table_to_file_unsorted, table_to_file); - // Check 1: charmap and iconv forward should be identical. - assert_compare_file(srcdir + "/" + charsetf + ".TXT", "tmp-" + charsetf + ".TXT"); + // Check 1: Charmap and iconv forward should be identical. + std::filesystem::path standard_file = srcdir / (charsetf + ".TXT"); + compare_files(standard_file, table_from_file); // Check 2: the difference between the charmap and iconv backward. - check2_pre_process(srcdir + "/" + charsetf + ".TXT", "tmp-noprecomposed-" + charsetf + ".TXT"); - - if(file_exists(srcdir + "/" + charsetf + ".IRREVERSIBLE.TXT")) + std::filesystem::path noprecomposed_tmp_file = "tmp-noprecomposed-" + charsetf + ".TXT"; + check2_pre_process(standard_file, noprecomposed_tmp_file); + + std::filesystem::path irreversible_file = srcdir / (charsetf + ".IRREVERSIBLE.TXT"); + std::filesystem::path orig_inverse_unsorted_file = "tmp-orig-" + charsetf + ".INVERSE.UNSORTED.TXT"; + std::filesystem::path orig_inverse_ununiqued_file = "tmp-orig-" + charsetf + ".INVERSE.UNUNIQUED.TXT"; + std::filesystem::path orig_inverse_file = "tmp-orig-" + charsetf + ".INVERSE.TXT"; + if (std::filesystem::exists(irreversible_file)) { - std::vector files = { "tmp-noprecomposed-" + charsetf + ".TXT", srcdir + "/" + charsetf + ".IRREVERSIBLE.TXT" }; - merge_files(files, "tmp-orig-" + charsetf + ".INVERSE.UNSORTED.TXT"); - sort_file("tmp-orig-" + charsetf + ".INVERSE.UNSORTED.TXT", "tmp-orig-" + charsetf + ".INVERSE.UNUNIQUED.TXT"); - uniq_u("tmp-orig-" + charsetf + ".INVERSE.UNUNIQUED.TXT", "tmp-orig-" + charsetf + ".INVERSE.TXT"); + std::vector files = {noprecomposed_tmp_file, irreversible_file}; + merge_files(files, orig_inverse_unsorted_file); + sort_file(orig_inverse_unsorted_file, orig_inverse_ununiqued_file); + uniq_u(orig_inverse_ununiqued_file, orig_inverse_file); } else { - copy_file("tmp-noprecomposed-" + charsetf + ".TXT", "tmp-orig-" + charsetf + ".INVERSE.TXT"); + if (std::filesystem::exists(orig_inverse_file)) + { + std::filesystem::remove(orig_inverse_file); + } + std::filesystem::copy_file(noprecomposed_tmp_file, orig_inverse_file); } - assert_compare_file("tmp-orig-" + charsetf + ".INVERSE.TXT", "tmp-" + charsetf + ".INVERSE.TXT"); + compare_files(orig_inverse_file, table_to_file); - remove_file("tmp-" + charsetf + ".TXT"); - remove_file("tmp-" + charsetf + ".INVERSE.UNSORTED.TXT"); - remove_file("tmp-" + charsetf + ".INVERSE.TXT"); - remove_file("tmp-orig-" + charsetf + ".INVERSE.UNSORTED.TXT"); - remove_file("tmp-orig-" + charsetf + ".INVERSE.UNUNIQUED.TXT"); - remove_file("tmp-orig-" + charsetf + ".INVERSE.TXT"); - remove_file("tmp-noprecomposed-" + charsetf + ".TXT"); + if (!debug) + { + std::filesystem::remove(table_from_file); + std::filesystem::remove(table_to_file_unsorted); + std::filesystem::remove(table_to_file); + std::filesystem::remove(orig_inverse_unsorted_file); + std::filesystem::remove(orig_inverse_ununiqued_file); + std::filesystem::remove(orig_inverse_file); + std::filesystem::remove(noprecomposed_tmp_file); + } success("check-stateless", charset + " OK."); - return 0; + + return EXIT_SUCCESS; } diff --git a/tests/data-generator.cpp b/tests/data-generator.cpp index a5b84a72..6fc383d0 100644 --- a/tests/data-generator.cpp +++ b/tests/data-generator.cpp @@ -1,48 +1,48 @@ -/* Copyright (C) 2005, 2012 Free Software Foundation, Inc. - This file is part of the cppp-reiconv library. - - The cppp-reiconv library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 3 - of the License, or (at your option) any later version. - - The cppp-reiconv library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the cppp-reiconv library; see the file COPYING. - If not, see . */ - -/* Creates the beyond-BMP part of the GB18030.TXT reference table. */ -/* Or creates the UTF-8.TXT reference table. */ - -/* Usage: ./data_generator [utf-8 | gb18030:2005 gb18030:2022] datadir stdout */ - -#include -#include -#include - -#include "throw_error.hpp" - +/** + * @file reiconv-test.hpp + * @brief Creates the beyond-BMP part of the GB18030.TXT reference table. + * Or creates the UTF-8.TXT reference table. + * @author ChenPi11 + * @copyright Copyright (C) 2005, 2012 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/** + * This file is part of the cppp-reiconv library. + * + * The cppp-reiconv library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv library; see the file LICENSE. + * If not, see . */ + +#include +#include +#include + +/** + * @brief Generates the GB18030 reference table. + */ void gengb18030z() { - int i1, i2, i3, i4, uc; + int uc = 0x10000; - uc = 0x10000; - for (i1 = 0x90; i1 <= 0xe3; i1++) + for (int i1 = 0x90; i1 <= 0xe3; i1++) { - for (i2 = 0x30; i2 <= 0x39; i2++) + for (int i2 = 0x30; i2 <= 0x39; i2++) { - for (i3 = 0x81; i3 <= 0xfe; i3++) + for (int i3 = 0x81; i3 <= 0xfe; i3++) { - for (i4 = 0x30; i4 <= 0x39; i4++) + for (int i4 = 0x30; i4 <= 0x39; i4++) { - - char buffer[32] {}; - sprintf(buffer, "0x%02X%02X%02X%02X\t0x%X\n", i1, i2, i3, i4, uc); - fwrite(buffer, sizeof(char), strlen(buffer), stdout); + std::printf("0x%02X%02X%02X%02X\t0x%X\n", i1, i2, i3, i4, uc); uc++; if (uc == 0x110000) { @@ -52,80 +52,61 @@ void gengb18030z() } } } - done: +done: - if (ferror(stdout) || fclose(stdout)) - { - error("gengb18030z", "IO Error."); - } - fflush(stdout); + std::fflush(stdout); } +/** + * @brief Generates the UTF-8 reference table. + */ void genutf8() { int i1, i2, i3; /* Range 0x0000..0x007f */ - for (i1 = 0; i1 < 0x80; i1++) + for (int i1 = 0; i1 < 0x80; i1++) { - char buffer[32] {}; - sprintf(buffer, "0x%02X\t0x%04X\n", i1, i1); - fwrite(buffer, sizeof(char), strlen(buffer), stdout); + std::printf("0x%02X\t0x%04X\n", i1, i1); } + /* Range 0x0080..0x07ff */ for (i1 = 2; i1 < 32; i1++) { for (i2 = 0; i2 < 64; i2++) { - char buffer[32] {}; - sprintf(buffer, "0x%02X%02X\t0x%04X\n", 0xc0+i1, 0x80+i2, (i1 << 6) + i2); - fwrite(buffer, sizeof(char), strlen(buffer), stdout); + std::printf("0x%02X%02X\t0x%04X\n", 0xc0 + i1, 0x80 + i2, (i1 << 6) + i2); } } /* Range 0x0800..0xffff, except 0xd800..0xdfff */ for (i1 = 0; i1 < 16; i1++) - for (i2 = (i1==0 ? 32 : 0); i2 < 64; i2++) + for (i2 = (i1 == 0 ? 32 : 0); i2 < 64; i2++) { for (i3 = 0; i3 < 64; i3++) { int u = (i1 << 12) + (i2 << 6) + i3; if (!(u >= 0xd800 && u < 0xe000)) { - char buffer[32] {}; - sprintf(buffer, "0x%02X%02X%02X\t0x%04X\n", 0xe0 + i1, 0x80 + i2, 0x80 + i3, u); - fwrite(buffer, sizeof(char), strlen(buffer), stdout); + std::printf("0x%02X%02X%02X\t0x%04X\n", 0xe0 + i1, 0x80 + i2, 0x80 + i3, u); } } } - - if (ferror(stdout) || fclose(stdout)) - { - error("genutf8", "IO Error."); - } - fflush(stdout); } -int main (int argc, char *argv[]) +int main(int argc, char *argv[]) { - if (argc < 2) + if (argc != 2) { - fprintf(stderr, "Usage: %s [utf-8 | gb18030z]\n", argv[0]); - return 1; + std::fprintf(stderr, "Usage: %s [utf-8 | gb18030z]\n", argv[0]); + return EXIT_FAILURE; } - if (strcmp(argv[1], "utf-8") == 0) + if (std::string(argv[1]) == "utf-8") { genutf8(); - } - else if (strcmp(argv[1], "gb18030z") == 0) - { - gengb18030z(); - } - else - { - fprintf(stderr, "Usage: %s [utf-8 | gb18030z]\n", argv[0]); + return EXIT_SUCCESS; } - fclose(stdout); - return 0; + gengb18030z(); + return EXIT_SUCCESS; } diff --git a/tests/file_utils.hpp b/tests/file_utils.hpp deleted file mode 100644 index 5921e674..00000000 --- a/tests/file_utils.hpp +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (C) 2023 The C++ Plus Project. - * This file is part of the cppp-reiconv Library. - * - * The cppp-reiconv Library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv Library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv Library; see the file COPYING. - * If not, see . - */ - -/* - File operations utils for tests. -*/ - -#ifndef _FILE_UTILS_HPP -#define _FILE_UTILS_HPP - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) || defined(_WIN64) - #include -#else - #include -#endif - -#include "throw_error.hpp" - - - -// Compare 2 files difference but ignore CR. -void assert_compare_file(const std::string& path1, const std::string& path2) -{ - std::ifstream file1(path1, std::ios::binary); - if (!file1.is_open()) - { - error(path1, path1 + " " + strerror(errno)); - } - std::ifstream file2(path2, std::ios::binary); - if (!file2.is_open()) - { - error(path2, path2 + " " + strerror(errno)); - } - - std::cerr << "Comparing " << path1 << " and " << path2 << " ..." << std::endl; - - char file1_c; - char file2_c; - size_t read_seek = 0; - - while(1) - { - ++read_seek; - - if(file1.get(file1_c).eof()) { file1_c = EOF; } - if(file1_c == '\r') { continue; } - - if(file2.get(file2_c).eof()) { file2_c = EOF; } - if(file2_c == '\r') { file1.unget(); continue; } - - if(file1_c != file2_c) - { - errno = 0; - error("assert_compare_file", "Files are not equal at " + std::to_string(read_seek) + " byte."); - } - - if(file1_c == EOF && file2_c == EOF) { break; } - - } - - success("assert_compare_file", "Files are equal."); - -} - - -// Get file size. -long long get_file_size(const std::string& file_name) -{ - const char* filename = file_name.c_str(); - long long file_size = -1; - -#if defined(_WIN32) || defined(_WIN64) - WIN32_FILE_ATTRIBUTE_DATA fileInfo; - if (GetFileAttributesEx(filename, GetFileExInfoStandard, &fileInfo)) { - file_size = ((long long)fileInfo.nFileSizeHigh << 32) | fileInfo.nFileSizeLow; - } -#else - struct stat st; - if (stat(filename, &st) == 0) { - file_size = st.st_size; - } -#endif - return file_size; -} - - -/* This code is not optimal, only for test. */ -// Read all data in a file. -std::vector read_all(const std::string& input_file_path) -{ - std::ifstream input_file(input_file_path); - if (!input_file.is_open()) - { - error(input_file_path, "Unable to open input file."); - } - - size_t size = get_file_size(input_file_path.c_str()); - char* buffer = new char[size]; - input_file.read(buffer, size); - - input_file.close(); - - return std::vector(buffer, buffer + size); -} - -// Check if a file exists. -bool file_exists(const std::string& file_name) -{ - std::ifstream file(file_name); - bool result = file.good(); - file.close(); - return result; -} - -// Remove file. -bool remove_file(const std::string& file_name) -{ - if (std::remove(file_name.c_str()) == 0) - { - return true; - } - return false; -} - - -// Merge files. -void merge_files(const std::vector& files, const std::string& output_file_path) -{ - std::ofstream output_file(output_file_path, std::ios::trunc); - - if (!output_file.is_open()) - { - error(output_file_path, "Unable to open output file."); - } - - for (const std::string& file : files) - { - std::ifstream input_file(file); - - if (!input_file.is_open()) - { - error(file, "Unable to open input file."); - } - output_file << input_file.rdbuf() << std::endl; - input_file.close(); - } - - output_file.close(); -} - -// Copy file. -void copy_file(const std::string& from, const std::string& to) -{ - std::ifstream input_file(from, std::ios::binary); - std::ofstream output_file(to, std::ios::binary | std::ios::trunc); - - if (input_file.is_open() && output_file.is_open()) - { - output_file << input_file.rdbuf(); - input_file.close(); - output_file.close(); - } - else - { - error(from + " " + to, "Unable to open file."); - } -} - -// Copy file to a stream. -void cat(const std::string& input_file_path, FILE* dstfile) -{ - FILE* srcfile; - char buffer[1024]; - size_t len = 0; - srcfile = fopen(input_file_path.c_str(), "r"); - if (srcfile == NULL) - { - error(input_file_path, "Error opening source file"); - } - while ((len = fread(buffer, 1, sizeof(buffer), srcfile)) > 0) - { - fwrite(buffer, 1, len, dstfile); - } - fclose(srcfile); -} - -// Move file. -void mv(const std::string& from, const std::string& to) -{ - if (rename(from.c_str(), to.c_str()) != 0) - { - error(from + " " + to, "Unable to move file."); - } -} - -#endif diff --git a/tests/output.hpp b/tests/output.hpp new file mode 100644 index 00000000..3ceab33d --- /dev/null +++ b/tests/output.hpp @@ -0,0 +1,145 @@ +/** + * @file output.hpp + * @brief Output utils. + * @author ChenPi11 + * @copyright Copyright (C) 2024 The C++ Plus Project + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#pragma once + +#include +#include +#include +#include + +enum +{ + NOCONTROL = 0b000000000, + COLOR_RED = 0b000000001, + COLOR_GREEN = 0b000000010, + COLOR_YELLOW = 0b000000100, + COLOR_BLUE = 0b000001000, + COLOR_MAGENTA = 0b000010000, + COLOR_CYAN = 0b000100000, + COLOR_WHITE = 0b001000000, + CONTROL_BOLD = 0b010000000, + CONTROL_UNDERLINE = 0b100000000, +}; + +inline std::string colorize(const std::string &str, int control, bool reset = true) +{ + if (control & NOCONTROL) + { + return str; + } + + std::string color_code; + if (control & COLOR_RED) + { + color_code = "\033[31m"; + } + else if (control & COLOR_GREEN) + { + color_code = "\033[32m"; + } + else if (control & COLOR_YELLOW) + { + color_code = "\033[33m"; + } + else if (control & COLOR_BLUE) + { + color_code = "\033[34m"; + } + else if (control & COLOR_MAGENTA) + { + color_code = "\033[35m"; + } + else if (control & COLOR_CYAN) + { + color_code = "\033[36m"; + } + else if (control & COLOR_WHITE) + { + color_code = "\033[37m"; + } + + std::string control_code; + if (control & CONTROL_BOLD) + { + control_code = "\033[1m"; + } + if (control & CONTROL_UNDERLINE) + { + control_code = "\033[4m"; + } + + return color_code + control_code + str + (reset ? "\033[0m" : ""); +} + +template inline std::string print_string(const std::string &format, Args... args) +{ + std::initializer_list args_ = {args...}; + std::string str = format; + for (const auto &arg : args_) + { + size_t pos = 0; + if ((pos = str.find_first_of("{}", pos)) != std::string::npos) + { + str.replace(pos, 2, arg); + } + } + return str; +} + +template inline void print_stdout(const std::string &format, Args... args) +{ + std::string str = print_string(format, args...); + std::puts(str.c_str()); +} + +template inline void print_stderr(const std::string &format, Args... args) +{ + std::string str = print_string(format, args...); + std::fputs(str.c_str(), stderr); +} + +inline void error(const std::string &operation, const std::string &msg, + const std::source_location location = std::source_location::current()) +{ + print_stderr(colorize("", COLOR_RED, false)); + if (errno) + { + std::perror(operation.c_str()); + } + else + { + print_stderr("{}: ", operation); + } + std::string file_info = std::string(location.file_name()) + ":" + std::to_string(location.line()); + print_stderr(msg); + print_stderr("\n\tAt {}", colorize(file_info, CONTROL_UNDERLINE)); + + exit(EXIT_FAILURE); +} + +inline void success(const std::string &operation, const std::string &msg) +{ + print_stdout(colorize("{}: {}", COLOR_GREEN), operation, msg); +} diff --git a/tests/reiconv-test.hpp b/tests/reiconv-test.hpp index c49f9d97..a40ee263 100644 --- a/tests/reiconv-test.hpp +++ b/tests/reiconv-test.hpp @@ -1,5 +1,10 @@ +/** + * @file reiconv-test.hpp + * @brief Conversion test. + * @author ChenPi11 + * @copyright Copyright (C) 2024 The C++ Plus Project + */ /* - * Copyright (C) 2023 The C++ Plus Project. * This file is part of the cppp-reiconv Library. * * The cppp-reiconv Library is free software; you can redistribute it @@ -13,51 +18,22 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv Library; see the file COPYING. + * License along with the cppp-reiconv Library; see the file LICENSE. * If not, see . */ -#ifndef _REICONV_TEST_HPP -#define _REICONV_TEST_HPP +#pragma once #include -#include "file_utils.hpp" - -#include -#include -#include -#include -#include -#include - -#include "throw_error.hpp" +#include -using namespace cppp::base::reiconv; +#include "buffer.hpp" -namespace test +inline Buffer reiconv_test(reiconv::Encoding from, reiconv::Encoding to, const std::filesystem::path &input_file_path) { - namespace iconv - { - void main(const std::string& from, const std::string& to, const std::string& input_file_path, const std::string& output_file_path) - { - char* res = NULL; - size_t len = 0; - - FILE* src = fopen(input_file_path.c_str(), "rb"); - size_t srclen = get_file_size(input_file_path.c_str()); - char* s = (char*)malloc(srclen); - fread(s, 1, srclen, src); - std::cout << "SRCLEN:" << srclen << "\n"; - fclose(src); - cppp::base::reiconv::iconv_string(to.c_str(), from.c_str(), s, s+srclen, &res, &len); - - FILE* out = fopen(output_file_path.c_str(), "wb"); - fwrite(res, 1, len, out); - fclose(out); - free(s); - } - } + using namespace reiconv; + Buffer input = Buffer::read_from_file(input_file_path); + std::string res = convert(from, to, {input.data(), input.size}, ConvertFlag::DISCARD_ILSEQ); + return Buffer(res, "converted"); } - -#endif diff --git a/tests/sort.cpp b/tests/sort.cpp index 14cd98b0..9198580c 100644 --- a/tests/sort.cpp +++ b/tests/sort.cpp @@ -1,5 +1,10 @@ +/** + * @file sort.cpp + * @brief Sort file lines. + * @author ChenPi11 + * @copyright Copyright (C) 2024 The C++ Plus Project + */ /* - * Copyright (C) 2023 The C++ Plus Project. * This file is part of the cppp-reiconv Library. * * The cppp-reiconv Library is free software; you can redistribute it @@ -13,29 +18,23 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv Library; see the file COPYING. + * License along with the cppp-reiconv Library; see the file LICENSE. * If not, see . */ -/* - Sort file lines. -*/ - - -#include +#include #include "sort.hpp" -#include "throw_error.hpp" +#include "output.hpp" -// Usage: ./sort input_file output_file -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { - if (argc < 3) + if (argc != 3) { - error("sort", "Usage: ./sort input_file output_file"); + print_stderr("Usage: ./sort INPUT-FILE OUTPUT-FILE\n"); + return EXIT_FAILURE; } sort_file(argv[1], argv[2]); - - return 0; + return EXIT_SUCCESS; } diff --git a/tests/sort.hpp b/tests/sort.hpp index 062a9860..fe537a97 100644 --- a/tests/sort.hpp +++ b/tests/sort.hpp @@ -1,5 +1,10 @@ +/** + * @file sort.hpp + * @brief Sort file lines. + * @author ChenPi11 + * @copyright Copyright (C) 2024 The C++ Plus Project + */ /* - * Copyright (C) 2023 The C++ Plus Project. * This file is part of the cppp-reiconv Library. * * The cppp-reiconv Library is free software; you can redistribute it @@ -13,39 +18,35 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv Library; see the file COPYING. + * License along with the cppp-reiconv Library; see the file LICENSE. * If not, see . */ -/* - Sort file lines. -*/ - -#ifndef _SORT_HPP -#define _SORT_HPP +#pragma once -#include -#include -#include #include +#include +#include #include +#include -#include "throw_error.hpp" +#include "output.hpp" +#include "utils.hpp" -void sort_file(const std::string& file_name, const std::string& output_file_name) +inline void sort_file(const std::filesystem::path &file_name, const std::filesystem::path &output_file_name) { std::vector lines; - std::ifstream input_file(file_name); - if(!input_file.is_open()) + std::ifstream input_file {file_name}; + if (!input_file.good()) { - error("sort", "Failed to open file: " + file_name); + error("sort", "Failed to open the input file."); } - std::ofstream output_file(output_file_name, std::ios::trunc); - if(!output_file.is_open()) + std::ofstream output_file {output_file_name, std::ios::trunc}; + if (!output_file.good()) { - error("sort", "Failed to open file: " + output_file_name); + error("sort", "Failed to open the output file."); } std::string line; @@ -57,10 +58,9 @@ void sort_file(const std::string& file_name, const std::string& output_file_name std::sort(lines.begin(), lines.end()); - for (const std::string& line : lines) + for (const std::string &line : lines) { - output_file << line << std::endl; + print_string(""); + write_stream(output_file, line + "\n"); } } - -#endif diff --git a/tests/table-from.hpp b/tests/table-from.hpp index fba9c9d8..c608192c 100644 --- a/tests/table-from.hpp +++ b/tests/table-from.hpp @@ -1,249 +1,219 @@ -/* Copyright (C) 2000-2002, 2004-2005 Free Software Foundation, Inc. - This file is part of the cppp-reiconv library. - - The cppp-reiconv library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 3 - of the License, or (at your option) any later version. - - The cppp-reiconv library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the cppp-reiconv library; see the file COPYING. - If not, see . */ - -/* Create a table from CHARSET to Unicode. */ - -#ifndef _TABLE_FROM_HPP -#define _TABLE_FROM_HPP - -#include +/** + * @file table-from.hpp + * @brief Create a table from CHARSET to Unicode. + * @author ChenPi11 + * @copyright Copyright (C) 2000-2002, 2004-2005 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#pragma once + +#include +#include + +#ifndef _CPPP_API +#error This header is not API header of cppp-reiconv. +#endif -#include +#include #include #include -#include - -#include "throw_error.hpp" - -using namespace cppp::base::reiconv; - -namespace test +#include +#include + +#include "output.hpp" +#include "utils.hpp" + +/** + * @brief Hex dump of a buffer. + * @param buf The buffer. + * @param buflen The length of the buffer. + * @return The hex dump of the buffer. + */ +inline std::string hexbuf(unsigned char *buf, unsigned int buflen) { - namespace _table_from + std::string res{"0x"}; + for (unsigned int i = 0; i < buflen; i++) { - /* If nonzero, ignore conversions outside Unicode plane 0. */ - static int bmp_only; + res += tohex(buf[i], 2); + } - FILE* save_file; + return res; +} - static const char* hexbuf (unsigned char buf[], unsigned int buflen) +/** + * @brief Try to convert a buffer. + * @param cd The cppp-reiconv handle. + * @param buf The buffer. + * @param buflen The length of the buffer. + * @param out The output buffer. + * @return The number of Unicode values in the output buffer. + */ +static int try_convert(iconv_t cd, unsigned char *buf, unsigned int buflen, unsigned int *out) +{ + const char *inbuf = (const char *)buf; + std::size_t inbytesleft = buflen; + char *outbuf = (char *)out; + std::size_t outbytesleft = 3 * sizeof(unsigned int); + std::size_t result; + iconv(cd, nullptr, nullptr, nullptr, nullptr); + result = iconv(cd, (char **)&inbuf, &inbytesleft, &outbuf, &outbytesleft); + if (result != (std::size_t)(-1)) + { + result = iconv(cd, nullptr, nullptr, &outbuf, &outbytesleft); + } + if (result == (std::size_t)(-1)) + { + if (errno == EILSEQ) { - static char msg[50]; - switch (buflen) - { - case 1: sprintf(msg,"0x%02X",buf[0]); break; - case 2: sprintf(msg,"0x%02X%02X",buf[0],buf[1]); break; - case 3: sprintf(msg,"0x%02X%02X%02X",buf[0],buf[1],buf[2]); break; - case 4: sprintf(msg,"0x%02X%02X%02X%02X",buf[0],buf[1],buf[2],buf[3]); break; - default: error("hexbuf", "Buflen out of range."); - } - return msg; + return -1; } - - static int try_do (iconv_t cd, unsigned char buf[], unsigned int buflen, unsigned int* out) + else if (errno == EINVAL) { - const char* inbuf = (const char*) buf; - size_t inbytesleft = buflen; - char* outbuf = (char*) out; - size_t outbytesleft = 3 * sizeof(unsigned int); - size_t result; - iconv(cd, NULL, NULL, NULL, NULL); - result = iconv(cd, (char**)&inbuf, &inbytesleft, &outbuf, &outbytesleft); - if (result != (size_t)(-1)) - { - result = iconv(cd, NULL, NULL, &outbuf, &outbytesleft); - } - if (result == (size_t)(-1)) - { - if (errno == EILSEQ) - { - return -1; - } - else if (errno == EINVAL) - { - return 0; - } - else - { - fprintf(stderr, "%s: iconv error.", hexbuf(buf, buflen)); - error("table-from", "Iconv error."); - } - } - else if (result > 0) /* ignore conversions with transliteration */ - { - return -1; - } - else - { - if (inbytesleft != 0) - { - fprintf(stderr, "%s: inbytes = %ld, outbytes = %ld\n", hexbuf(buf, buflen), (long)(buflen - inbytesleft), (long)(3 * sizeof(unsigned int) - outbytesleft)); - error("table-from", "Iconv error."); - } - return (3 * sizeof(unsigned int) - outbytesleft) / sizeof(unsigned int); - } return 0; } - - /* Returns the out[] buffer as a Unicode value, formatted as 0x%04X. */ - static const char* ucs4_decode (const unsigned int* out, unsigned int outlen) + else { - static char hexbuf[21]; - char* p = hexbuf; - while (outlen > 0) - { - if (p > hexbuf) - *p++ = ' '; - sprintf (p, "0x%04X", out[0]); - out += 1; outlen -= 1; - if (bmp_only && strlen(p) > 6) - return NULL; - p += strlen(p); - } - return hexbuf; + print_stderr("hexbuf(): {}\n", hexbuf(buf, buflen)); + error("table-from", "Iconv error."); } - } - - void table_from (const std::string& save_file_path, const std::string& charset) + else if (result > 0) /* Ignore conversions with transliteration. */ { - using namespace _table_from; - - save_file = fopen(save_file_path.c_str(), "w"); - if (save_file == NULL) + return -1; + } + else + { + if (inbytesleft != 0) { - error("table-from", "Can't open save file."); + print_stderr("{}: inbytes = {}, outbytes = {}\n", hexbuf(buf, buflen), std::to_string(buflen - inbytesleft), + std::to_string(3 * sizeof(unsigned int) - outbytesleft)); + error("table-from", "Iconv error."); } + return (3 * sizeof(unsigned int) - outbytesleft) / sizeof(unsigned int); + } + return 0; +} - iconv_t cd; - int search_depth; - - cd = iconv_open("UCS-4-INTERNAL", charset.c_str()); - if (cd == (iconv_t)(-1)) +/** + * @brief Returns the out[] buffer as a Unicode value, formatted as 0x%04X. + * @param out The out buffer. + * @param outlen The length of the out buffer. + * @return The Unicode value. + */ +static const char *ucs4_decode(const unsigned int *out, unsigned int outlen, bool bmp_only) +{ + static char hexbuf[21]; + char *p = hexbuf; + while (outlen > 0) + { + if (p > hexbuf) { - error("iconv_open"," Iconv open error."); + *p++ = ' '; } + std::sprintf(p, "0x%04X", out[0]); + out += 1; + outlen -= 1; + if (bmp_only && std::strlen(p) > 6) + { + return nullptr; + } + p += std::strlen(p); + } + return hexbuf; +} - /* When testing UTF-8, stop at 0x10000, otherwise the output file gets too - big. */ - bmp_only = (charset == "UTF-8"); - search_depth = (bmp_only ? 3 : 4); - +/** + * @brief Generate the table. + * @param cd The cppp-reiconv handle. + * @param i The index buffer. + * @param index The index for generation. 0-3. + * @param out The out buffer. + * @param buf The index buffer. + * @param bmp_only When true, ignore conversions outside Unicode plane 0. + * @param save_file The save file stream. + */ +inline void run_table_from_test(iconv_t cd, unsigned int (&i)[4], std::size_t index, unsigned int (&out)[3], + unsigned char (&buf)[4], bool bmp_only, std::ofstream &save_file) +{ + int result; + for (i[index] = 0; i[index] < 0x100; i[index]++) + { + buf[index] = i[index]; + result = try_convert(cd, buf, index + 1, out); + if (result > 0) { - unsigned int out[3]; - unsigned char buf[4]; - unsigned int i0, i1, i2, i3; - int result; - for (i0 = 0; i0 < 0x100; i0++) + const char *unicode = ucs4_decode(out, result, bmp_only); + if (unicode != nullptr) { - buf[0] = i0; - result = try_do(cd, buf, 1, out); - if (result < 0) - { - - } - else if (result > 0) - { - const char* unicode = ucs4_decode(out, result); - if (unicode != NULL) - { - fprintf(save_file, "0x%02X\t%s\n", i0, unicode); - } - } - else + save_file.write("0x", 2); + for (std::size_t j = 0; j < index + 1; j++) { - for (i1 = 0; i1 < 0x100; i1++) - { - buf[1] = i1; - result = try_do(cd, buf, 2, out); - if (result < 0) - { - - } - else if (result > 0) - { - const char* unicode = ucs4_decode(out,result); - if (unicode != NULL) - { - fprintf(save_file, "0x%02X%02X\t%s\n", i0, i1, unicode); - } - } - else - { - for (i2 = 0; i2 < 0x100; i2++) - { - buf[2] = i2; - result = try_do(cd, buf, 3, out); - if (result < 0) - { - - } - else if (result > 0) - { - const char* unicode = ucs4_decode(out, result); - if (unicode != NULL) - { - fprintf(save_file, "0x%02X%02X%02X\t%s\n", i0, i1, i2, unicode); - } - } - else if (search_depth > 3) - { - for (i3 = 0; i3 < 0x100; i3++) - { - buf[3] = i3; - result = try_do(cd, buf, 4, out); - if (result < 0) - { - - } - else if (result > 0) - { - const char* unicode = ucs4_decode(out, result); - if (unicode != NULL) - { - fprintf(save_file, "0x%02X%02X%02X%02X\t%s\n", i0, i1, i2, i3, unicode); - } - } - else - { - fprintf(stderr, "%s: incomplete byte sequence\n", hexbuf(buf, 4)); - error("table-from", "Incomplete byte sequence."); - } - } - } - } - } - } + write_stream(save_file, tohex(i[j], 2)); } + write_stream(save_file, print_string("\t{}\n", unicode)); } } - - if (iconv_close(cd) < 0) + else if (result == 0) { - error("iconv_close","Iconv close error."); + if (index >= 3) + { + print_stderr("{}: Incomplete byte sequence" + "\n", + hexbuf(buf, 4)); + error("table-from", "Incomplete byte sequence."); + } + run_table_from_test(cd, i, index + 1, out, buf, bmp_only, save_file); } + } +} - if (fclose(save_file) < 0) - { - error("table-from", "IO Error."); - } +/** + * @brief Create a table from CHARSET to Unicode. + * @param save_file_path The path of the save file. + * @param charset The CHARSET. + */ +inline void table_from(const std::filesystem::path &save_file_path, const std::string &charset) +{ + /* If nonzero, ignore conversions outside Unicode plane 0. */ + bool bmp_only = (charset == "UTF-8"); + int search_depth = (bmp_only ? 3 : 4); + + std::ofstream save_file{save_file_path, std::ios::out | std::ios::trunc}; + if (!save_file.good()) + { + error(save_file_path.string(), "Cannot open save file."); } + iconv_t cd = iconv_open("UCS-4-INTERNAL", charset.c_str()); + if (cd == (iconv_t)(-1)) + { + error("iconv_open", " Iconv open error."); + } -} + unsigned int out[3]; + unsigned char buf[4]; + unsigned int i[4]; -#endif + run_table_from_test(cd, i, 0, out, buf, bmp_only, save_file); + + iconv_close(cd); + save_file.close(); +} diff --git a/tests/table-to.hpp b/tests/table-to.hpp index 397c2bce..d0b6312e 100644 --- a/tests/table-to.hpp +++ b/tests/table-to.hpp @@ -1,128 +1,111 @@ -/* Copyright (C) 2000-2002, 2004-2005 Free Software Foundation, Inc. - This file is part of the cppp-reiconv library. +/** + * @file table-to.hpp + * @brief Create a table from Unicode to CHARSET. + * @author ChenPi11 + * @copyright Copyright (C) 2000-2002, 2004-2005 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#pragma once + +#include "iconv.h" - The cppp-reiconv library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 3 - of the License, or (at your option) any later version. - - The cppp-reiconv library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the cppp-reiconv library; see the file COPYING. - If not, see . */ - -/* Create a table from Unicode to CHARSET. */ - -#ifndef _TABLE_TO_HPP -#define _TABLE_TO_HPP - -#include - -#include +#include #include #include -#include +#include +#include -#include "throw_error.hpp" +#include "output.hpp" +#include "utils.hpp" -using namespace cppp::base::reiconv; - -namespace test +inline void table_to(const std::filesystem::path &save_file_path, const std::string &charset) { - namespace _table_to + // When testing UTF-8, stop at 0x10000, otherwise the output file gets too big. + int bmp_only = (charset == "UTF-8"); + + std::ofstream save_file{save_file_path, std::ios::out | std::ios::trunc}; + if (!save_file.good()) { - FILE* save_file; + error(save_file_path.string(), "Cannot open save file."); } - void table_to(const std::string& save_file_path, const std::string& charset) + iconv_t cd = iconv_open(charset.c_str(), "UCS-4-INTERNAL"); + if (cd == (iconv_t)(-1)) { - using namespace _table_to; + error("iconv_open", "Iconv open error."); + } - save_file = fopen(save_file_path.c_str(), "w"); - if (save_file == NULL) + unsigned int i; + unsigned char buf[10]; + for (i = 0; i < (bmp_only ? 0x10000 : 0x110000); i++) + { + unsigned int in = i; + const char *inbuf = (const char *)∈ + size_t inbytesleft = sizeof(unsigned int); + char *outbuf = (char *)buf; + size_t outbytesleft = sizeof(buf); + size_t result; + size_t result2 = 0; + iconv(cd, nullptr, nullptr, nullptr, nullptr); + result = iconv(cd, (char **)&inbuf, &inbytesleft, &outbuf, &outbytesleft); + if (result != (size_t)(-1)) { - error("table-to", "Cannot open save file."); + result2 = iconv(cd, nullptr, nullptr, &outbuf, &outbytesleft); } - - iconv_t cd; - int bmp_only; - - cd = iconv_open(charset.c_str(), "UCS-4-INTERNAL"); - if (cd == (iconv_t)(-1)) + if (result == (size_t)(-1) || result2 == (size_t)(-1)) { - error("iconv_open", "Iconv open error."); + if (errno != EILSEQ) + { + print_stderr("0x{}: Iconv error.\n", tohex(in, 4)); + error("table-to", "Iconv error."); + } } - - /* When testing UTF-8, stop at 0x10000, otherwise the output file gets too - big. */ - bmp_only = (charset == "UTF-8"); - + else if (result == 0) /* Ignore conversions with transliteration. */ { - unsigned int i; - unsigned char buf[10]; - for (i = 0; i < (bmp_only ? 0x10000 : 0x110000); i++) + if (inbytesleft == 0 && outbytesleft < sizeof(buf)) { - unsigned int in = i; - const char* inbuf = (const char*) ∈ - size_t inbytesleft = sizeof(unsigned int); - char* outbuf = (char*)buf; - size_t outbytesleft = sizeof(buf); - size_t result; - size_t result2 = 0; - iconv(cd, NULL, NULL, NULL, NULL); - result = iconv(cd, (char**)&inbuf, &inbytesleft, &outbuf, &outbytesleft); - if (result != (size_t)(-1)) - { - result2 = iconv(cd, NULL, NULL, &outbuf, &outbytesleft); - } - if (result == (size_t)(-1) || result2 == (size_t)(-1)) + unsigned int jmax = sizeof(buf) - outbytesleft; + unsigned int j; + save_file.write("0x", 2); + for (j = 0; j < jmax; j++) { - if (errno != EILSEQ) - { - fprintf(stderr, "0x%02X: iconv error.\n", i); - error("iconv", "Iconv error."); - } - } - else if (result == 0) /* ignore conversions with transliteration */ - { - if (inbytesleft == 0 && outbytesleft < sizeof(buf)) - { - unsigned int jmax = sizeof(buf) - outbytesleft; - unsigned int j; - fprintf(save_file, "0x"); - for (j = 0; j < jmax; j++) - { - fprintf(save_file, "%02X",buf[j]); - } - fprintf(save_file, "\t0x%04X\n", i); - } - else if (inbytesleft == 0 && i >= 0xe0000 && i < 0xe0080) - { - /* Language tags may silently be dropped. */ - } - else - { - fprintf(stderr, "0x%02X: inbytes = %ld, outbytes = %ld\n", i, (long)(sizeof(unsigned int) - inbytesleft), (long)(sizeof(buf) - outbytesleft)); - error("iconv", "Iconv error."); - } + write_stream(save_file, tohex(buf[j], 2)); } + write_stream(save_file, print_string("\t0x{}\n", tohex(in, 4))); + } + else if (inbytesleft == 0 && i >= 0xe0000 && i < 0xe0080) + { + /* Language tags may silently be dropped. */ + } + else + { + print_stderr("0x{}: inbytes = {}, outbytes = {}\n", tohex(in, 2), + std::to_string(sizeof(unsigned int) - inbytesleft), + std::to_string(sizeof(buf) - outbytesleft)); + error("iconv", "Iconv error."); } } + } - if (iconv_close(cd) < 0) - { - error("iconv_close", "Iconv close error."); - } + iconv_close(cd); - if (fclose(save_file) < 0) - { - error("fclose", "IO error."); - } - } + save_file.close(); } - -#endif diff --git a/tests/test-bom-state.cpp b/tests/test-bom-state.cpp new file mode 100644 index 00000000..bd8916d4 --- /dev/null +++ b/tests/test-bom-state.cpp @@ -0,0 +1,120 @@ +/** + * @file test-bom-state.cpp + * @brief Checks that iconv does not forget about the byte-order state. + * @author Bruno Haible, ChenPi11 + * @copyright Copyright (C) 2024 Free Software Foundation, Inc. + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#include "cppp/reiconv.h" + +#include +#include +#include + +/* + * This test checks that iconv(cd, nullptr, nullptr, ...) does not forget about + * the byte-order state in conversions from UCS-2, UCS-4, UTF-16, UTF-32. + * + * The POSIX specification + * + * is clear that iconv(cd, nullptr, nullptr, ...) has an effect for state-dependent + * encodings only. The manual page + * + * is not so clear about it. But Ulrich Drepper states it correctly in + * : + * "Flushing using iconv() only resets the shift state. This is needed + * for stateful encodings with states where the caller wants a converted + * string to end in the initial state. The BOM recognition has nothing + * to do with shift states. Once the byte order is determined this is + * a property which stays with the iconv_t descriptor for its lifetime." + * + * Based on a bug report from Tomas Kalibera in + * . + */ + +static void test_one_input(const char *fromcode, const char *input, std::size_t input_size) +{ + char outbuf1[3]; + char outbuf2[3]; + + ::reiconv_t cd = ::reiconv_open("UTF-8", fromcode); + if (cd == (::reiconv_t)(-1)) + { + std::abort(); + } + + // Convert the first character. + char *inbuf = (char *)input; + std::size_t inbytesleft = input_size; + char *outbuf = outbuf1; + std::size_t outbytesleft = sizeof(outbuf1); + std::size_t ret = ::reiconv_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + if (ret != (std::size_t)(-1) || errno != E2BIG || outbytesleft != 0) + { + std::abort(); + } + if (std::memcmp(outbuf1, "\xe2\x94\xa6", 3) != 0) // Should be U+2526. + { + std::abort(); + } + + // Reset the shift state. + ret = ::reiconv_iconv(cd, nullptr, nullptr, nullptr, nullptr); + if (ret) + { + std::abort(); + } + + // Convert the second character. + outbuf = outbuf2; + outbytesleft = sizeof(outbuf2); + ret = ::reiconv_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + if (ret != 0 || outbytesleft != 0) + { + std::abort(); + } + if (memcmp(outbuf2, "\xe2\x98\xa9", 3) != 0) // Should be U+2629. + { + std::abort(); + } + + ::reiconv_handle_close(cd); +} + +static void test_both_inputs(const char *fromcode, const char *be_input, const char *le_input, std::size_t input_size) +{ + test_one_input(fromcode, be_input, input_size); + test_one_input(fromcode, le_input, input_size); +} + +int main() +{ + static const char ucs2_be_input[] = "\xfe\xff\x25\x26\x26\x29"; + static const char ucs2_le_input[] = "\xff\xfe\x26\x25\x29\x26"; + test_both_inputs("UCS-2", ucs2_be_input, ucs2_le_input, sizeof(ucs2_be_input) - 1); + test_both_inputs("UTF-16", ucs2_be_input, ucs2_le_input, sizeof(ucs2_be_input) - 1); + + static const char ucs4_be_input[] = "\x00\x00\xfe\xff\x00\x00\x25\x26\x00\x00\x26\x29"; + static const char ucs4_le_input[] = "\xff\xfe\x00\x00\x26\x25\x00\x00\x29\x26\x00\x00"; + test_both_inputs("UCS-4", ucs4_be_input, ucs4_le_input, sizeof(ucs4_be_input) - 1); + test_both_inputs("UTF-32", ucs4_be_input, ucs4_le_input, sizeof(ucs4_be_input) - 1); + + return EXIT_SUCCESS; +} diff --git a/tests/test-discard.cpp b/tests/test-discard.cpp new file mode 100644 index 00000000..7ebd9e04 --- /dev/null +++ b/tests/test-discard.cpp @@ -0,0 +1,259 @@ +/** + * @file test-bom-state.cpp + * @brief Checks the behaviour of iconv() with suffix //IGNORE. + * @author Bruno Haible, ChenPi11 + * @copyright Copyright (C) 2024 Free Software Foundation, Inc. + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#include "cppp/reiconv.h" +#include "iconv.h" + +#include +#include +#include +#include + +static const char input1[8] = "3\xd4\xe2\x84\x83\xc3\x9f"; +static const char input2[8] = "3\xe2\x84\x83\xd4\xc3\x9f"; + +static void test_default(::reiconv_t cd) +{ + char output[10]; + char *inbuf; + std::size_t inbytesleft; + char *outbuf; + std::size_t outbytesleft; + std::size_t ret; + + inbuf = (char *)input1; + inbytesleft = sizeof(input1) - 1; + outbuf = output; + outbytesleft = sizeof(output); + ret = ::reiconv_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + if (ret != (size_t)(-1) || errno != EILSEQ || sizeof(input1) - 1 - inbytesleft != 1) + { + std::abort(); + } + if (sizeof(output) - outbytesleft != 1 || output[0] != '3') + { + std::abort(); + } + + inbuf = (char *)input2; + inbytesleft = sizeof(input2) - 1; + outbuf = output; + outbytesleft = sizeof(output); + ret = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + if (ret != (std::size_t)(-1) || errno != EILSEQ || sizeof(input2) - 1 - inbytesleft != 1) + { + std::abort(); + } + if (sizeof(output) - outbytesleft != 1 || output[0] != '3') + { + std::abort(); + } +} + +static void test_translit(::reiconv_t cd) +{ + char output[10]; + char *inbuf; + std::size_t inbytesleft; + char *outbuf; + std::size_t outbytesleft; + std::size_t ret; + + inbuf = (char *)input1; + inbytesleft = sizeof(input1) - 1; + outbuf = output; + outbytesleft = sizeof(output); + ret = ::reiconv_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + if (ret != (std::size_t)(-1) || errno != EILSEQ || sizeof(input1) - 1 - inbytesleft != 1) + { + std::abort(); + } + if (sizeof(output) - outbytesleft != 1 || output[0] != '3') + { + std::abort(); + } + + inbuf = (char *)input2; + inbytesleft = sizeof(input2) - 1; + outbuf = output; + outbytesleft = sizeof(output); + ret = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + if (ret != (std::size_t)(-1) || errno != EILSEQ || sizeof(input2) - 1 - inbytesleft != 4) + { + std::abort(); + } + if (sizeof(output) - outbytesleft != 3 || output[0] != '3' || output[1] != '\xb0' || output[2] != 'C') + { + std::abort(); + } +} + +static void test_ignore(::reiconv_t cd) +{ + char output[10]; + char *inbuf; + std::size_t inbytesleft; + char *outbuf; + std::size_t outbytesleft; + std::size_t ret; + + inbuf = (char *)input1; + inbytesleft = sizeof(input1) - 1; + outbuf = output; + outbytesleft = sizeof(output) - 1; + ret = ::reiconv_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + if (ret != 1 || inbytesleft != 0) + { + std::abort(); + } + if (sizeof(output) - outbytesleft != 3 || output[0] != '3' || output[1] != '\xdf') + { + std::abort(); + } + + inbuf = (char *)input2; + inbytesleft = sizeof(input2) - 1; + outbuf = output; + outbytesleft = sizeof(output) - 1; + ret = ::reiconv_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + if (ret != 1 || inbytesleft != 0) + { + std::abort(); + } + if (sizeof(output) - outbytesleft != 3 || output[0] != '3' || output[1] != '\xdf') + { + std::abort(); + } +} + +static void test_ignore_translit(::reiconv_t cd) +{ + char output[10]; + char *inbuf; + std::size_t inbytesleft; + char *outbuf; + std::size_t outbytesleft; + std::size_t ret; + + inbuf = (char *)input1; + inbytesleft = sizeof(input1) - 1; + outbuf = output; + outbytesleft = sizeof(output); + ret = ::reiconv_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + if (ret != 1 || inbytesleft != 0) + { + std::abort(); + } + if (sizeof(output) - outbytesleft != 4 || output[0] != '3' || output[1] != '\xb0' || output[2] != 'C' || + output[3] != '\xdf') + { + std::abort(); + } + + inbuf = (char *)input2; + inbytesleft = sizeof(input2) - 1; + outbuf = output; + outbytesleft = sizeof(output); + ret = ::reiconv_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + if (ret != 1 || inbytesleft != 0) + { + std::abort(); + } + if (sizeof(output) - outbytesleft != 4 || output[0] != '3' || output[1] != '\xb0' || output[2] != 'C' || + output[3] != '\xdf') + { + std::abort(); + } +} + +int main() +{ + ::reiconv_t cd; + +#pragma region Default conversion + + cd = ::reiconv_open("ISO-8859-1", "UTF-8"); + test_default(cd); + ::reiconv_handle_close(cd); + + cd = ::reiconv_open_from_index(ENCODING_UTF8, ENCODING_ISO8859_1, REICONV_NO_FLAGS); + test_default(cd); + ::reiconv_handle_close(cd); + + cd = ::reiconv_open_from_codepage(65001, 28591, REICONV_NO_FLAGS); + test_default(cd); + ::reiconv_handle_close(cd); + +#pragma endregion + +#pragma region Ignore conversion + + cd = ::reiconv_open("ISO-8859-1//IGNORE", "UTF-8"); + test_ignore(cd); + ::reiconv_handle_close(cd); + + cd = ::reiconv_open("ISO-8859-1", "UTF-8//IGNORE"); + test_ignore(cd); + ::reiconv_handle_close(cd); + + cd = ::reiconv_open_from_index(ENCODING_UTF8, ENCODING_ISO8859_1, REICONV_DISCARD_ILSEQ); + test_ignore(cd); + ::reiconv_handle_close(cd); + + cd = ::reiconv_open_from_codepage(65001, 28591, REICONV_DISCARD_ILSEQ); + test_ignore(cd); + ::reiconv_handle_close(cd); + +#pragma endregion + +#if TEST_TRANSLIT +#pragma region Translit conversion + cd = ::reiconv_open("ISO-8859-1//TRANSLIT", "UTF-8"); + test_translit(cd); + ::reiconv_handle_close(cd); + + cd = ::reiconv_open("ISO-8859-1", "UTF-8//TRANSLIT"); + test_translit(cd); + ::reiconv_handle_close(cd); + + // TODO: Translit support. + +#pragma endregion +#endif + +#if TEST_TRANSLIT + { + iconv_t cd = iconv_open("ISO-8859-1//IGNORE//TRANSLIT", "UTF-8"); + test_ignore_translit(cd); + iconv_close(cd); + } + { + iconv_t cd = iconv_open("ISO-8859-1//TRANSLIT//IGNORE", "UTF-8"); + test_ignore_translit(cd); + iconv_close(cd); + } +#endif + + return EXIT_SUCCESS; +} diff --git a/tests/test-shiftseq.cpp b/tests/test-shiftseq.cpp deleted file mode 100644 index 1330d2fe..00000000 --- a/tests/test-shiftseq.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright (C) 2008, 2018, 2022 Free Software Foundation, Inc. - This file is part of the cppp-reiconv library. - - The cppp-reiconv library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 3 - of the License, or (at your option) any later version. - - The cppp-reiconv library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the cppp-reiconv library; see the file COPYING. - If not, see . */ - -#include -#include -#include -#include -#include - -#include "throw_error.hpp" - -using namespace cppp::base::reiconv; - -/* This test checks that the behaviour of iconv() in the situation of an - invalid multibyte character after a shift sequence is consistent whether - the entire buffer is passed at once, or whether it is passed in two - subsequent calls. Based on a bug report from - Roman Rybalko - at . */ - -namespace test -{ - namespace shiftseq - { - void main1 (void) - { - static const char input[] = "+2D/YQNhB"; - iconv_t cd; - char buf[20]; - - const char * inptr; - size_t inleft; - char * outptr; - size_t outleft; - - cd = iconv_open ("UTF-8", "UTF-7"); - { - size_t r; - - inptr = input; - inleft = 9; - outptr = buf; - outleft = sizeof (buf); - r = iconv (cd, (char **) &inptr, &inleft, &outptr, &outleft); - /* - printf ("r = %d errno = %d inconsumed = %d outproduced = %d\n", - r, errno, inptr - input, outptr - buf); - // glibc: - // r = -1 errno = 84 inconsumed = 4 outproduced = 0 - // cppp-reiconv: - // r = -1 errno = 84 inconsumed = 1 outproduced = 0 - */ - if (!(r == (size_t)(-1) && errno == EILSEQ - && inptr - input == 1 && outptr - buf == 0)) - { - error(std::string(__FILE__) + ":" + std::to_string(__LINE__), "Test 1 failed."); - } - } - } - - void main2 (void) - { - static const char input[20] = "+2D/YQNhB"; - iconv_t cd; - char buf[20]; - - const char * inptr; - size_t inleft; - char * outptr; - size_t outleft; - - cd = iconv_open ("UTF-8", "UTF-7"); - { - size_t r; - - inptr = input; - inleft = 5; - outptr = buf; - outleft = sizeof (buf); - r = iconv (cd, (char **) &inptr, &inleft, &outptr, &outleft); - /* - printf ("r = %d errno = %d inconsumed = %d outproduced = %d\n", - r, errno, inptr - input, outptr - buf); - // glibc: - // r = -1 errno = 84 (EILSEQ) inconsumed = 4 outproduced = 0 - // libiconv: - // r = -1 errno = 22 (EINVAL) inconsumed = 1 outproduced = 0 - */ - if (!(r == (size_t)(-1) && errno == EINVAL - && inptr - input == 1 && outptr - buf == 0)) - { - error(std::string(__FILE__) + ":" + std::to_string(__LINE__), "Test 2 failed."); - } - - inleft = input + 20 - inptr; - r = iconv (cd, (char **) &inptr, &inleft, &outptr, &outleft); - /* - printf ("r = %d errno = %d inconsumed = %d outproduced = %d\n", - r, errno, inptr - input, outptr - buf); - // glibc: - // r = -1 errno = 84 (EILSEQ) inconsumed = 4 outproduced = 0 - // libiconv: - // r = -1 errno = 84 (EILSEQ) inconsumed = 1 outproduced = 0 - */ - if (!(r == (size_t)(-1) && errno == EILSEQ - && inptr - input == 1 && outptr - buf == 0)) - { - error(std::string(__FILE__) + ":" + std::to_string(__LINE__), "Test 2 failed."); - } - } - } - - void main() - { - main1(); - main2(); - } - } -} - -int main() -{ - test::shiftseq::main(); - return 0; -} diff --git a/tests/test-to-wchar.cpp b/tests/test-to-wchar.cpp deleted file mode 100644 index 16359d1f..00000000 --- a/tests/test-to-wchar.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (C) 2009, 2011 Free Software Foundation, Inc. - This file is part of the cppp-reiconv library. - - The cppp-reiconv library is free software; you can redistribute it - and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either version 3 - of the License, or (at your option) any later version. - - The cppp-reiconv library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the cppp-reiconv library; see the file COPYING. - If not, see . */ - -#include -#include -#include -#include -#include - -#include "throw_error.hpp" - -using namespace cppp::base::reiconv; - -/* This test checks that the conversion to wchar_t stops correctly when - the input is incomplete. Based on a bug report from - Tristan Gingold . */ - -namespace test -{ - namespace to_wchar - { - void main () - { - const char* wchar_type; - if(sizeof(wchar_t) == 2) - { - wchar_type = "UTF-16"; - } - else - { - wchar_type = "UTF-32"; - } - iconv_t cd = iconv_open (wchar_type, "UTF-8"); - if (cd == (iconv_t)(-1)) { - /* Skip the test on platforms without wchar_t - (Solaris 2.6, HP-UX 11.00). */ - } else { - char inbuf[2] = { (char)0xc2, (char)0xa0 }; - wchar_t outbuf[10]; - - char *inptr = inbuf; - size_t inbytesleft = 1; - char *outptr = (char *) outbuf; - size_t outbytesleft = sizeof (outbuf); - size_t r = iconv (cd, - (char **) &inptr, &inbytesleft, - &outptr, &outbytesleft); - - if (!(r == (size_t)(-1) && errno == EINVAL)) - { - error(std::string(__FILE__) + ":" + std::to_string(__LINE__), - "iconv() did not return EINVAL for incomplete input."); - } - } - } - } -} - -int main () -{ - test::to_wchar::main(); - return 0; -} diff --git a/tests/tests.cmake b/tests/tests.cmake index eecc50f5..0f5cc1f7 100644 --- a/tests/tests.cmake +++ b/tests/tests.cmake @@ -1,254 +1,274 @@ # CMake script for cppp-reiconv/tests +# Init CTest +enable_testing() +include(CTest) +message(STATUS "Test suite for '${PROJECT_NAME}' enabled.") -option(ENABLE_TEST "Enable cppp-reiconv test suites build." OFF) - -if (ENABLE_TEST) - # Init CTest - enable_testing() - include(CTest) - message(STATUS "Test suite for 'cppp-reiconv' enabled.") - - # Includes - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/tests") - include_directories("${output_includedir}") - - # Test executables - add_executable(data-generator "${CMAKE_CURRENT_SOURCE_DIR}/tests/data-generator.cpp") - add_executable(check-stateful "${CMAKE_CURRENT_SOURCE_DIR}/tests/check-stateful.cpp") - add_executable(check-stateless "${CMAKE_CURRENT_SOURCE_DIR}/tests/check-stateless.cpp") - add_executable(test-shiftseq "${CMAKE_CURRENT_SOURCE_DIR}/tests/test-shiftseq.cpp") - add_executable(test-to-wchar "${CMAKE_CURRENT_SOURCE_DIR}/tests/test-to-wchar.cpp") - add_executable(sort "${CMAKE_CURRENT_SOURCE_DIR}/tests/sort.cpp") - - target_link_libraries(check-stateful libcppp-reiconv.static) - target_link_libraries(check-stateless libcppp-reiconv.static) - target_link_libraries(test-shiftseq libcppp-reiconv.static) - target_link_libraries(test-to-wchar libcppp-reiconv.static) - - set_target_properties(data-generator PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${output_testsdir}" ) - set_target_properties(check-stateful PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${output_testsdir}" ) - set_target_properties(check-stateless PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${output_testsdir}" ) - set_target_properties(test-shiftseq PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${output_testsdir}" ) - set_target_properties(test-to-wchar PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${output_testsdir}" ) - set_target_properties(sort PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${output_testsdir}" ) - - # Test macro - macro(test state encoding) - add_test( NAME "check-${state}-${encoding}" - WORKING_DIRECTORY "${output_testsdir}" - COMMAND "$" "${CMAKE_CURRENT_SOURCE_DIR}/tests/data" "${encoding}" ) - endmacro(test) - - # Init test - - add_custom_command(TARGET data-generator POST_BUILD - COMMAND "$" "utf-8" > "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/UTF-8.TXT" - WORKING_DIRECTORY "${output_testsdir}" - COMMENT "Generating UTF-8 test data ... " - ) - #{ cat $(CMAKE_CURRENT_SOURCE_DIR)/GB18030-2005-BMP.TXT ; "$" "gengb18030z" ; } | sort > GB18030-2005.TXT -#{ test $(CMAKE_CURRENT_SOURCE_DIR) = . || cp $(CMAKE_CURRENT_SOURCE_DIR)/GB18030-2005.IRREVERSIBLE.TXT GB18030-2005.IRREVERSIBLE.TXT; } -#$(SHELL) $(CMAKE_CURRENT_SOURCE_DIR)/check-stateless . GB18030:2005 -#{ cat $(CMAKE_CURRENT_SOURCE_DIR)/GB18030-2022-BMP.TXT ; "$" "gengb18030z" ; } | sort > GB18030-2022.TXT -#$(SHELL) $(CMAKE_CURRENT_SOURCE_DIR)/check-stateless . GB18030:2022 - file(COPY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2005-BMP.TXT" "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2005.TXT") - add_custom_command(TARGET data-generator POST_BUILD - COMMAND "$" "gb18030z" >> "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2005.TXT" - WORKING_DIRECTORY "${output_testsdir}" - COMMENT "Generating GB18030:2005 test data ... " - ) - add_custom_command(TARGET data-generator POST_BUILD - COMMAND "$" "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2005.TXT" "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2005.TXT.tmp" - COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2005.TXT.tmp" "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2005.TXT" - COMMAND "${CMAKE_COMMAND}" -E remove "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2005.TXT.tmp" - WORKING_DIRECTORY "${output_testsdir}" - COMMENT "Sorting GB18030:2005 test data ... " - ) - - file(COPY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2022-BMP.TXT" "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2022.TXT") - add_custom_command(TARGET data-generator POST_BUILD - COMMAND "$" "gb18030z" >> "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2022.TXT" - WORKING_DIRECTORY "${output_testsdir}" - COMMENT "Generating GB18030:2022 test data ... " - ) - add_custom_command(TARGET data-generator POST_BUILD - COMMAND "$" "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2022.TXT" "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2022.TXT.tmp" - COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2022.TXT.tmp" "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2022.TXT" - COMMAND "${CMAKE_COMMAND}" -E remove "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/GB18030-2022.TXT.tmp" - WORKING_DIRECTORY "${output_testsdir}" - COMMENT "Sorting GB18030:2022 test data ... " - ) - - - - - # Start test - - # General multi-byte encodings - test("stateless" "UTF-8") - test("stateful" "UTF-16") - test("stateful" "UCS-2BE") - test("stateful" "UCS-2LE") - test("stateful" "UCS-4BE") - test("stateful" "UCS-4LE") - test("stateful" "UTF-16BE") - test("stateful" "UTF-16LE") - test("stateful" "UTF-32") - test("stateful" "UTF-32BE") - test("stateful" "UTF-32LE") - test("stateful" "UTF-7") - - # 8-bit encodings - test("stateless" "ISO-8859-1") - test("stateless" "ISO-8859-2") - test("stateless" "ISO-8859-3") - test("stateless" "ISO-8859-4") - test("stateless" "ISO-8859-5") - test("stateless" "ISO-8859-6") - test("stateless" "ISO-8859-7") - test("stateless" "ISO-8859-8") - test("stateless" "ISO-8859-9") - test("stateless" "ISO-8859-10") - test("stateless" "ISO-8859-11") - test("stateless" "ISO-8859-13") - test("stateless" "ISO-8859-14") - test("stateless" "ISO-8859-15") - test("stateless" "ISO-8859-16") - test("stateless" "KOI8-R") - test("stateless" "KOI8-U") - test("stateless" "KOI8-RU") - test("stateless" "CP1250") - test("stateless" "CP1251") - test("stateless" "CP1252") - test("stateless" "CP1253") - test("stateless" "CP1254") - test("stateless" "CP1255") - test("stateful" "CP1255") - test("stateless" "CP1256") - test("stateless" "CP1257") - test("stateless" "CP1258") - test("stateful" "CP1258") - test("stateless" "CP850") - test("stateless" "CP862") - test("stateless" "CP866") - test("stateless" "CP1131") - test("stateless" "MacRoman") - test("stateless" "MacCentralEurope") - test("stateless" "MacIceland") - test("stateless" "MacCroatian") - test("stateless" "MacRomania") - test("stateless" "MacCyrillic") - test("stateless" "MacUkraine") - test("stateless" "MacGreek") - test("stateless" "MacTurkish") - test("stateless" "MacHebrew") - test("stateless" "MacArabic") - test("stateless" "MacThai") - test("stateless" "HP-ROMAN8") - test("stateless" "NEXTSTEP") - test("stateless" "ARMSCII-8") - test("stateless" "Georgian-Academy") - test("stateless" "Georgian-PS") - test("stateless" "KOI8-T") - test("stateless" "PT154") - test("stateless" "RK1048") - test("stateless" "MuleLao-1") - test("stateless" "CP1133") - test("stateless" "TIS-620") - test("stateless" "CP874") - test("stateless" "VISCII") - test("stateless" "TCVN") - test("stateful" "TCVN") - - # CJK character sets - test("stateless" "ISO646-JP") - test("stateless" "JIS_X0201") - test("stateless" "ISO646-CN") - test("stateless" "ISO-IR-165") - - # CJK encodings - test("stateless" "EUC-JP") - test("stateless" "SHIFT_JIS") - test("stateless" "CP932") - test("stateful" "ISO-2022-JP") - test("stateful" "ISO-2022-JP-2") - test("stateful" "ISO-2022-JP-1") - test("stateful" "ISO-2022-JP-MS") - test("stateless" "EUC-CN") - test("stateless" "GBK") - test("stateless" "CP936") - test("stateless" "GB18030:2005") - test("stateless" "GB18030:2022") - test("stateful" "ISO-2022-CN") - test("stateful" "ISO-2022-CN-EXT") - test("stateful" "HZ") - test("stateless" "EUC-TW") - test("stateless" "BIG5") - test("stateless" "CP950") - test("stateless" "BIG5-HKSCS:1999") - test("stateful" "BIG5-HKSCS:1999") - test("stateless" "BIG5-HKSCS:2001") - test("stateful" "BIG5-HKSCS:2001") - test("stateless" "BIG5-HKSCS:2004") - test("stateful" "BIG5-HKSCS:2004") - test("stateless" "BIG5-HKSCS:2008") - test("stateful" "BIG5-HKSCS:2008") - test("stateless" "EUC-KR") - test("stateless" "CP949") - test("stateless" "JOHAB") - test("stateful" "ISO-2022-KR") - - # Shift sequence before invalid multibyte character - add_test( NAME test-shiftseq - WORKING_DIRECTORY "${output_testsdir}" - COMMAND "$" ) - - #if(CMAKE_SYSTEM_NAME STREQUAL "AIX") - # AIX specific encodings - test("stateless" "CP856") - test("stateless" "CP922") - test("stateless" "CP1046") - test("stateless" "CP1124") - test("stateless" "CP1129") - test("stateless" "CP1161") - test("stateless" "CP1162") - test("stateless" "CP1163") - #endif() - - # OSF/1 specific encodings - test("stateless" "DEC-KANJI") - test("stateless" "DEC-HANYU") - - # DOS specific encodings - test("stateless" "CP437") - test("stateless" "CP737") - test("stateless" "CP775") - test("stateless" "CP852") - test("stateless" "CP853") - test("stateless" "CP855") - test("stateless" "CP857") - test("stateless" "CP858") - test("stateless" "CP860") - test("stateless" "CP861") - test("stateless" "CP863") - test("stateless" "CP864") - test("stateless" "CP865") - test("stateless" "CP869") - test("stateless" "CP1125") - - # Extra encodings - test("stateless" "EUC-JISX0213") - test("stateless" "SHIFT_JISX0213") - test("stateful" "ISO-2022-JP-3") - test("stateless" "BIG5-2003") - test("stateless" "TDS565") - test("stateless" "ATARIST") - test("stateless" "RISCOS-LATIN1") - - # Test to wchar - add_test( NAME test-to-wchar +# Includes +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/tests") +include_directories("${output_includedir}") + +# Test executables +add_executable(data-generator "${CMAKE_CURRENT_SOURCE_DIR}/tests/data-generator.cpp") +add_executable(test-bom-state "${CMAKE_CURRENT_SOURCE_DIR}/tests/test-bom-state.cpp") +add_executable(test-discard "${CMAKE_CURRENT_SOURCE_DIR}/tests/test-discard.cpp") +add_executable(check-encoding "${CMAKE_CURRENT_SOURCE_DIR}/tests/check-encoding.cpp") +add_executable(check-stateful "${CMAKE_CURRENT_SOURCE_DIR}/tests/check-stateful.cpp") +add_executable(check-stateless "${CMAKE_CURRENT_SOURCE_DIR}/tests/check-stateless.cpp") +add_executable(sort "${CMAKE_CURRENT_SOURCE_DIR}/tests/sort.cpp") + +target_link_libraries(test-bom-state libcppp-reiconv.static) +target_link_libraries(test-discard libcppp-reiconv.static) +target_link_libraries(check-encoding libcppp-reiconv.static) +target_link_libraries(check-stateful libcppp-reiconv.static) +target_link_libraries(check-stateless libcppp-reiconv.static) + +set_target_properties(data-generator PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${output_testsdir}") +set_target_properties(test-bom-state PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${output_testsdir}") +set_target_properties(test-discard PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${output_testsdir}") +set_target_properties(check-encoding PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${output_testsdir}") +set_target_properties(check-stateful PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${output_testsdir}") +set_target_properties(check-stateless PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${output_testsdir}") +set_target_properties(sort PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${output_testsdir}") + +macro(convert_to_crlf input_file output_file) + file(READ ${input_file} file_content) + file(WRITE ${output_file} "${file_content}") +endmacro() + +# Test macro +macro(test state encoding) + add_test( NAME "check-${state}-${encoding}" WORKING_DIRECTORY "${output_testsdir}" - COMMAND "$" ) + COMMAND ${EXECUTOR} "$" "${TEST_DATA_DIR}" "${encoding}" + ) +endmacro(test) +# Init test +set(TEST_DATA_DIR "${output_testsdir}/data") + +# Copy data directory. +if (NOT EXISTS "${TEST_DATA_DIR}" OR TRUE) + file(MAKE_DIRECTORY "${TEST_DATA_DIR}") + file(GLOB_RECURSE TEST_DATA_FILES "${CMAKE_CURRENT_SOURCE_DIR}/tests/data/*") + + foreach(TEST_FILE ${TEST_DATA_FILES}) + if(NOT IS_DIRECTORY "${TEST_FILE}") + get_filename_component(TEST_FILE_NAME "${TEST_FILE}" NAME) + if ("${TEST_FILE_NAME}" MATCHES "\\.TXT$" AND (WIN32 OR WINCE OR WINDOWS_PHONE OR WINDOWS_STORE)) + # On Windows, copy the text-only file as CR LF. + convert_to_crlf("${TEST_FILE}" "${TEST_DATA_DIR}/${TEST_FILE_NAME}") + else() + file(COPY_FILE "${TEST_FILE}" "${TEST_DATA_DIR}/${TEST_FILE_NAME}") + endif() + endif() + endforeach() + unset(TEST_DATA_FILES) endif() + +# Generate UTF-8 test data. +add_custom_command(TARGET data-generator POST_BUILD + COMMAND ${EXECUTOR} "$" "utf-8" > "${TEST_DATA_DIR}/UTF-8.TXT" + WORKING_DIRECTORY "${output_testsdir}" + COMMENT "Generating UTF-8 test data ... " +) + +# Generate GB18030:2005 test data. +add_custom_command(TARGET data-generator POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy "${TEST_DATA_DIR}/GB18030-2005-BMP.TXT" "${TEST_DATA_DIR}/GB18030-2005.TXT" + COMMAND ${EXECUTOR} "$" gb18030z >> "${TEST_DATA_DIR}/GB18030-2005.TXT" + WORKING_DIRECTORY "${output_testsdir}" + COMMENT "Generating GB18030:2005 test data ... " +) +add_custom_command(TARGET data-generator POST_BUILD + COMMAND ${EXECUTOR} "$" "${TEST_DATA_DIR}/GB18030-2005.TXT" "${TEST_DATA_DIR}/GB18030-2005.TXT.tmp" + COMMAND "${CMAKE_COMMAND}" -E copy "${TEST_DATA_DIR}/GB18030-2005.TXT.tmp" "${TEST_DATA_DIR}/GB18030-2005.TXT" + COMMAND "${CMAKE_COMMAND}" -E remove "${TEST_DATA_DIR}/GB18030-2005.TXT.tmp" + WORKING_DIRECTORY "${output_testsdir}" + COMMENT "Sorting GB18030:2005 test data ... " +) + +# Generate GB18030:2022 test data. +add_custom_command(TARGET data-generator POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy "${TEST_DATA_DIR}/GB18030-2022-BMP.TXT" "${TEST_DATA_DIR}/GB18030-2022.TXT" + COMMAND ${EXECUTOR} "$" gb18030z >> "${TEST_DATA_DIR}/GB18030-2022.TXT" + WORKING_DIRECTORY "${output_testsdir}" + COMMENT "Generating GB18030:2022 test data ... " +) +add_custom_command(TARGET data-generator POST_BUILD + COMMAND ${EXECUTOR} "$" "${TEST_DATA_DIR}/GB18030-2022.TXT" "${TEST_DATA_DIR}/GB18030-2022.TXT.tmp" + COMMAND "${CMAKE_COMMAND}" -E copy "${TEST_DATA_DIR}/GB18030-2022.TXT.tmp" "${TEST_DATA_DIR}/GB18030-2022.TXT" + COMMAND "${CMAKE_COMMAND}" -E remove "${TEST_DATA_DIR}/GB18030-2022.TXT.tmp" + WORKING_DIRECTORY "${output_testsdir}" + COMMENT "Sorting GB18030:2022 test data ... " +) + +add_test(NAME check-encoding + WORKING_DIRECTORY "${output_testsdir}" + COMMAND ${EXECUTOR} "$" + ) + +add_test(NAME test-bom-state + WORKING_DIRECTORY "${output_testsdir}" + COMMAND ${EXECUTOR} "$" + ) + +add_test(NAME test-discard + WORKING_DIRECTORY "${output_testsdir}" + COMMAND ${EXECUTOR} "$" + ) + +# General multi-byte encodings. +test("stateless" "UTF-8") +test("stateful" "UTF-16") +test("stateful" "UCS-2BE") +test("stateful" "UCS-2LE") +test("stateful" "UCS-4BE") +test("stateful" "UCS-4LE") +test("stateful" "UTF-16BE") +test("stateful" "UTF-16LE") +test("stateful" "UTF-32") +test("stateful" "UTF-32BE") +test("stateful" "UTF-32LE") +test("stateful" "UTF-7") + +# 8-bit encodings. +test("stateless" "ISO-8859-1") +test("stateless" "ISO-8859-2") +test("stateless" "ISO-8859-3") +test("stateless" "ISO-8859-4") +test("stateless" "ISO-8859-5") +test("stateless" "ISO-8859-6") +test("stateless" "ISO-8859-7") +test("stateless" "ISO-8859-8") +test("stateless" "ISO-8859-9") +test("stateless" "ISO-8859-10") +test("stateless" "ISO-8859-11") +test("stateless" "ISO-8859-13") +test("stateless" "ISO-8859-14") +test("stateless" "ISO-8859-15") +test("stateless" "ISO-8859-16") +test("stateless" "KOI8-R") +test("stateless" "KOI8-U") +test("stateless" "KOI8-RU") +test("stateless" "CP1250") +test("stateless" "CP1251") +test("stateless" "CP1252") +test("stateless" "CP1253") +test("stateless" "CP1254") +test("stateless" "CP1255") +test("stateful" "CP1255") +test("stateless" "CP1256") +test("stateless" "CP1257") +test("stateless" "CP1258") +test("stateful" "CP1258") +test("stateless" "CP850") +test("stateless" "CP862") +test("stateless" "CP866") +test("stateless" "CP1131") +test("stateless" "MacRoman") +test("stateless" "MacCentralEurope") +test("stateless" "MacIceland") +test("stateless" "MacCroatian") +test("stateless" "MacRomania") +test("stateless" "MacCyrillic") +test("stateless" "MacUkraine") +test("stateless" "MacGreek") +test("stateless" "MacTurkish") +test("stateless" "MacHebrew") +test("stateless" "MacArabic") +test("stateless" "MacThai") +test("stateless" "HP-ROMAN8") +test("stateless" "NEXTSTEP") +test("stateless" "ARMSCII-8") +test("stateless" "Georgian-Academy") +test("stateless" "Georgian-PS") +test("stateless" "KOI8-T") +test("stateless" "PT154") +test("stateless" "RK1048") +test("stateless" "MuleLao-1") +test("stateless" "CP1133") +test("stateless" "TIS-620") +test("stateless" "CP874") +test("stateless" "VISCII") +test("stateless" "TCVN") +test("stateful" "TCVN") + +# CJK character sets. +test("stateless" "ISO646-JP") +test("stateless" "JIS_X0201") +test("stateless" "ISO646-CN") +test("stateless" "ISO-IR-165") + +# CJK encodings. +test("stateless" "EUC-JP") +test("stateless" "SHIFT_JIS") +test("stateless" "CP932") +test("stateful" "ISO-2022-JP") +test("stateful" "ISO-2022-JP-2") +test("stateful" "ISO-2022-JP-1") +test("stateful" "ISO-2022-JP-MS") +test("stateless" "EUC-CN") +test("stateless" "GBK") +test("stateless" "CP936") +test("stateless" "GB18030:2005") +test("stateless" "GB18030:2022") +test("stateful" "ISO-2022-CN") +test("stateful" "ISO-2022-CN-EXT") +test("stateful" "HZ") +test("stateless" "EUC-TW") +test("stateless" "BIG5") +test("stateless" "CP950") +test("stateless" "BIG5-HKSCS:1999") +test("stateful" "BIG5-HKSCS:1999") +test("stateless" "BIG5-HKSCS:2001") +test("stateful" "BIG5-HKSCS:2001") +test("stateless" "BIG5-HKSCS:2004") +test("stateful" "BIG5-HKSCS:2004") +test("stateless" "BIG5-HKSCS:2008") +test("stateful" "BIG5-HKSCS:2008") +test("stateless" "EUC-KR") +test("stateless" "CP949") +test("stateless" "JOHAB") +test("stateful" "ISO-2022-KR") + +# AIX specific encodings. +test("stateless" "CP856") +test("stateless" "CP922") +test("stateless" "CP1046") +test("stateless" "CP1124") +test("stateless" "CP1129") +test("stateless" "CP1161") +test("stateless" "CP1162") +test("stateless" "CP1163") + +# OSF/1 encodings. +test("stateless" "DEC-KANJI") +test("stateless" "DEC-HANYU") + +# DOS specific encodings. +test("stateless" "CP437") +test("stateless" "CP737") +test("stateless" "CP775") +test("stateless" "CP852") +test("stateless" "CP853") +test("stateless" "CP855") +test("stateless" "CP857") +test("stateless" "CP858") +test("stateless" "CP860") +test("stateless" "CP861") +test("stateless" "CP863") +test("stateless" "CP864") +test("stateless" "CP865") +test("stateless" "CP869") +test("stateless" "CP1125") + +# Extra encodings. +test("stateless" "EUC-JISX0213") +test("stateless" "SHIFT_JISX0213") +test("stateful" "ISO-2022-JP-3") +test("stateless" "BIG5-2003") +test("stateless" "TDS565") +test("stateless" "ATARIST") +test("stateless" "RISCOS-LATIN1") diff --git a/tests/throw_error.hpp b/tests/throw_error.hpp deleted file mode 100644 index c722dbf8..00000000 --- a/tests/throw_error.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2023 The C++ Plus Project. - * This file is part of the cppp-reiconv Library. - * - * The cppp-reiconv Library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv Library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv Library; see the file COPYING. - * If not, see . - */ - -/* - Throw error for reiconv-test. -*/ - -#ifndef _THROW_ERROR_HPP -#define _THROW_ERROR_HPP - -#include -#ifdef _MSC_VER -#include -#else -#include -#endif - -#ifdef _MSC_VER -#define isatty _isatty -#define fileno _fileno -#endif - -const bool stderr_is_tty = isatty(fileno(stderr)); - -void error(const std::string& op, const std::string& msg) -{ - int saved_errno = errno; - if(stderr_is_tty) - { - std::cerr << "\033[31m"; - } - if(saved_errno) - { - perror(op.c_str()); - } - else - { - std::cerr << op << ": "; - } - std::cerr << msg << std::endl; - if(stderr_is_tty) - { - std::cerr << "\033[0m"; - } - if(saved_errno) - { - exit(saved_errno); - } - else - { - exit(1); - } -} - -void success(const std::string& op, const std::string& msg) -{ - if(stderr_is_tty) - { - std::cerr << "\033[32m"; - } - std::cerr << op << ": "; - std::cerr << msg << std::endl; - if(stderr_is_tty) - { - std::cerr << "\033[0m"; - } -} - -#endif diff --git a/tests/uniq-u.hpp b/tests/uniq-u.hpp index 7dd90a20..5336abde 100644 --- a/tests/uniq-u.hpp +++ b/tests/uniq-u.hpp @@ -1,271 +1,274 @@ -/* uniq -- remove duplicate lines from a sorted file - Copyright (C) 86, 91, 1995-1998, 1999, 2012 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ +/** + * @file uniq-u.hpp + * @brief Remove duplicate lines from a sorted file. + * @author Richard Stallman, David MacKenzie, Bruno Haible, ChenPi11 + * @copyright Copyright (C) 86, 91, 1995-1998, 1999, 2012 Free Software Foundation, Inc. + * @copyright Copyright (C) 2024 ChenPi11 + * @license GPL-3.0-or-later + */ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ /* Written by Richard Stallman and David MacKenzie. */ /* 2000-03-22 Trimmed down to the case of "uniq -u" by Bruno Haible. */ /* 2023-08-22 Change it to a C++ header for reiconv-test by ChenPi11. */ +/* 2023-10-08 Use '#pragma once' for header. */ +/* 2024-10-26 Refactored with C++20 features by ChenPi11. */ -#ifndef _UNIQ_U_HPP -#define _UNIQ_U_HPP +#pragma once -#include #include #include +#include -namespace _uniq_u +#include "output.hpp" + +/** + * @brief Allocate N bytes of memory dynamically, with error checking. + * @param n The number of bytes to allocate. + * @return The pointer to the allocated memory. + */ +inline void *xmalloc(size_t n) { - static void xalloc_fail (void) + void *p = std::malloc(n); + if (p == nullptr) { error("xmalloc", "uniq-u: virtual memory exhausted."); } + return p; +} - /* Allocate N bytes of memory dynamically, with error checking. */ - - void* xmalloc(size_t n) - { - void *p; - - p = malloc(n); - if (p == 0) - { - xalloc_fail(); - } - return p; - } - - /* Change the size of an allocated block of memory P to N bytes, - with error checking. - If P is NULL, run xmalloc. */ - - void* xrealloc(void* p, size_t n) +/** + * @brief Change the size of an allocated block of memory P to N bytes, with error checking. + * @note If P is nullptr, run xmalloc. + * @param p The pointer to the allocated memory. + * @param n The number of bytes to allocate. + * @return The pointer to the allocated memory. + */ +inline void *xrealloc(void *p, size_t n) +{ + p = std::realloc(p, n); + if (p == 0) { - p = realloc(p, n); - if (p == 0) - { - xalloc_fail(); - } - return p; + error("xrealloc", "uniq-u: virtual memory exhausted."); } + return p; +} - /* A 'struct linebuffer' holds a line of text. */ - - struct linebuffer - { - size_t size; /* Allocated. */ - size_t length; /* Used. */ - char *buffer; - }; +/** + * @brief A 'struct linebuffer' holds a line of text. + */ +struct linebuffer +{ + std::size_t size; // Allocated. + std::size_t length; // Used. + char *buffer; +}; + +/** + * @brief Initialize linebuffer LINEBUFFER for use. + * @param linebuffer The linebuffer to initialize. + */ +inline void initbuffer(struct linebuffer *linebuffer) +{ + linebuffer->length = 0; + linebuffer->size = 200; + linebuffer->buffer = (char *)xmalloc(linebuffer->size); +} - /* Initialize linebuffer LINEBUFFER for use. */ +/** + * @brief Read an arbitrarily long line of text from STREAM into LINEBUFFER. + * @note Keep the newline; append a newline if it's the last line of a file + * that ends in a non-newline character. Do not null terminate. + * @param linebuffer The linebuffer to read into. + * @param stream The stream to read from. + * @return LINEBUFFER, except at end of file return 0. + */ +static struct linebuffer *readline(struct linebuffer *linebuffer, FILE *stream) +{ + int c; + char *buffer = linebuffer->buffer; + char *p = linebuffer->buffer; + char *end = buffer + linebuffer->size - 1; /* Sentinel. */ - static void initbuffer(struct linebuffer* linebuffer) + if (std::feof(stream) || std::ferror(stream)) { - linebuffer->length = 0; - linebuffer->size = 200; - linebuffer->buffer = (char *)xmalloc(linebuffer->size); + return 0; } - /* Read an arbitrarily long line of text from STREAM into LINEBUFFER. - Keep the newline; append a newline if it's the last line of a file - that ends in a non-newline character. Do not null terminate. - Return LINEBUFFER, except at end of file return 0. */ - - static struct linebuffer* readline (struct linebuffer* linebuffer, FILE* stream) + do { - int c; - char* buffer = linebuffer->buffer; - char* p = linebuffer->buffer; - char* end = buffer + linebuffer->size - 1; /* Sentinel. */ - - if (feof (stream) || ferror (stream)) + c = std::getc(stream); + if (c == EOF) { - return 0; - } - - do - { - c = getc(stream); - if (c == EOF) + if (p == buffer) { - if (p == buffer) - { - return 0; - } - if (p[-1] == '\n') - { - break; - } - c = '\n'; + return 0; } - if (p == end) + if (p[-1] == '\n') { - linebuffer -> size *= 2; - buffer = (char *)xrealloc(buffer, linebuffer -> size); - p = p - linebuffer -> buffer + buffer; - linebuffer -> buffer = buffer; - end = buffer + linebuffer -> size - 1; + break; } - *p++ = c; + c = '\n'; } - while (c != '\n'); + if (p == end) + { + linebuffer->size *= 2; + buffer = (char *)xrealloc(buffer, linebuffer->size); + p = p - linebuffer->buffer + buffer; + linebuffer->buffer = buffer; + end = buffer + linebuffer->size - 1; + } + *p++ = c; + } while (c != '\n'); - linebuffer -> length = p - buffer; - return linebuffer; - } + linebuffer->length = p - buffer; + return linebuffer; +} - /* Free linebuffer LINEBUFFER's data. */ - static void freebuffer (struct linebuffer *linebuffer) +/** + * @brief Free linebuffer LINEBUFFER's data. + * @param linebuffer The linebuffer to free. + */ +inline void freebuffer(struct linebuffer *linebuffer) +{ + std::free(linebuffer->buffer); +} + +/** + * @brief Return zero if two strings OLD and NEW match, nonzero if not. + * @note OLD and NEW point not to the beginnings of the lines but rather + * @note to the beginnings of the fields to compare. + * @param old The old string. + * @param new_one The new string. + * @param oldlen The length of the old string. + * @param newlen The length of the new string. + * @return Zero if two strings OLD and NEW match, nonzero if not. + */ +inline int different(const char *old, const char *new_one, size_t oldlen, size_t newlen) +{ + int order = std::memcmp(old, new_one, (oldlen < newlen) ? oldlen : newlen); + return (order == 0) ? (oldlen - newlen) : order; +} + +/** + * @brief Output the line in linebuffer LINE to stream STREAM. + * @param line The linebuffer to output. + * @param stream The stream to output to. + * @param linecount The number of times that the line occurred. + */ +inline void writeline(const struct linebuffer *line, FILE *stream, int linecount) +{ + if (linecount == 0) { - free (linebuffer -> buffer); + std::fwrite(line->buffer, 1, line->length, stream); } +} - /* Undefine, to avoid warning about redefinition on some systems. */ - #undef min - template - constexpr inline const T& min(const T& a, const T& b) +/** + * @brief Process input file INFILE with output to OUTFILE. + * @param infile The input file. + * @param outfile The output file. + */ +static void uniq_u(const std::filesystem::path& infile, std::filesystem::path& outfile) +{ + struct linebuffer *exch; + char *prevfield, *thisfield; + size_t prevlen, thislen; + int match_count = 0; + std::string tmp; + + tmp = infile.string(); + FILE *istream = std::fopen(tmp.c_str(), "r"); + if (istream == nullptr) { - return (a < b) ? a : b; + print_stderr("uniq-u: Error while opening {}\n", tmp); + error("fopen", "File open error."); } - /* Return zero if two strings OLD and NEW match, nonzero if not. - OLD and NEW point not to the beginnings of the lines - but rather to the beginnings of the fields to compare. - OLDLEN and NEWLEN are their lengths. */ - - static int different(const char *old, const char *new_one, size_t oldlen, size_t newlen) + tmp = outfile.string(); + FILE *ostream = std::fopen(tmp.c_str(), "w"); + if (ostream == nullptr) { - int order; - - order = memcmp(old, new_one, min(oldlen, newlen)); - - if (order == 0) - { - return oldlen - newlen; - } - return order; + print_stderr("uniq-u: Error while opening {}\n", tmp); + error("fopen", "File open error."); } - /* Output the line in linebuffer LINE to stream STREAM - provided that the switches say it should be output. - If requested, print the number of times it occurred, as well; - LINECOUNT + 1 is the number of times that the line occurred. */ + struct linebuffer lb1; + struct linebuffer lb2; + struct linebuffer *thisline = &lb1; + struct linebuffer *prevline = &lb2; + + initbuffer(thisline); + initbuffer(prevline); - static void writeline(const struct linebuffer* line, FILE* stream, int linecount) + if (readline(prevline, istream) == 0) { - if (linecount == 0) - { - fwrite (line -> buffer, 1, line -> length, stream); - } + goto closefiles; } + prevfield = prevline->buffer; + prevlen = prevline->length; - /* Process input file INFILE with output to OUTFILE. - If either is "-", use the standard I/O stream for it instead. */ - static void check_file(const char* infile, const char* outfile) + while (!std::feof(istream)) { - FILE *istream; - FILE *ostream; - struct linebuffer lb1, lb2; - struct linebuffer *thisline, *prevline, *exch; - char *prevfield, *thisfield; - size_t prevlen, thislen; - int match_count = 0; - - istream = fopen(infile, "r"); - if (istream == NULL) + int match; + if (readline(thisline, istream) == 0) { - fprintf(stderr, "uniq-u: error opening %s\n", infile); - error("fopen", "File open error."); + break; } + thisfield = thisline->buffer; + thislen = thisline->length; + match = !different(thisfield, prevfield, thislen, prevlen); - ostream = fopen (outfile, "w"); - if (ostream == NULL) + if (match) { - fprintf(stderr, "uniq-u: error opening %s\n", outfile); - error("fopen", "File open error."); + ++match_count; } - thisline = &lb1; - prevline = &lb2; - - initbuffer(thisline); - initbuffer(prevline); - - if (readline(prevline, istream) == 0) + if (!match) { - goto closefiles; - } - prevfield = prevline -> buffer; - prevlen = prevline -> length; - - while (!feof(istream)) - { - int match; - if (readline(thisline, istream) == 0) - { - break; - } - thisfield = thisline -> buffer; - thislen = thisline -> length; - match = !different(thisfield, prevfield, thislen, prevlen); - - if (match) - { - ++match_count; - } - + writeline(prevline, ostream, match_count); + exch = prevline; + prevline = thisline; + thisline = exch; + prevfield = thisfield; + prevlen = thislen; if (!match) { - writeline(prevline, ostream, match_count); - exch = prevline; - prevline = thisline; - thisline = exch; - prevfield = thisfield; - prevlen = thislen; - if (!match) - { - match_count = 0; - } + match_count = 0; } } + } - writeline(prevline, ostream, match_count); - - closefiles: - if (ferror(istream) || fclose(istream) == EOF) - { - fprintf (stderr, "uniq-u: error reading %s\n", infile); - error("fclose", "IO Error."); - } + writeline(prevline, ostream, match_count); - if (ferror(ostream) || fclose(ostream) == EOF) - { - fprintf(stderr, "uniq-u: error writing %s\n", outfile); - error("fclose", "IO Error."); - } +closefiles: + if (std::ferror(istream) || std::fclose(istream) == EOF) + { + tmp = infile.string(); + print_stderr("uniq-u: Error while reading {}\n", tmp); + error("fclose", "I/O Error."); + } - freebuffer(&lb1); - freebuffer(&lb2); + if (ferror(ostream) || fclose(ostream) == EOF) + { + tmp = outfile.string(); + print_stderr("uniq-u: Error while writing {}\n", tmp); + error("fclose", "I/O Error."); } -} -void uniq_u(const std::string& in_file, const std::string& out_file) -{ - using namespace _uniq_u; - - check_file(in_file.c_str(), out_file.c_str()); + freebuffer(&lb1); + freebuffer(&lb2); } - -#endif diff --git a/tests/utils.hpp b/tests/utils.hpp new file mode 100644 index 00000000..3040a74c --- /dev/null +++ b/tests/utils.hpp @@ -0,0 +1,224 @@ +/** + * @file utils.hpp + * @brief Utils for tests. + * @author ChenPi11 + * @copyright Copyright (C) 2024 The C++ Plus Project + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "buffer.hpp" + +/** + * @brief Compare two files. + * @param file1 The first file. + * @param file2 The second file. + */ +inline void compare_files(const std::filesystem::path &file1, const std::filesystem::path &file2) +{ + Buffer::read_from_file(file1).compare_assert(Buffer::read_from_file(file2)); +} + +/** + * @brief Write all content to a stream. + */ +inline void write_stream(std::ostream &stream, const std::string &buffer) +{ + stream.write(buffer.data(), buffer.size()); +} + +/** + * @brief Write all content to a file. + * @param output_file_path The file path. + * @param buffer The content to write. + * @param append Append to the file. + */ +inline void write_all(const std::filesystem::path &output_file_path, const std::string &buffer, bool append = false) +{ + std::ofstream output_file{output_file_path, + std::ios::binary | std::ios::ate | (append ? std::ios::app : std::ios::trunc)}; + if (!output_file.good()) + { + error(output_file_path.string(), "Unable to open output file."); + } + + output_file.write(buffer.data(), buffer.size()); + output_file.close(); +} + +/** + * @brief Write all content to a file. + * @param output_file_path The file path. + * @param buffer The content to write. + * @param size The size of the content. + * @param append Append to the file. + */ +inline void write_all(const std::filesystem::path &output_file_path, const Buffer &buffer, bool append = false) +{ + std::ofstream output_file{output_file_path, + std::ios::binary | std::ios::ate | (append ? std::ios::app : std::ios::trunc)}; + if (!output_file.good()) + { + error(output_file_path.string(), "Unable to open output file."); + } + + output_file.write(buffer.data(), buffer.size); + output_file.close(); +} + +/** + * @brief Merge files into one. + * @param files The files to merge. + * @param output_file_path The output file path. + */ +inline void merge_files(const std::vector &files, const std::filesystem::path &output_file_path) +{ + std::ofstream output_file{output_file_path, std::ios::binary | std::ios::trunc}; + if (!output_file.good()) + { + error(output_file_path.string(), "Unable to open output file."); + } + + for (const auto &file : files) + { + Buffer input_file = Buffer::read_from_file(file); + input_file.write_stream(output_file, true, true); + } + + output_file.close(); +} + +/** + * @brief Replace A to B in string src. + * @param src The source string. + * @param from The string to replace. + * @param to The string to replace with. + * @return The replaced string. + */ +inline std::string replace(const std::string &src, const std::string &from, const std::string &to) +{ + std::string result = src; + size_t pos = 0; + + while ((pos = result.find(from, pos)) != std::string::npos) + { + result.replace(pos, from.length(), to); + pos += to.length(); + } + + return result; +} + +constexpr std::uint32_t _fromhex(char hex) noexcept +{ + return (hex >= '0' && hex <= '9') ? hex - '0' : hex - 'A' + 10; +} + +constexpr std::uint32_t _fromhex(char hex1, char hex2) +{ + return _fromhex(hex1) << 4 | _fromhex(hex2); +} + +/** + * @brief Check if the system is big endian. + * @return True if the system is big endian, false otherwise. + */ +inline bool is_big_endian() noexcept +{ + return *reinterpret_cast("\0\x01") == 1; +} + +/** + * @brief Convert a hex string to a number. + * @param hex The hex string. + * @return The number. + */ +inline std::uint64_t fromhex(std::string hex) +{ + if (hex.size() % 2 != 0) + { + hex.insert(hex.begin(), '0'); + } + std::size_t x = 0; + for (std::size_t i = 0; i < hex.size(); i += 2) + { + hex[i] = std::toupper(hex[i]); + hex[i + 1] = std::toupper(hex[i + 1]); + if (!std::isxdigit(hex[i]) || !std::isxdigit(hex[i + 1])) + { + throw std::invalid_argument("Invalid hex: " + hex); + } + if (is_big_endian()) + { + x |= _fromhex(hex[i], hex[i + 1]) << (4 * i); + } + else + { + x |= _fromhex(hex[i], hex[i + 1]) << (4 * (hex.size() - i - 2)); + } + } + return x; +} + +constexpr std::uint32_t log16(std::uint32_t value) +{ + std::uint32_t result = 0; + while (value) + { + value >>= 4; + result++; + } + return result; +} + +/** + * @brief Convert a number to a hex string. + * @param value The number. + * @param length The length of the hex string. + */ +inline std::string tohex(std::uint32_t value, std::size_t length) +{ + std::uint32_t orig_value = value; + std::size_t orig_length = length; + std::string hex(length, '0'); + + while (value) + { + if (length <= 0) + { + return tohex(orig_value, orig_length + 1); + error("tohex", print_string("Value too large: {} + {}", hex, std::to_string(value))); + } + hex[--length] = "0123456789ABCDEF"[value % 16]; + value /= 16; + } + + return hex; +} diff --git a/tools/check-encodings.cpp b/tools/check-encodings.cpp new file mode 100644 index 00000000..5de0a94e --- /dev/null +++ b/tools/check-encodings.cpp @@ -0,0 +1,69 @@ +/** + * @file check-encodings.cpp + * @brief Check if all names in `encodings.h.snippet` are in upper case. + * @copyright Copyright (C) 2024 The C++ Plus Project. + * @note `name_canonicalize()` will upper the encoding name. So lower-case cannot be recognized. + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#include +#include +#include + +template void check_upper_case(const char *const (&names)[N], ...) +{ + for (std::size_t i = 0; i < N; i++) + { + const char *name = names[i]; + for (; *name; name++) + { + unsigned char c = *(unsigned char *)name; + if (std::islower(c)) + { + std::fprintf(stderr, "Encoding name `%s` is not in upper case.\n", names[i]); + std::exit(EXIT_FAILURE); + } + } + } +} + +int main(int argc, char *argv[]) +{ + if (argc != 1) + { + std::fprintf(stderr, "Usage: %s\n", argv[0]); + return EXIT_FAILURE; + } + +#define DEFENCODING(xxx_names, xxx, xxx_index, xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2) \ + { \ + static const char *const names[] = BRACIFY xxx_names; \ + check_upper_case(names); \ + } +#define DEFCODEPAGE(codepage, xxx) +#define DEFINDEX(alias, index) +#define BRACIFY(...) \ + { \ + __VA_ARGS__ \ + } + +#include "encodings.h.snippet" + + return EXIT_SUCCESS; +} diff --git a/tools/genaliases.cpp b/tools/genaliases.cpp index 3dea8685..2c5bf01f 100644 --- a/tools/genaliases.cpp +++ b/tools/genaliases.cpp @@ -1,5 +1,9 @@ +/** + * @file genaliases.cpp + * @brief Creates the aliases.gperf table. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ /* - * Copyright (C) 2023 The C++ Plus Project. * This file is part of the cppp-reiconv Library. * * The cppp-reiconv Library is free software; you can redistribute it @@ -13,41 +17,42 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv Library; see the file COPYING. + * License along with the cppp-reiconv Library; see the file LICENSE. * If not, see . */ -/* Creates the aliases.gperf table. */ - -#include +#include +#include +#include +#include +#include +#include -/* When we create shell scripts, we need to make sure that on Cygwin they have - Unix end-of-line characters, regardless of Cygwin choice of text mode vs. - binary mode. On z/OS, however, binary mode turns off charset tagging for - output files, which is not what we want. */ -#if defined __MVS__ -#define BINARY_MODE "" -#else -#define BINARY_MODE "b" -#endif +static inline void write_stream(std::ostream &out, const std::string_view data) +{ + out.write(data.data(), data.size()); +} -static void emit_alias(FILE* out, const char* alias, const char* c_name) +static void emit_alias(std::ostream &out, const char *alias, const char *c_name) { - /* Output alias in upper case. */ const char *s = alias; for (; *s; s++) { - unsigned char c = *(unsigned char*)s; + unsigned char c = *(unsigned char *)s; if (c >= 0x80) - exit(1); - if (c >= 'a' && c <= 'z') - c -= 'a' - 'A'; - putc(c, out); + { + std::fprintf(stderr, "Error: non-ASCII character in alias '%s'\n", alias); + exit(EXIT_FAILURE); + } + c = std::toupper(c); + out.put(c); } - fprintf(out, ", ei_%s\n", c_name); + write_stream(out, ", ei_"); + write_stream(out, c_name); + out.put('\n'); } -static void emit_encoding(FILE* out, const char* const* names, size_t n, const char* c_name) +static void emit_encoding(std::ofstream &out, const char *const *names, size_t n, const char *c_name) { for (; n > 0; names++, n--) { @@ -55,56 +60,56 @@ static void emit_encoding(FILE* out, const char* const* names, size_t n, const c } } -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { - char* aliases_file_name; - FILE* aliases_file; + std::string aliases_file_name; if (argc != 2) { - fprintf(stderr, "Usage: %s aliases.gperf\n", argv[0]); - return 1; + std::fprintf(stderr, "Usage: %s aliases-file\n", argv[0]); + return EXIT_FAILURE; } aliases_file_name = argv[1]; - aliases_file = fopen(aliases_file_name, "w"); - if (aliases_file == NULL) + std::ofstream aliases_file{aliases_file_name, std::ios::out | std::ios::trunc}; + + if (!aliases_file.good()) { - fprintf(stderr, "Could not open '%s' for writing\n", aliases_file_name); - return 1; + std::perror(aliases_file_name.c_str()); + return EXIT_FAILURE; } - fprintf(aliases_file, "struct alias { int name; unsigned int encoding_index; };\n"); - fprintf(aliases_file, "%%struct-type\n"); - fprintf(aliases_file, "%%language=C++\n"); - fprintf(aliases_file, "%%define hash-function-name aliases_hash\n"); - fprintf(aliases_file, "%%define lookup-function-name aliases_lookup\n"); - fprintf(aliases_file, "%%7bit\n"); - fprintf(aliases_file, "%%readonly-tables\n"); - fprintf(aliases_file, "%%global-table\n"); - fprintf(aliases_file, "%%define word-array-name aliases\n"); - fprintf(aliases_file, "%%pic\n"); - fprintf(aliases_file, "%%%%\n"); + write_stream(aliases_file, "/* This file is automatically generated. Do not edit. */\n"); + write_stream(aliases_file, "struct alias { int name; unsigned int encoding_index; };\n"); + write_stream(aliases_file, "%struct-type\n"); + write_stream(aliases_file, "%language=C++\n"); + write_stream(aliases_file, "%define hash-function-name aliases_hash\n"); + write_stream(aliases_file, "%define lookup-function-name aliases_lookup\n"); + write_stream(aliases_file, "%7bit\n"); + write_stream(aliases_file, "%readonly-tables\n"); + write_stream(aliases_file, "%global-table\n"); + write_stream(aliases_file, "%define word-array-name aliases\n"); + write_stream(aliases_file, "%pic\n"); + write_stream(aliases_file, "%%\n"); -#define DEFENCODING(xxx_names, codepage, xxx, xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2) \ +#define DEFENCODING(xxx_names, xxx, xxx_index, xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2) \ { \ static const char *const names[] = BRACIFY xxx_names; \ emit_encoding(aliases_file, names, sizeof(names) / sizeof(names[0]), #xxx); \ } -#define BRACIFY(...) \ - { \ - __VA_ARGS__ \ - } -#define DEFALIAS(xxx_alias, xxx) emit_alias(aliases_file, xxx_alias, #xxx); +#define DEFCODEPAGE(codepage, xxx) +#define DEFINDEX(alias, index) +#define BRACIFY(...) {__VA_ARGS__} -#include "encodings.def" +#include "encodings.h.snippet" -#undef DEFALIAS -#undef BRACIFY -#undef DEFENCODING + aliases_file.close(); + if (!aliases_file.good()) + { + std::perror(aliases_file_name.c_str()); + return EXIT_FAILURE; + } - if (ferror(aliases_file) || fclose(aliases_file)) - return 1; - return 0; + return EXIT_SUCCESS; } diff --git a/tools/genaliases2.cpp b/tools/genaliases2.cpp deleted file mode 100644 index 3ff60891..00000000 --- a/tools/genaliases2.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2023 The C++ Plus Project. - * This file is part of the cppp-reiconv Library. - * - * The cppp-reiconv Library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv Library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv Library; see the file COPYING. - * If not, see . - */ - -/* Creates the aliases2.h table. */ - -#include - -static unsigned int counter = 0; - -static void emit_alias(FILE* out, const char* tag, const char* alias, const char* c_name) -{ - fprintf(out, " S(%s_%u, \"", tag, counter); - /* Output alias in upper case. */ - { - const char* s = alias; - for (; *s; s++) - { - unsigned char c = *(unsigned char*)s; - if (c >= 0x80) - exit(1); - if (c >= 'a' && c <= 'z') - c -= 'a' - 'A'; - putc(c, out); - } - } - fprintf(out, "\", ei_%s )\n", c_name); - counter++; -} - -static void emit_encoding(FILE* out, const char* tag, const char* const* names, size_t n, const char* c_name) -{ - for (; n > 0; names++, n--) - emit_alias(out, tag, *names, c_name); -} - -int main(int argc, char* argv[]) -{ - const char* tag; - char* aliases_file_name; - FILE* aliases_file; - - if (argc != 3) - { - fprintf(stderr, "Usage: genaliases2 tag aliases.h\n"); - return 1; - } - - tag = argv[1]; - aliases_file_name = argv[2]; - - aliases_file = fopen(aliases_file_name, "w"); - if (aliases_file == NULL) - { - fprintf(stderr, "Could not open '%s' for writing\n", aliases_file_name); - return 1; - } - -#define DEFENCODING(xxx_names, codepage, xxx, xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2) \ - { \ - static const char* const names[] = BRACIFY xxx_names; \ - emit_encoding(aliases_file, tag, names, sizeof(names) / sizeof(names[0]), #xxx); \ - } -#define BRACIFY(...) \ - { \ - __VA_ARGS__ \ - } -#define DEFALIAS(xxx_alias, xxx) emit_alias(aliases_file, tag, xxx_alias, #xxx); -#ifdef USE_AIX -#include "encodings_aix.def" -#endif -#ifdef USE_OSF1 -#include "encodings_osf1.def" -#endif -#ifdef USE_DOS -#include "encodings_dos.def" -#endif -#ifdef USE_ZOS -#include "encodings_zos.def" -#endif -#ifdef USE_EXTRA -#include "encodings_extra.def" -#endif -#undef DEFALIAS -#undef BRACIFY -#undef DEFENCODING - if (ferror(aliases_file) || fclose(aliases_file)) - return 1; - return 0; -} diff --git a/tools/genflags.cpp b/tools/genflags.cpp deleted file mode 100644 index 6fa84af6..00000000 --- a/tools/genflags.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2023 The C++ Plus Project. - * This file is part of the cppp-reiconv Library. - * - * The cppp-reiconv Library is free software; you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * The cppp-reiconv Library is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the cppp-reiconv Library; see the file COPYING. - * If not, see . - */ - -/* Creates the flags.h include file. */ - -#include -#include -#include - -/* Consider all encodings, including the system dependent ones. */ -#define USE_AIX -#define USE_OSF1 -#define USE_DOS -#define USE_ZOS -#define USE_EXTRA - -struct loop_funcs -{ -}; -struct iconv_hooks -{ -}; -struct iconv_fallbacks -{ -}; -#define ICONV_SURFACE_EBCDIC_ZOS_UNIX 1 -#include "converters.h" - -static void emit_encoding(struct wctomb_funcs* ofuncs, const char* c_name) -{ - /* Prepare a converter struct. */ - struct conv_struct conv; - memset(&conv, '\0', sizeof(conv)); - conv.ofuncs = *ofuncs; - - { - /* See whether the encoding can encode the accents and quotation marks. */ - ucs4_t probe[6] = { - 0x0060, 0x00b4, 0x2018, 0x2019, 0x3131, 0x3163, - }; - int res[6]; - int i; - for (i = 0; i < 6; i++) - { - unsigned char buf[10]; - memset(&conv.ostate, '\0', sizeof(state_t)); - res[i] = (conv.ofuncs.xxx_wctomb(&conv, buf, probe[i], sizeof(buf)) != RET_ILUNI); - } - printf("#define ei_%s_oflags (", c_name); - { - int first = 1; - if (res[0] && res[1]) - { - printf("HAVE_ACCENTS"); - first = 0; - } - if (res[2] && res[3]) - { - if (!first) - printf(" | "); - printf("HAVE_QUOTATION_MARKS"); - first = 0; - } - if (res[4] && res[5]) - { - if (!first) - printf(" | "); - printf("HAVE_HANGUL_JAMO"); - first = 0; - } - if (first) - printf("0"); - } - printf(")\n"); - } -} - -int main() -{ - int bitmask = 1; - printf("/* Generated automatically by genflags. */\n"); - printf("\n"); - printf("/* Set if the encoding can encode\n"); - printf(" the acute and grave accents U+00B4 and U+0060. */\n"); - printf("#define HAVE_ACCENTS %d\n", bitmask); - printf("\n"); - bitmask = bitmask << 1; - printf("/* Set if the encoding can encode\n"); - printf(" the single quotation marks U+2018 and U+2019. */\n"); - printf("#define HAVE_QUOTATION_MARKS %d\n", bitmask); - printf("\n"); - bitmask = bitmask << 1; - printf("/* Set if the encoding can encode\n"); - printf(" the double-width Hangul letters (Jamo) U+3131 to U+3163. */\n"); - printf("#define HAVE_HANGUL_JAMO %d\n", bitmask); - printf("\n"); - -#define DEFENCODING(xxx_names, codepage, xxx, xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2) \ - { \ - struct wctomb_funcs ofuncs = xxx_ofuncs1, xxx_ofuncs2; \ - emit_encoding(&ofuncs, #xxx); \ - } -#define DEFALIAS(xxx_alias, xxx) /* nothing */ -/* Consider all encodings, including the system dependent ones. */ -#include "encodings.def" -#include "encodings_aix.def" -#include "encodings_dos.def" -#include "encodings_extra.def" -#include "encodings_osf1.def" -#include "encodings_zos.def" -#undef DEFALIAS -#undef DEFENCODING - - if (ferror(stdout) || fclose(stdout)) - return 1; - return 0; -} diff --git a/tools/genindexes.cpp b/tools/genindexes.cpp new file mode 100644 index 00000000..105fc67b --- /dev/null +++ b/tools/genindexes.cpp @@ -0,0 +1,113 @@ +/** + * @file genaliases.cpp + * @brief Generate index enum for reiconv users. + * @copyright Copyright (C) 2024 The C++ Plus Project. + */ +/* + * This file is part of the cppp-reiconv Library. + * + * The cppp-reiconv Library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * The cppp-reiconv Library is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the cppp-reiconv Library; see the file LICENSE. + * If not, see . + */ + +#include +#include +#include + +#include "encoding_indexes.h" // IWYU pragma: keep + +#define DEFENCODING(xxx_names, xxx, xxx_index, xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2) \ + {#xxx_index, ei_##xxx}, +#define DEFCODEPAGE(codepage, xxx) +#define DEFINDEX(alias, index) + +std::unordered_map enum_data = { +#include "encodings.h.snippet" +}; + +#undef DEFINDEX +#undef DEFCODEPAGE +#undef DEFENCODING + +#define DEFENCODING(xxx_names, xxx, xxx_index, xxx_ifuncs1, xxx_ifuncs2, xxx_ofuncs1, xxx_ofuncs2) +#define DEFCODEPAGE(codepage, xxx) +#define DEFINDEX(alias, index) {#alias, #index}, + +std::unordered_map aliases = { +#include "encodings.h.snippet" +}; + +#undef DEFINDEX +#undef DEFCODEPAGE +#undef DEFENCODING + +void cpp_gen() +{ + std::puts("namespace reiconv::encoding"); + std::puts("{"); + std::puts(" enum class Encodings"); + std::puts(" {"); + for (auto &it : enum_data) + { + std::printf(" %s = %d,\n", it.first.c_str(), it.second); + } + for (auto &it : aliases) + { + std::printf(" %s = %s,\n", it.first.c_str(), it.second.c_str()); + } + std::puts(" };"); + std::puts("} // reiconv::encoding"); + std::fflush(stdout); +} + +void c_gen() +{ + std::puts("enum"); + std::puts("{"); + for (auto &it : enum_data) + { + std::printf(" ENCODING_%s = %d,\n", it.first.c_str(), it.second); + } + for (auto &it : aliases) + { + std::printf(" ENCODING_%s = ENCODING_%s,\n", it.first.c_str(), it.second.c_str()); + } + std::puts("};"); + std::fflush(stdout); +} + +int main(int argc, char* argv[]) +{ + if (argc != 2) + { + std::fprintf(stderr, "Usage: %s [C | C++]\n", argv[0]); + return EXIT_FAILURE; + } + + if (std::string(argv[1]) == "C") + { + c_gen(); + } + else if (std::string(argv[1]) == "C++") + { + cpp_gen(); + } + else + { + std::fprintf(stderr, "Usage: %s [C | C++]\n", argv[0]); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/windows/libcppp-reiconv.rc.in b/windows/cppp-reiconv.rc.in similarity index 87% rename from windows/libcppp-reiconv.rc.in rename to windows/cppp-reiconv.rc.in index b87c0d19..1f5b2df1 100644 --- a/windows/libcppp-reiconv.rc.in +++ b/windows/cppp-reiconv.rc.in @@ -1,4 +1,4 @@ -/* Resources for iconv.dll */ +/* Resources for cppp-reiconv.dll */ #include @@ -28,11 +28,11 @@ BEGIN VALUE "CompanyName", "The C++ Plus Project\0" VALUE "FileDescription", "LGPLed cppp-reiconv for Windows\0" VALUE "FileVersion", PROJECT_VERSION "\0" - VALUE "InternalName", "libcppp-reiconv.dll\0" + VALUE "InternalName", "cppp-reiconv.dll\0" VALUE "LegalCopyright", "Copyright (C) 2023\0" VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "libcppp-reiconv.dll\0" - VALUE "ProductName", "cppp-reiconv: character set conversion library\0" + VALUE "OriginalFilename", "cppp-reiconv.dll\0" + VALUE "ProductName", "cppp-reiconv: Character set conversion library.\0" VALUE "ProductVersion", PROJECT_VERSION "\0" END END