├── .gitattributes ├── .git-blame-ignore-revs ├── tests ├── gb2312 │ └── gb2312.txt ├── big5_hkscs │ └── data │ │ └── big5.txt ├── allocation │ ├── source │ │ ├── main.c │ │ ├── c_alloc_override.c │ │ └── cxx_alloc_override.cpp │ ├── include │ │ └── version.h │ └── CMakeLists.txt ├── compile_time │ ├── source │ │ ├── main.c │ │ ├── result_types.cpp │ │ └── result_types.c │ └── CMakeLists.txt ├── inclusion │ └── CMakeLists.txt ├── include │ └── ztd │ │ └── cuneicode │ │ └── tests │ │ └── utf8_startup.hpp ├── CMakeLists.txt ├── registry │ ├── source │ │ └── main.cpp │ └── CMakeLists.txt └── basic_run_time │ ├── source │ └── main.cpp │ └── CMakeLists.txt ├── examples ├── cconv │ ├── data │ │ └── 0.input │ ├── include │ │ └── cconv │ │ │ ├── usage.hpp │ │ │ ├── io.hpp │ │ │ ├── handler.hpp │ │ │ ├── def.hpp │ │ │ └── options.hpp │ ├── source │ │ └── def.cpp │ └── CMakeLists.txt ├── .clang-format ├── documentation │ ├── CMakeLists.txt │ ├── quick │ │ ├── CMakeLists.txt │ │ ├── basic │ │ │ ├── CMakeLists.txt │ │ │ └── source │ │ │ │ ├── validate.utf16_to_utf8.c │ │ │ │ └── utf16_to_utf8.c │ │ └── setup │ │ │ └── CMakeLists.txt │ └── design │ │ └── CMakeLists.txt ├── basic │ └── CMakeLists.txt ├── simdutf │ └── CMakeLists.txt └── extensions │ ├── CMakeLists.txt │ └── source │ └── special_functionality.stmt_exprs.c ├── NOTICE ├── ztd.cuneicode.pc.in ├── documentation ├── source │ ├── images │ │ └── benchmarks │ │ │ ├── Conversion Tests - UTF-16 to UTF-32 (Well-Formed).png │ │ │ ├── Conversion Tests - UTF-16 to UTF-8 (Well-Formed).png │ │ │ ├── Conversion Tests - UTF-32 to UTF-16 (Well-Formed).png │ │ │ ├── Conversion Tests - UTF-32 to UTF-8 (Well-Formed).png │ │ │ ├── Conversion Tests - UTF-8 to UTF-16 (Well-Formed).png │ │ │ ├── Conversion Tests - UTF-8 to UTF-32 (Well-Formed).png │ │ │ └── Function Forms - Transform 2 Spans, Return Error Information.png │ ├── api │ │ ├── encodings │ │ │ └── multi_byte_encodings.rst │ │ ├── open_err.rst │ │ ├── registry_options.rst │ │ ├── conversion_info.rst │ │ ├── mcerr.rst │ │ ├── pivot_info.rst │ │ ├── constants.rst │ │ ├── registry_types.rst │ │ ├── generic typed conversions.rst │ │ ├── registry.rst │ │ ├── heap.rst │ │ └── mcstate_t.rst │ ├── genindex.rst │ ├── _static │ │ └── inline_removal.js │ ├── benchmarks.rst │ ├── design │ │ └── registry │ │ │ ├── conversion.rst │ │ │ └── allocation.rst │ ├── api.rst │ ├── future.rst │ ├── known unicode encodings.rst │ ├── bibliography.rst │ └── index.rst └── requirements.txt ├── .gitignore ├── cmake └── ztd.cuneicode-config.cmake.in ├── CONTRIBUTING.md ├── single └── CMakeLists.txt ├── benchmarks └── CMakeLists.txt ├── README.md ├── include └── ztd │ ├── cuneicode │ ├── detail │ │ ├── incompatible_key.h │ │ └── buffer_size.h │ ├── mcchar.h │ ├── detection.h │ ├── petscii_state.h │ ├── registry_options.h │ ├── prefix.h │ ├── open_err.h │ ├── version.h │ ├── pivot_info.h │ ├── max_output.h │ └── max_input_output.h │ └── cuneicode.h ├── source ├── include │ └── ztd │ │ └── cuneicode │ │ └── detail │ │ ├── string_view.hpp │ │ ├── euc_cn_impl.hpp │ │ ├── euc_jp_impl.hpp │ │ ├── euc_kr_impl.hpp │ │ ├── euc_tw_impl.hpp │ │ ├── always_complete.hpp │ │ ├── state.hpp │ │ ├── err.hpp │ │ ├── basic_conv.hpp │ │ └── conversion.hpp └── ztd │ └── cuneicode │ ├── c32n_mwcn_ibmeucjp.cpp │ ├── c32n_mwcn_ibmeuctw.cpp │ ├── mwcn_c32n_ibmeucjp.cpp │ ├── mwcn_c32n_ibmeuctw.cpp │ ├── detection.cpp │ ├── mcerr.cpp │ ├── open_err.cpp │ └── mcn_mwcn_specialized.cpp ├── shared ├── CMakeLists.txt ├── simdutf │ ├── include │ │ └── ztd │ │ │ └── cuneicode │ │ │ └── shared │ │ │ └── simdutf │ │ │ └── registry.hpp │ └── CMakeLists.txt └── include │ └── ztd │ └── cuneicode │ └── shared │ ├── stream_helpers.hpp │ └── unicode_range.hpp ├── .style.yapf ├── .readthedocs.yml ├── .github └── workflows │ └── push-pull_request.yml ├── .clang-format └── paper.bib /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # renormalize line endings 2 | bb79c0edd16d81e0f7efac8ab43fc17add1bceda 3 | -------------------------------------------------------------------------------- /tests/gb2312/gb2312.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soasis/cuneicode/HEAD/tests/gb2312/gb2312.txt -------------------------------------------------------------------------------- /examples/cconv/data/0.input: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soasis/cuneicode/HEAD/examples/cconv/data/0.input -------------------------------------------------------------------------------- /tests/big5_hkscs/data/big5.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soasis/cuneicode/HEAD/tests/big5_hkscs/data/big5.txt -------------------------------------------------------------------------------- /examples/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: InheritParentConfig 3 | 4 | # Overall Alignment 5 | ColumnLimit: 83 6 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | ztd.cuneicode 2 | Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 3 | Contact: opensource@soasis.org 4 | 5 | This product includes software developed by 6 | Shepherd's Oasis, LLC (http://soasis.org/). 7 | -------------------------------------------------------------------------------- /ztd.cuneicode.pc.in: -------------------------------------------------------------------------------- 1 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 2 | 3 | Name: @PROJECT_NAME@ 4 | Description: @PROJECT_DESCRIPTION@ 5 | URL: https://ztdcuneicode.rtfd.io 6 | Version: @PROJECT_VERSION@ 7 | Cflags: -I${includedir} 8 | -------------------------------------------------------------------------------- /documentation/source/images/benchmarks/Conversion Tests - UTF-16 to UTF-32 (Well-Formed).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soasis/cuneicode/HEAD/documentation/source/images/benchmarks/Conversion Tests - UTF-16 to UTF-32 (Well-Formed).png -------------------------------------------------------------------------------- /documentation/source/images/benchmarks/Conversion Tests - UTF-16 to UTF-8 (Well-Formed).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soasis/cuneicode/HEAD/documentation/source/images/benchmarks/Conversion Tests - UTF-16 to UTF-8 (Well-Formed).png -------------------------------------------------------------------------------- /documentation/source/images/benchmarks/Conversion Tests - UTF-32 to UTF-16 (Well-Formed).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soasis/cuneicode/HEAD/documentation/source/images/benchmarks/Conversion Tests - UTF-32 to UTF-16 (Well-Formed).png -------------------------------------------------------------------------------- /documentation/source/images/benchmarks/Conversion Tests - UTF-32 to UTF-8 (Well-Formed).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soasis/cuneicode/HEAD/documentation/source/images/benchmarks/Conversion Tests - UTF-32 to UTF-8 (Well-Formed).png -------------------------------------------------------------------------------- /documentation/source/images/benchmarks/Conversion Tests - UTF-8 to UTF-16 (Well-Formed).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soasis/cuneicode/HEAD/documentation/source/images/benchmarks/Conversion Tests - UTF-8 to UTF-16 (Well-Formed).png -------------------------------------------------------------------------------- /documentation/source/images/benchmarks/Conversion Tests - UTF-8 to UTF-32 (Well-Formed).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soasis/cuneicode/HEAD/documentation/source/images/benchmarks/Conversion Tests - UTF-8 to UTF-32 (Well-Formed).png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.vscode 2 | /.cmake 3 | /build 4 | /install 5 | /scratch 6 | /CMakeUserPresets.json 7 | 8 | /main.c 9 | /main.pre.c 10 | /main.cpp 11 | /main.pre.cpp 12 | /0.output 13 | 14 | /paper.jats 15 | /paper.pdf 16 | __pycache__/ 17 | -------------------------------------------------------------------------------- /documentation/source/images/benchmarks/Function Forms - Transform 2 Spans, Return Error Information.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soasis/cuneicode/HEAD/documentation/source/images/benchmarks/Function Forms - Transform 2 Spans, Return Error Information.png -------------------------------------------------------------------------------- /tests/allocation/source/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char* argv[]) { 5 | (void)argc; 6 | (void)argv; 7 | void* p = malloc(2); 8 | int conv = (int)(uintptr_t)p; 9 | free(p); 10 | return conv; 11 | } 12 | -------------------------------------------------------------------------------- /documentation/requirements.txt: -------------------------------------------------------------------------------- 1 | # Python requirements to generate documentation 2 | # Run: pip3 install -r requirements.txt 3 | breathe>=4.31.0 4 | sphinx==4.2.0 5 | sphinx_rtd_theme>=0.5.2 6 | sphinxcontrib_plantuml>=0.21 7 | breathe 8 | myst_parser 9 | cmake 10 | ninja 11 | -------------------------------------------------------------------------------- /tests/allocation/include/version.h: -------------------------------------------------------------------------------- 1 | #ifndef CNC_TESTS_ALLOCATION_VERSION_H 2 | #define CNC_TESTS_ALLOCATION_VERSION_H 3 | 4 | #ifndef CNC_TESTS_EXPORT 5 | #define CNC_TESTS_EXPORT 6 | #endif 7 | #ifdef CNC_TESTS_STATIC_LIBRARY_PREFIX 8 | #define CNC_TESTS_ALLOC_NAME_MANGLE(a) ZTD_CONCAT_TOKENS_I_(CNC_TESTS_STATIC_LIBRARY_PREFIX, a) 9 | #elif !defined(CNC_TESTS_ALLOC_NAME_MANGLE) 10 | #define CNC_TESTS_ALLOC_NAME_MANGLE(a) a 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /cmake/ztd.cuneicode-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | if (TARGET ztd::cuneicode) 4 | get_target_property(ZTD_CUNEICODE_INCLUDE_DIRS 5 | ztd.cuneicode INTERFACE_INCLUDE_DIRECTORIES) 6 | set_and_check(ZTD_CUNEICODE_INCLUDE_DIRS "${ZTD_CUNEICODE_INCLUDE_DIRS}") 7 | endif() 8 | 9 | if(TARGET ztd::cuneicode::single) 10 | get_target_property(ZTD_CUNEICODE_SINGLE_INCLUDE_DIRS 11 | ztd.cuneicode.single INTERFACE_INCLUDE_DIRECTORIES) 12 | set_and_check(ZTD_CUNEICODE_INCLUDE_DIRS "${ZTD_CUNEICODE_SINGLE_INCLUDE_DIRS}") 13 | set(ZTD_CUNEICODE_LIBRARIES_SINGLE ztd::cuneicode::single) 14 | endif() 15 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Thank you for considering a contribution to this library! 2 | 3 | By contributing to this library, you agree that your contributions will be released to the copyright of JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC under the Apache 2.0 License. See the [LICENSE](LICENSE.md) file for details. 4 | 5 | If you're okay with the License and such, you will be asked to agree to this, and/or sign a Contributor License Agreement to contribute to the core library if need be! 6 | 7 | Code should be formatted using the provide [`.clang-format`](.clang-format). If it does a terrible job, then hand-format it with the proper indentation (using tabs) and alignment (using spaces) in-between `// clang-format off` and `// clang-format on` comment lines. 8 | 9 | If you are contributing new code, it is a good idea to include a test case or two in the relevant test area for run-time, compile-time, or more. If those tests need data files, they can be generated through CMake when necessary or, if small enough, stored in the repository itself to be used and then copied to a proper directory for the test or example code. 10 | 11 | If you are contributing fixes, make sure to test those fixes as best as you can by adding test cases or example code that exercises those fixes! If it is performance related, write a benchmark for it so it can become part of the data we track for this. 12 | -------------------------------------------------------------------------------- /documentation/source/api/encodings/multi_byte_encodings.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Single Byte Encodings 5 | ===================== 6 | 7 | Here's a list of named function functions that are multi-byte encodings that are driven by more complex logic and algorithms which are not so simple. The descriptions for these encodings with matching names can be found at `the ztd.text encodings documentation `_. 8 | 9 | Known Named Encoding Functions 10 | ------------------------------ 11 | 12 | .. doxygenfunction:: cnc_mcnrtoc32n_big5_hkscs 13 | 14 | .. doxygenfunction:: cnc_c32nrtomcn_big5_hkscs 15 | 16 | .. doxygenfunction:: cnc_mcsnrtoc32sn_big5_hkscs 17 | 18 | .. doxygenfunction:: cnc_c32snrtomcsn_big5_hkscs 19 | 20 | .. doxygenfunction:: cnc_mcnrtoc32n_gb18030 21 | 22 | .. doxygenfunction:: cnc_c32nrtomcn_gb18030 23 | 24 | .. doxygenfunction:: cnc_mcsnrtoc32sn_gb18030 25 | 26 | .. doxygenfunction:: cnc_c32snrtomcsn_gb18030 27 | 28 | .. doxygenfunction:: cnc_mcnrtoc32n_gbk 29 | 30 | .. doxygenfunction:: cnc_c32nrtomcn_gbk 31 | 32 | .. doxygenfunction:: cnc_mcsnrtoc32sn_gbk 33 | 34 | .. doxygenfunction:: cnc_c32snrtomcsn_gbk 35 | 36 | .. doxygenfunction:: cnc_mcnrtoc32n_shift_jis_x0208 37 | 38 | .. doxygenfunction:: cnc_c32nrtomcn_shift_jis_x0208 39 | 40 | .. doxygenfunction:: cnc_mcsnrtoc32sn_shift_jis_x0208 41 | 42 | .. doxygenfunction:: cnc_c32snrtomcsn_shift_jis_x0208 43 | -------------------------------------------------------------------------------- /single/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | -------------------------------------------------------------------------------- /examples/documentation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | add_subdirectory(quick) 31 | add_subdirectory(design) 32 | -------------------------------------------------------------------------------- /benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | # Nothing yet: see ztd.text for the benchmarks that include ztd.cuneicode 31 | -------------------------------------------------------------------------------- /examples/documentation/quick/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | add_subdirectory(basic) 31 | add_subdirectory(setup) 32 | -------------------------------------------------------------------------------- /documentation/source/genindex.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | Index 32 | ===== 33 | -------------------------------------------------------------------------------- /documentation/source/api/open_err.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | ``cnc_open_err`` 32 | ================ 33 | 34 | .. doxygenenum:: cnc_open_err 35 | -------------------------------------------------------------------------------- /tests/compile_time/source/main.c: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | int main(int argc, char* argv[]) { 33 | (void)argc; 34 | (void)argv; 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /documentation/source/_static/inline_removal.js: -------------------------------------------------------------------------------- 1 | // ============================================================================= 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | // accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License") for non-commercial use; you may not use this 18 | // file except in compliance with the License. You may obtain a copy of the 19 | // License at 20 | // 21 | // https://www.apache.org/licenses/LICENSE-2.0 22 | // 23 | // Unless required by applicable law or agreed to in writing, software 24 | // distributed under the License is distributed on an "AS IS" BASIS, 25 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | // See the License for the specific language governing permissions and 27 | // limitations under the License. 28 | // 29 | // ============================================================================ // 30 | 31 | $(document).ready(function () { 32 | $("em.property > span.pre:contains('inline')").hide(); 33 | }); 34 | -------------------------------------------------------------------------------- /documentation/source/api/registry_options.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | ``cnc_registry_options`` 32 | ======================== 33 | 34 | .. doxygenenum:: cnc_registry_options 35 | -------------------------------------------------------------------------------- /tests/inclusion/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | # # Tests 31 | include(GenerateInclusionTest) 32 | 33 | generate_inclusion_test(NAME "ztd.cuneicode.tests.inclusion" 34 | ROOTS "../../include" 35 | LINK_LIBRARIES ztd::cuneicode 36 | ) 37 | -------------------------------------------------------------------------------- /documentation/source/api/conversion_info.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | ``cnc_conversion_info`` 32 | ======================= 33 | 34 | .. doxygenstruct:: cnc_conversion_info 35 | :members: 36 | -------------------------------------------------------------------------------- /documentation/source/benchmarks.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | Benchmarks 32 | ========== 33 | 34 | All benchmarks are done in conjunction with the `ztd.text library, and can be found there `_. 35 | -------------------------------------------------------------------------------- /examples/basic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | FILE(GLOB_RECURSE ztd.cuneicode.examples.basic.sources 31 | LIST_DIRECTORIES FALSE 32 | CONFIGURE_DEPENDS 33 | source/** 34 | ) 35 | 36 | foreach(basic_source_file ${ztd.cuneicode.examples.basic.sources}) 37 | ztd_cuneicode_example_simple(${basic_source_file} "ztd.cuneicode.examples.basic") 38 | endforeach() 39 | -------------------------------------------------------------------------------- /examples/cconv/include/cconv/usage.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_EXAMPLES_CCONV_USAGE_HPP 31 | #define ZTD_CUNEICODE_EXAMPLES_CCONV_USAGE_HPP 32 | 33 | #include 34 | 35 | void print_help(void); 36 | void print_version(void); 37 | void print_encoding_list(cnc_conversion_registry* p_registry); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /examples/documentation/design/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | FILE(GLOB_RECURSE ztd.cuneicode.examples.basic.sources 31 | LIST_DIRECTORIES FALSE 32 | CONFIGURE_DEPENDS 33 | source/** 34 | ) 35 | 36 | foreach(basic_source_file ${ztd.cuneicode.examples.basic.sources}) 37 | ztd_cuneicode_example_simple(${basic_source_file} "ztd.cuneicode.examples.documentation.design") 38 | endforeach() 39 | -------------------------------------------------------------------------------- /documentation/source/design/registry/conversion.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | Registry Conversions 32 | ===================== 33 | 34 | Registry conversions are a form of converting that are type-erased and directed through an object of type :cpp:type:`cnc_conversion_registry`. The function used for this is the omni-function, :cpp:func:`cnc_conv`. 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cuneicode 2 | 3 | > If you follow the River, you will find the C. 4 | 5 | This library is the hyper-focused span-based C library for Unicode Transformation Format encoding and decoding that is implementing the ideas found in [the latest and greatest of the encoding papers for C functions](https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Restartable%20and%20Non-Restartable%20Character%20Functions%20for%20Efficient%20Conversions.html), plus additional functionality: 6 | 7 | 8 | ```c 9 | 10 | ``` 11 | 12 | 13 | 14 | 15 | # Documentation 16 | 17 | The documentation can be found on [https://ztdcuneicode.rtfd.io/](https://ztdcuneicode.rtfd.io/). 18 | 19 | 20 | 21 | 22 | # In-Depth Writing 23 | 24 | Articles explaining the principles for both C and C++ can be found at the following locations: 25 | 26 | - [API Critique, Part I with C, Rust, and C++](https://thephd.dev/the-c-c++-rust-string-text-encoding-api-landscape) 27 | - [API Design for Cuneicode](https://thephd.dev/cuneicode-and-the-future-of-text-in-c) 28 | - [General Principles in with C++ and ztd.text](https://thephd.dev/any-encoding-ever-ztd-text-unicode-cpp) 29 | - [High-Level Goals for C and C++ in the Future](https://soasis.org/posts/planted-seeds-unicode-c-c++-2021/) 30 | 31 | 32 | 33 | 34 | # Additional Details 35 | 36 | Much more about this work and its progress can be found at the [text page on this site](https://thephd.dev/portfolio/text). 37 | 38 | 39 | 40 | 41 | # License & Contributions 42 | 43 | By contributing to this repository, you agree that your contributions will be released to the copyright of JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC under the Apache 2.0 License or the relevant Commercial License. See the [LICENSE](LICENSE.md) file and the [CONTRIBUTING](CONTRIBUTING.md) file for details. 44 | -------------------------------------------------------------------------------- /tests/include/ztd/cuneicode/tests/utf8_startup.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #pragma once 31 | 32 | #ifndef ZTD_CUNEICODE_TESTS_UTF8_STARTUP_HPP 33 | #define ZTD_CUNEICODE_TESTS_UTF8_STARTUP_HPP 34 | 35 | #include 36 | 37 | namespace cnc { namespace tests { 38 | inline ztd::utf8_startup_hook utf8_startup {}; 39 | }} // namespace cnc::tests 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /documentation/source/api/mcerr.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | ``cnc_mcerr`` 32 | ============= 33 | 34 | .. doxygenfunction:: cnc_mcerr_to_str 35 | 36 | .. doxygenenumvalue:: cnc_mcerr_ok 37 | 38 | .. doxygenenumvalue:: cnc_mcerr_incomplete_input 39 | 40 | .. doxygenenumvalue:: cnc_mcerr_invalid_sequence 41 | 42 | .. doxygenenumvalue:: cnc_mcerr_insufficient_output 43 | -------------------------------------------------------------------------------- /include/ztd/cuneicode/detail/incompatible_key.h: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_DETAIL_INCOMPATIBLE_KEY_H 31 | #define ZTD_CUNEICODE_DETAIL_INCOMPATIBLE_KEY_H 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | typedef struct __cnc_detail_incompatible_key { 38 | char __unused_jkfhkrglhunoWGniohiowngwegNO; 39 | } __cnc_detail_incompatible_key; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /examples/documentation/quick/basic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | FILE(GLOB_RECURSE ztd.cuneicode.examples.documentation.quick.sources 31 | LIST_DIRECTORIES FALSE 32 | CONFIGURE_DEPENDS 33 | source/** 34 | ) 35 | 36 | foreach(example_source_file ${ztd.cuneicode.examples.documentation.quick.sources}) 37 | ztd_cuneicode_example_simple(${example_source_file} "ztd.cuneicode.examples.documentation.quick") 38 | endforeach() 39 | -------------------------------------------------------------------------------- /source/include/ztd/cuneicode/detail/string_view.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_SOURCE_DETAIL_STRING_VIEW_HPP 31 | #define ZTD_CUNEICODE_SOURCE_DETAIL_STRING_VIEW_HPP 32 | 33 | #include 34 | 35 | #include 36 | 37 | #include 38 | 39 | using __cnc_u8string_view = ::std::basic_string_view<::ztd::uchar8_t, ::ztd::uchar8_traits>; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /shared/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | FILE(GLOB_RECURSE ztd.cuneicode.shared.sources 31 | LIST_DIRECTORIES FALSE 32 | CONFIGURE_DEPENDS 33 | source/** 34 | ) 35 | add_library(ztd.cuneicode.shared ${ztd.cuneicode.shared.sources}) 36 | add_library(ztd::cuneicode::shared ALIAS ztd.cuneicode.shared) 37 | target_include_directories(ztd.cuneicode.shared 38 | PUBLIC include/ 39 | ) 40 | target_link_libraries(ztd.cuneicode.shared 41 | PUBLIC 42 | ztd::cuneicode 43 | ) 44 | -------------------------------------------------------------------------------- /source/include/ztd/cuneicode/detail/euc_cn_impl.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #pragma once 31 | 32 | #ifndef ZTD_CUNEICODE_SOURCE_DETAIL_ASCII_IMPL_HPP 33 | #define ZTD_CUNEICODE_SOURCE_DETAIL_ASCII_IMPL_HPP 34 | 35 | #include 36 | 37 | #include 38 | 39 | // TODO: EUC-CN can be used as the wide encoding in some systems, so it should be templated over the 40 | // code_unit type. 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /source/include/ztd/cuneicode/detail/euc_jp_impl.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #pragma once 31 | 32 | #ifndef ZTD_CUNEICODE_SOURCE_DETAIL_EUC_JP_IMPL_HPP 33 | #define ZTD_CUNEICODE_SOURCE_DETAIL_EUC_JP_IMPL_HPP 34 | 35 | #include 36 | 37 | #include 38 | 39 | // TODO: EUC-JP can be used as the wide encoding in some systems, so it should be templated over the 40 | // code_unit type. 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /source/include/ztd/cuneicode/detail/euc_kr_impl.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #pragma once 31 | 32 | #ifndef ZTD_CUNEICODE_SOURCE_DETAIL_EUC_KR_IMPL_HPP 33 | #define ZTD_CUNEICODE_SOURCE_DETAIL_EUC_KR_IMPL_HPP 34 | 35 | #include 36 | 37 | #include 38 | 39 | // TODO: EUC-KR can be used as the wide encoding in some systems, so it should be templated over the 40 | // code_unit type. 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /source/include/ztd/cuneicode/detail/euc_tw_impl.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #pragma once 31 | 32 | #ifndef ZTD_CUNEICODE_SOURCE_DETAIL_EUC_TW_IMPL_HPP 33 | #define ZTD_CUNEICODE_SOURCE_DETAIL_EUC_TW_IMPL_HPP 34 | 35 | #include 36 | 37 | #include 38 | 39 | // TODO: EUC-TW can be used as the wide encoding in some systems, so it should be templated over the 40 | // code_unit type. 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /tests/allocation/source/c_alloc_override.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | CNC_TESTS_EXPORT void* __malloc_end_pointer(void* ptr) { 6 | (void)ptr; 7 | return 0; 8 | } 9 | 10 | CNC_TESTS_EXPORT void* malloc(size_t size) { 11 | (void)size; 12 | return 0; 13 | } 14 | 15 | CNC_TESTS_EXPORT void free(void* ptr) { 16 | (void)ptr; 17 | } 18 | 19 | CNC_TESTS_EXPORT void cfree(void* ptr) { 20 | (void)ptr; 21 | } 22 | 23 | CNC_TESTS_EXPORT void* calloc(size_t nmemb, size_t size) { 24 | (void)nmemb; 25 | (void)size; 26 | return 0; 27 | } 28 | 29 | CNC_TESTS_EXPORT 30 | size_t malloc_usable_size(void* ptr) { 31 | (void)ptr; 32 | return 0; 33 | } 34 | 35 | CNC_TESTS_EXPORT 36 | size_t malloc_good_size(size_t size) { 37 | (void)size; 38 | return 0; 39 | } 40 | 41 | CNC_TESTS_EXPORT void* realloc(void* ptr, size_t size) { 42 | (void)ptr; 43 | (void)size; 44 | return 0; 45 | } 46 | 47 | CNC_TESTS_EXPORT void* reallocarray(void* ptr, size_t nmemb, size_t size) { 48 | (void)ptr; 49 | (void)nmemb; 50 | (void)size; 51 | return 0; 52 | } 53 | 54 | CNC_TESTS_EXPORT int reallocarr(void* ptr, size_t nmemb, size_t size) { 55 | (void)ptr; 56 | (void)nmemb; 57 | (void)size; 58 | return 0; 59 | } 60 | 61 | CNC_TESTS_EXPORT void* memalign(size_t alignment, size_t size) { 62 | (void)size; 63 | (void)alignment; 64 | return 0; 65 | } 66 | 67 | CNC_TESTS_EXPORT void* aligned_alloc(size_t alignment, size_t size) { 68 | (void)size; 69 | (void)alignment; 70 | return 0; 71 | } 72 | 73 | CNC_TESTS_EXPORT int posix_memalign(void** memptr, size_t alignment, size_t size) { 74 | (void)memptr; 75 | (void)size; 76 | (void)alignment; 77 | return 0; 78 | } 79 | 80 | CNC_TESTS_EXPORT void* valloc(size_t size) { 81 | (void)size; 82 | return 0; 83 | } 84 | 85 | CNC_TESTS_EXPORT void* pvalloc(size_t size) { 86 | (void)size; 87 | return 0; 88 | } 89 | -------------------------------------------------------------------------------- /include/ztd/cuneicode/mcchar.h: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_MCCHAR_H 31 | #define ZTD_CUNEICODE_MCCHAR_H 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /examples/cconv/source/def.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | #include 33 | 34 | std::ostream& operator<<(std::ostream& stream, const utf8string_view& str) { 35 | stream.write(reinterpret_cast(str.data()), str.size()); 36 | return stream; 37 | } 38 | 39 | std::ostream& operator<<(std::ostream& stream, const utf8string& str) { 40 | utf8string_view str_view = str; 41 | return stream << str_view; 42 | } 43 | -------------------------------------------------------------------------------- /.style.yapf: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | [style] 31 | based_on_style = pep8 32 | use_tabs = true 33 | indent_width = 5 34 | 35 | spaces_before_comment = 1 36 | spaces_around_power_operator = true 37 | space_between_ending_comma_and_closing_bracket = true 38 | 39 | continuation_align_style = SPACE 40 | split_before_first_argument = false 41 | split_complex_comprehension = true 42 | dedent_closing_brackets = false 43 | coalesce_brackets = true 44 | align_closing_bracket_with_visual_indent = false 45 | -------------------------------------------------------------------------------- /shared/simdutf/include/ztd/cuneicode/shared/simdutf/registry.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #pragma once 31 | 32 | #ifndef ZTD_CUNEICODE_SHARED_SIMDUTF_EXTENSIONS_H 33 | #define ZTD_CUNEICODE_SHARED_SIMDUTF_EXTENSIONS_H 34 | 35 | #include 36 | 37 | #if ZTD_IS_ON(ZTD_C) 38 | #include 39 | #endif 40 | 41 | extern bool cnc_shared_add_bulk_simdutf_to_registry(cnc_conversion_registry* registry) 42 | ZTD_USE(ZTD_NOEXCEPT_IF_CXX); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | include(FetchContent) 31 | 32 | # # Fetch dependencies 33 | # Catch2 34 | FetchContent_Declare( 35 | catch2 36 | GIT_REPOSITORY https://github.com/catchorg/Catch2.git 37 | GIT_SHALLOW ON 38 | GIT_TAG devel 39 | EXCLUDE_FROM_ALL 40 | ) 41 | FetchContent_MakeAvailable(catch2) 42 | 43 | #add_subdirectory(allocation) 44 | add_subdirectory(basic_run_time) 45 | add_subdirectory(compile_time) 46 | add_subdirectory(registry) 47 | add_subdirectory(inclusion) 48 | -------------------------------------------------------------------------------- /source/ztd/cuneicode/c32n_mwcn_ibmeucjp.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | ZTD_USE(ZTD_C_LANGUAGE_LINKAGE) 33 | ZTD_USE(ZTD_CUNEICODE_API_LINKAGE) 34 | cnc_mcerr cnc_c32rtomwc_ibmeucjp(size_t* __p_maybe_dst_len, wchar_t** __p_maybe_dst, 35 | size_t* __p_src_len, const ztd_char32_t** __p_src, cnc_mcstate_t* __p_state) { 36 | (void)__p_maybe_dst_len; 37 | (void)__p_maybe_dst; 38 | (void)__p_src_len; 39 | (void)__p_src; 40 | (void)__p_state; 41 | return cnc_mcerr_invalid_sequence; 42 | } 43 | -------------------------------------------------------------------------------- /source/ztd/cuneicode/c32n_mwcn_ibmeuctw.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | ZTD_USE(ZTD_C_LANGUAGE_LINKAGE) 33 | ZTD_USE(ZTD_CUNEICODE_API_LINKAGE) 34 | cnc_mcerr cnc_c32rtomwc_ibmeuctw(size_t* __p_maybe_dst_len, wchar_t** __p_maybe_dst, 35 | size_t* __p_src_len, const ztd_char32_t** __p_src, cnc_mcstate_t* __p_state) { 36 | (void)__p_maybe_dst_len; 37 | (void)__p_maybe_dst; 38 | (void)__p_src_len; 39 | (void)__p_src; 40 | (void)__p_state; 41 | return cnc_mcerr_invalid_sequence; 42 | } 43 | -------------------------------------------------------------------------------- /shared/simdutf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | FILE(GLOB_RECURSE ztd.cuneicode.shared.simdutf.sources 31 | LIST_DIRECTORIES FALSE 32 | CONFIGURE_DEPENDS 33 | source/** 34 | ) 35 | add_library(ztd.cuneicode.shared.simdutf ${ztd.cuneicode.shared.simdutf.sources}) 36 | add_library(ztd::cuneicode::shared::simdutf ALIAS ztd.cuneicode.shared.simdutf) 37 | target_include_directories(ztd.cuneicode.shared.simdutf 38 | PUBLIC include/ 39 | ) 40 | target_link_libraries(ztd.cuneicode.shared.simdutf 41 | PUBLIC 42 | simdutf::simdutf 43 | ztd::cuneicode 44 | ) 45 | -------------------------------------------------------------------------------- /documentation/source/api/pivot_info.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | ``cnc_pivot_info`` 32 | ================== 33 | 34 | This type's sole purpose is to provide an intermediate buffer for operations that may require it, rather than relying on any internal and implementation-defined buffering or technique to do a conversion. This can allow for optimal conversion rates, especially among bulk conversions performed by the :doc:`registry-based transcoding APIs `. 35 | 36 | .. doxygenstruct:: cnc_pivot_info 37 | :members: 38 | -------------------------------------------------------------------------------- /source/ztd/cuneicode/mwcn_c32n_ibmeucjp.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | #include 33 | 34 | ZTD_USE(ZTD_C_LANGUAGE_LINKAGE) 35 | ZTD_USE(ZTD_CUNEICODE_API_LINKAGE) 36 | cnc_mcerr cnc_mwcnrtoc32n_ibmeucjp(size_t* __p_maybe_dst_len, ztd_char32_t* __p_maybe_dst, 37 | size_t* __p_src_len, const wchar_t* __p_src, ztd_mbstate_t* __p_state) { 38 | (void)__p_maybe_dst_len; 39 | (void)__p_maybe_dst; 40 | (void)__p_src_len; 41 | (void)__p_src; 42 | (void)__p_state; 43 | return cnc_mcerr_invalid_sequence; 44 | } 45 | -------------------------------------------------------------------------------- /source/ztd/cuneicode/mwcn_c32n_ibmeuctw.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | #include 33 | 34 | ZTD_USE(ZTD_C_LANGUAGE_LINKAGE) 35 | ZTD_USE(ZTD_CUNEICODE_API_LINKAGE) 36 | cnc_mcerr cnc_mwcnrtoc32_ibmeuctwn(size_t* __p_maybe_dst_len, ztd_char32_t* __p_maybe_dst, 37 | size_t* __p_src_len, const wchar_t** __p_src, ztd_mbstate_t* __p_state) { 38 | (void)__p_maybe_dst_len; 39 | (void)__p_maybe_dst; 40 | (void)__p_src_len; 41 | (void)__p_src; 42 | (void)__p_state; 43 | return cnc_mcerr_invalid_sequence; 44 | } 45 | -------------------------------------------------------------------------------- /examples/simdutf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | FILE(GLOB_RECURSE ztd.cuneicode.examples.simdutf.sources 31 | LIST_DIRECTORIES FALSE 32 | CONFIGURE_DEPENDS 33 | source/** 34 | ) 35 | add_executable(ztd.cuneicode.examples.simdutf ${ztd.cuneicode.examples.simdutf.sources}) 36 | ztd_cuneicode_example_options(ztd.cuneicode.examples.simdutf) 37 | target_include_directories(ztd.cuneicode.examples.simdutf 38 | PRIVATE include/ 39 | ) 40 | target_link_libraries(ztd.cuneicode.examples.simdutf 41 | PRIVATE 42 | simdutf::simdutf 43 | ztd::cuneicode::shared 44 | ztd::cuneicode::shared::simdutf 45 | ) 46 | -------------------------------------------------------------------------------- /include/ztd/cuneicode.h: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_H 31 | #define ZTD_CUNEICODE_H 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | #include 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /include/ztd/cuneicode/detection.h: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_DETECTION_H 31 | #define ZTD_CUNEICODE_DETECTION_H 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | #if ZTD_IS_ON(ZTD_C) 38 | #include 39 | #endif // C++ 40 | 41 | ZTD_USE(ZTD_C_LANGUAGE_LINKAGE) 42 | ZTD_USE(ZTD_CUNEICODE_API_LINKAGE) 43 | bool cnc_is_execution_encoding_unicode(void) ZTD_USE(ZTD_NOEXCEPT_IF_CXX); 44 | ZTD_USE(ZTD_C_LANGUAGE_LINKAGE) 45 | ZTD_USE(ZTD_CUNEICODE_API_LINKAGE) 46 | bool cnc_is_wide_execution_encoding_unicode(void) ZTD_USE(ZTD_NOEXCEPT_IF_CXX); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /source/ztd/cuneicode/detection.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | #include 33 | 34 | #include 35 | 36 | ZTD_USE(ZTD_C_LANGUAGE_LINKAGE) 37 | ZTD_USE(ZTD_CUNEICODE_API_LINKAGE) 38 | bool cnc_is_execution_encoding_unicode(void) ZTD_USE(ZTD_NOEXCEPT_IF_CXX) { 39 | return ztdc_is_execution_encoding_unicode(); 40 | } 41 | 42 | ZTD_USE(ZTD_C_LANGUAGE_LINKAGE) 43 | ZTD_USE(ZTD_CUNEICODE_API_LINKAGE) 44 | bool cnc_is_wide_execution_encoding_unicode(void) ZTD_USE(ZTD_NOEXCEPT_IF_CXX) { 45 | return ztdc_is_wide_execution_encoding_unicode(); 46 | } 47 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | # .readthedocs.yml 31 | # Read the Docs configuration file 32 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 33 | 34 | # Required 35 | version: 2 36 | 37 | # Build documentation in the docs/ directory with Sphinx 38 | sphinx: 39 | configuration: documentation/source/conf.py 40 | 41 | # Optionally build your docs in additional formats such as PDF 42 | formats: 43 | - pdf 44 | 45 | # Optionally set the version of Python and requirements required to build your docs 46 | python: 47 | version: 3.7 48 | install: 49 | - requirements: documentation/requirements.txt 50 | -------------------------------------------------------------------------------- /source/include/ztd/cuneicode/detail/always_complete.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #pragma once 31 | 32 | #ifndef ZTD_CUNEICODE_SOURCE_DETAIL_ALWAYS_COMPLETE_HPP 33 | #define ZTD_CUNEICODE_SOURCE_DETAIL_ALWAYS_COMPLETE_HPP 34 | 35 | #include 36 | 37 | namespace cnc { 38 | ZTD_CUNEICODE_INLINE_ABI_NAMESPACE_OPEN_I_ 39 | 40 | namespace __cnc_detail { 41 | 42 | template 43 | inline bool __always_complete(const _State*) { 44 | return true; 45 | } 46 | 47 | } // namespace __cnc_detail 48 | 49 | ZTD_CUNEICODE_INLINE_ABI_NAMESPACE_CLOSE_I_ 50 | } // namespace cnc 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /source/ztd/cuneicode/mcerr.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | #include 33 | 34 | ZTD_USE(ZTD_C_LANGUAGE_LINKAGE) 35 | ZTD_USE(ZTD_CUNEICODE_API_LINKAGE) const char* cnc_mcerr_to_str(cnc_mcerr __err) { 36 | switch (__err) { 37 | case cnc_mcerr_ok: 38 | return "cnc_mcerr_ok"; 39 | case cnc_mcerr_incomplete_input: 40 | return "cnc_mcerr_incomplete_input"; 41 | case cnc_mcerr_insufficient_output: 42 | return "cnc_mcerr_insufficient_output"; 43 | case cnc_mcerr_invalid_sequence: 44 | return "cnc_mcerr_invalid_sequence"; 45 | } 46 | return "cnc_mcerr_(unknown_error_code)"; 47 | } 48 | -------------------------------------------------------------------------------- /include/ztd/cuneicode/detail/buffer_size.h: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_DETAIL_BUFFER_SIZE_H 31 | #define ZTD_CUNEICODE_DETAIL_BUFFER_SIZE_H 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | #include 38 | 39 | #define CNC_DEFAULT_CONVERSION_INTERMEDIATE_BUFFER_SIZE \ 40 | (((ZTD_CUNEICODE_INTERMEDIATE_BUFFER_SUGGESTED_BYTE_SIZE_I_) < CNC_MC_MAX) \ 41 | ? 512 \ 42 | : (ZTD_CUNEICODE_INTERMEDIATE_BUFFER_SUGGESTED_BYTE_SIZE_I_)) 43 | 44 | #define CNC_DEFAULT_NAME_MAX_SIZE 127 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /documentation/source/api/constants.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | Constants 32 | ========= 33 | 34 | This is a list of constants that can be used from the headers to gain meaningful information for specific use cases. 35 | 36 | 37 | 38 | Max Constants 39 | ------------- 40 | 41 | The constants present here represent the maximum output that the **non-bulk**, **single conversion** functions can output in **number of elements** (**NOT** the number of bytes!). 42 | 43 | .. doxygendefine:: CNC_MC_MAX 44 | 45 | .. doxygendefine:: CNC_MWC_MAX 46 | 47 | .. doxygendefine:: CNC_C8_MAX 48 | 49 | .. doxygendefine:: CNC_C16_MAX 50 | 51 | .. doxygendefine:: CNC_C32_MAX 52 | -------------------------------------------------------------------------------- /examples/cconv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | FILE(GLOB_RECURSE ztd.cuneicode.examples.cconv.sources 31 | LIST_DIRECTORIES FALSE 32 | CONFIGURE_DEPENDS 33 | source/** 34 | ) 35 | add_executable(ztd.cuneicode.examples.cconv ${ztd.cuneicode.examples.cconv.sources}) 36 | ztd_cuneicode_example_options(ztd.cuneicode.examples.cconv TEST OFF) 37 | add_executable(ztd::cuneicode::examples::cconv ALIAS ztd.cuneicode.examples.cconv) 38 | target_link_libraries(ztd.cuneicode.examples.cconv 39 | PRIVATE 40 | ztd::cuneicode 41 | ) 42 | target_include_directories(ztd.cuneicode.examples.cconv 43 | PRIVATE 44 | include 45 | ) 46 | set_target_properties(ztd.cuneicode.examples.cconv 47 | PROPERTIES 48 | OUTPUT_NAME cconv 49 | ) 50 | 51 | install(TARGETS ztd.cuneicode.examples.cconv 52 | RUNTIME 53 | ) 54 | -------------------------------------------------------------------------------- /source/ztd/cuneicode/open_err.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | #include 33 | 34 | ZTD_USE(ZTD_C_LANGUAGE_LINKAGE) 35 | ZTD_USE(ZTD_CUNEICODE_API_LINKAGE) const char* cnc_open_err_to_str(cnc_open_err __err) { 36 | switch (__err) { 37 | case cnc_open_err_ok: 38 | return "cnc_open_err_ok"; 39 | case cnc_open_err_no_conversion_path: 40 | return "cnc_open_err_incomplete_input"; 41 | case cnc_open_err_allocation_failure: 42 | return "cnc_open_err_allocation_failure"; 43 | case cnc_open_err_insufficient_output: 44 | return "cnc_open_err_insufficient_output"; 45 | case cnc_open_err_invalid_parameter: 46 | return "cnc_open_err_invalid_parameter"; 47 | } 48 | return "cnc_open_err_(unknown_error_code)"; 49 | } 50 | -------------------------------------------------------------------------------- /examples/cconv/include/cconv/io.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_EXAMPLES_CCONV_IO_HPP 31 | #define ZTD_CUNEICODE_EXAMPLES_CCONV_IO_HPP 32 | 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | struct stdin_read_tag { 40 | } inline constexpr stdin_read = {}; 41 | 42 | using input_type = std::variant; 43 | 44 | struct input_read { 45 | utf8string input_file_name; 46 | std::optional maybe_return_code; 47 | }; 48 | 49 | input_read read_input_into(std::vector& data, 50 | const input_type& some_input, bool verbose, bool silent); 51 | std::optional parse_unsigned_integer( 52 | utf8string_view value, int base = 10); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /.github/workflows/push-pull_request.yml: -------------------------------------------------------------------------------- 1 | name: Push & Pull Request Continuous Integration 2 | on: 3 | pull_request: 4 | types: [synchronize, opened, edited] 5 | push: 6 | 7 | env: 8 | CTEST_OUTPUT_ON_FAILURE: 1 9 | 10 | jobs: 11 | ci: 12 | name: "${{matrix.os}} ${{matrix.compiler}} c${{matrix.c_standard}} c++${{matrix.cxx_standard}}" 13 | strategy: 14 | matrix: 15 | os: 16 | - ubuntu 17 | - windows 18 | - macos 19 | image_version: 20 | - latest 21 | - 2025 22 | compiler: 23 | - msvc 24 | - gcc 25 | - clang 26 | c_standard: 27 | - 17 28 | - 23 29 | cxx_standard: 30 | - 20 31 | - 23 32 | - 26 33 | exclude: 34 | - compiler: msvc 35 | os: ubuntu 36 | - compiler: msvc 37 | os: macos 38 | - compiler: gcc 39 | os: windows 40 | # workarounds for shitty hard requirements in MSVC STL 41 | - os: ubuntu 42 | image_version: 2025 43 | - os: macos 44 | image_version: 2025 45 | - os: windows 46 | image_version: latest 47 | runs-on: ${{matrix.os}}-${{matrix.image_version}} 48 | env: 49 | CMAKE_CXX_STANDARD: ${{matrix.cxx_standard}} 50 | CMAKE_C_STANDARD: ${{matrix.c_standard}} 51 | steps: 52 | # important setup 53 | - uses: actions/checkout@main 54 | with: 55 | submodules: recursive 56 | - uses: humbletim/vsdevenv-shell@main 57 | if: ${{matrix.os == 'windows'}} 58 | - uses: seanmiddleditch/gha-setup-ninja@master 59 | if: ${{matrix.os == 'windows'}} 60 | # actual runs 61 | - name: Execute CMake Workflow (Windows and MSVC) 62 | if: ${{(matrix.os == 'windows' && matrix.compiler == 'msvc')}} 63 | shell: vsdevenv x64 powershell {0} 64 | run: cmake --workflow --preset ${{matrix.compiler}} 65 | - name: Execute CMake Workflow (Non-Windows and Non-MSVC) 66 | if: ${{(matrix.os != 'windows' || matrix.compiler != 'msvc')}} 67 | run: cmake --workflow --preset ${{matrix.compiler}} 68 | -------------------------------------------------------------------------------- /tests/registry/source/main.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #define CATCH_CONFIG_RUNNER 31 | #include 32 | 33 | #include 34 | 35 | #include 36 | 37 | #include 38 | 39 | int main(int argc, char* argv[]) { 40 | std::cout << "=== Encoding Names ===" << std::endl; 41 | std::cout << "Literal Encoding: " << ztd::literal_encoding_name() << std::endl; 42 | std::cout << "Wide Literal Encoding: " << ztd::wide_literal_encoding_name() << std::endl; 43 | std::cout << "Execution Encoding: " << ztd::execution_encoding_name() << std::endl; 44 | std::cout << "Wide Execution Encoding: " << ztd::wide_execution_encoding_name() << std::endl; 45 | int result = Catch::Session().run(argc, argv); 46 | return result; 47 | } 48 | -------------------------------------------------------------------------------- /tests/basic_run_time/source/main.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #define CATCH_CONFIG_RUNNER 31 | #include 32 | 33 | #include 34 | 35 | #include 36 | 37 | #include 38 | 39 | int main(int argc, char* argv[]) { 40 | std::cout << "=== Encoding Names ===" << std::endl; 41 | std::cout << "Literal Encoding: " << ztd::literal_encoding_name() << std::endl; 42 | std::cout << "Wide Literal Encoding: " << ztd::wide_literal_encoding_name() << std::endl; 43 | std::cout << "Execution Encoding: " << ztd::execution_encoding_name() << std::endl; 44 | std::cout << "Wide Execution Encoding: " << ztd::wide_execution_encoding_name() << std::endl; 45 | int result = Catch::Session().run(argc, argv); 46 | return result; 47 | } 48 | -------------------------------------------------------------------------------- /source/include/ztd/cuneicode/detail/state.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_SOURCE_DETAIL_STATE_HPP 31 | #define ZTD_CUNEICODE_SOURCE_DETAIL_STATE_HPP 32 | 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | inline constexpr cnc_mcstate_indicator __mc_s_i_locale 39 | = (cnc_mcstate_indicator)CNC_MCSTATE_INDICATOR___RESERVED0; 40 | inline constexpr cnc_mcstate_indicator __mc_s_i_raw 41 | = (cnc_mcstate_indicator)CNC_MCSTATE_INDICATOR_RAW; 42 | inline constexpr cnc_mcstate_indicator __mc_s_i_punycode 43 | = (cnc_mcstate_indicator)CNC_MCSTATE_INDICATOR___RESERVED1; 44 | inline constexpr cnc_mcstate_indicator __mc_s_i_win32_code_page 45 | = (cnc_mcstate_indicator)CNC_MCSTATE_INDICATOR___RESERVED2; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /shared/include/ztd/cuneicode/shared/stream_helpers.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_SHARED_STREAM_HELPERS_HPP 31 | #define ZTD_CUNEICODE_SHARED_STREAM_HELPERS_HPP 32 | 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | using utf8string = std::basic_string; 43 | using utf8string_view = std::basic_string_view; 44 | 45 | void print_encoding_list(std::ostream& out, cnc_conversion_registry* registry); 46 | void print_conversion_info(std::ostream& out, cnc_conversion_info info); 47 | std::ostream& operator<<(std::ostream& stream, const utf8string_view& str); 48 | std::ostream& operator<<(std::ostream& stream, const utf8string& str); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /documentation/source/design/registry/allocation.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | Registry Allocation 32 | =================== 33 | 34 | At many times, the registry may need to access additional information to, for example, store extra information. This could be done with ``malloc`` and handled on cleanup with ``free``, but that can be prohibitive to C implementations which may not want to draw their memory from either of these global pools. Therefore, in order to allow a user to customize the way allocation works, there are 2 ways to customize how memory allocation is done with the library. 35 | 36 | 37 | The first, high-level way to control all allocation is to use the :cpp:struct:`cnc_conversion_heap`. That structure provides 5 functions which will control all non-automatic storage duration space created by the registry. 38 | -------------------------------------------------------------------------------- /examples/extensions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | FILE(GLOB_RECURSE ztd.cuneicode.examples.extensions.stmt-exprs.sources 31 | LIST_DIRECTORIES FALSE 32 | CONFIGURE_DEPENDS 33 | source/**stmt_exprs** 34 | ) 35 | 36 | foreach(extensions_source_file ${ztd.cuneicode.examples.extensions.stmt-exprs.sources}) 37 | ztd_cuneicode_example_simple(${extensions_source_file} "ztd.cuneicode.examples.extensions" extensions_target_name) 38 | target_compile_options(${extensions_target_name} 39 | PRIVATE 40 | ${--no-pedantic} 41 | ${--no-warn-pedantic} 42 | ${--allow-gnu-auto-type} 43 | ${--allow-gnu-statement-expressions} 44 | ${--allow-gnu-statement-expression-from-macro-expansion} 45 | ) 46 | if (NOT MSVC) 47 | target_compile_features(${extensions_target_name} 48 | PRIVATE 49 | c_std_23) 50 | set_property(TARGET ${extensions_target_name} 51 | PROPERTY 52 | C_EXTENSIONS ON) 53 | endif() 54 | endforeach() 55 | -------------------------------------------------------------------------------- /documentation/source/api/registry_types.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | Registry Function Types 32 | ======================= 33 | 34 | There are many function types used to perform work related to the registry, or hook in user behavior. They are detailed below and are used in the various :doc:`registry functions`. 35 | 36 | .. note:: Breathe and Doxygen is broken by the function typedefs, so they are not shown here at the moment. 37 | 38 | .. .. doxygentypedef:: cnc_conversion_function 39 | .. 40 | .. .. doxygentypedef:: cnc_open_function 41 | .. 42 | .. .. doxygentypedef:: cnc_close_function 43 | .. 44 | .. .. doxygentypedef:: cnc_conversion_registry_pair_c8_function 45 | .. 46 | .. .. doxygentypedef:: cnc_conversion_registry_pair_function 47 | .. 48 | .. .. doxygentypedef:: cnc_indirect_selection_c8_function 49 | .. 50 | .. .. doxygentypedef:: cnc_indirect_selection_function 51 | -------------------------------------------------------------------------------- /examples/cconv/include/cconv/handler.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_EXAMPLES_CCONV_HANDLER_HPP 31 | #define ZTD_CUNEICODE_EXAMPLES_CCONV_HANDLER_HPP 32 | 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | struct byte_substitution_handler { 40 | std::vector substitution; 41 | 42 | bool operator()(const cnc_conversion_info&, cnc_conversion*, size_t*, 43 | unsigned char**, size_t*, const unsigned char**) const noexcept; 44 | }; 45 | 46 | struct discard_handler { 47 | bool operator()(const cnc_conversion_info&, cnc_conversion*, size_t*, 48 | unsigned char**, size_t*, const unsigned char**) const noexcept; 49 | }; 50 | 51 | struct fail_handler { 52 | bool operator()(const cnc_conversion_info&, cnc_conversion*, size_t*, 53 | unsigned char**, size_t*, const unsigned char**) const noexcept; 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /source/include/ztd/cuneicode/detail/err.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #pragma once 31 | 32 | #ifndef ZTD_CUNEICODE_SOURCE_DETAIL_ERR_HPP 33 | #define ZTD_CUNEICODE_SOURCE_DETAIL_ERR_HPP 34 | 35 | #include 36 | 37 | #include 38 | 39 | namespace cnc { 40 | ZTD_CUNEICODE_INLINE_ABI_NAMESPACE_OPEN_I_ 41 | namespace __cnc_detail { 42 | 43 | inline constexpr const size_t __stdc_ret_null_value = 0; 44 | inline constexpr const size_t __stdc_ret_no_write_out_yet = 0; 45 | inline constexpr const size_t __stdc_ret_err_invalid = static_cast(-1); 46 | inline constexpr const size_t __stdc_ret_err_incomplete_input = static_cast(-2); 47 | inline constexpr const size_t __stdc_ret_accumulated_write_out = static_cast(-3); 48 | 49 | } // namespace __cnc_detail 50 | ZTD_CUNEICODE_INLINE_ABI_NAMESPACE_CLOSE_I_ 51 | } // namespace cnc 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /include/ztd/cuneicode/petscii_state.h: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_PETSCII_STATE_H 31 | #define ZTD_CUNEICODE_PETSCII_STATE_H 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | #if ZTD_IS_OFF(ZTD_CXX) 38 | #include 39 | #endif 40 | 41 | ////// 42 | /// @addtogroup ztd_cuneicode_conversion Conversion Functions 43 | /// 44 | /// @{ 45 | 46 | ////// 47 | /// @brief The state of a PETSCII encoding, which is either shifted / unshifted. 48 | typedef struct cnc_petscii_state_t { 49 | ////// 50 | /// @brief Whether or not the input is assumed to be perfectly in-range and valid. 51 | bool assume_valid; 52 | ////// 53 | /// @brief Whether the PETSCII state is shifted/unshifted. This variable is ignored if the 54 | /// `*_petscii_unshifted` or `*_petscii_shifted` functions are used directly. 55 | bool shifted; 56 | } cnc_petscii_state_t; 57 | 58 | ////// 59 | /// @} 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /tests/allocation/source/cxx_alloc_override.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | static void* my_null = 0; 7 | 8 | CNC_TESTS_EXPORT void* operator new(size_t size) { 9 | (void)size; 10 | return my_null; 11 | } 12 | 13 | CNC_TESTS_EXPORT void* operator new[](size_t size) { 14 | (void)size; 15 | return my_null; 16 | } 17 | 18 | CNC_TESTS_EXPORT void* operator new(size_t size, std::nothrow_t&) { 19 | (void)size; 20 | return my_null; 21 | } 22 | 23 | CNC_TESTS_EXPORT void* operator new[](size_t size, std::nothrow_t&) { 24 | (void)size; 25 | return my_null; 26 | } 27 | 28 | CNC_TESTS_EXPORT void operator delete(void* p) noexcept { 29 | (void)p; 30 | } 31 | 32 | CNC_TESTS_EXPORT void operator delete(void* p, size_t size) noexcept { 33 | (void)p; 34 | (void)size; 35 | } 36 | 37 | CNC_TESTS_EXPORT void operator delete(void* p, std::nothrow_t&) { 38 | (void)p; 39 | } 40 | 41 | CNC_TESTS_EXPORT void operator delete[](void* p) noexcept { 42 | (void)p; 43 | } 44 | 45 | CNC_TESTS_EXPORT void operator delete[](void* p, size_t size) noexcept { 46 | (void)p; 47 | (void)size; 48 | } 49 | 50 | CNC_TESTS_EXPORT void operator delete[](void* p, std::nothrow_t&) { 51 | (void)p; 52 | } 53 | 54 | CNC_TESTS_EXPORT void* operator new(size_t size, std::align_val_t val) { 55 | (void)size; 56 | (void)val; 57 | return my_null; 58 | } 59 | 60 | CNC_TESTS_EXPORT void* operator new[](size_t size, std::align_val_t val) { 61 | (void)size; 62 | (void)val; 63 | return my_null; 64 | } 65 | 66 | CNC_TESTS_EXPORT void* operator new(size_t size, std::align_val_t val, std::nothrow_t&) { 67 | (void)size; 68 | (void)val; 69 | return my_null; 70 | } 71 | 72 | CNC_TESTS_EXPORT void* operator new[](size_t size, std::align_val_t val, std::nothrow_t&) { 73 | (void)size; 74 | (void)val; 75 | return my_null; 76 | } 77 | 78 | CNC_TESTS_EXPORT void operator delete(void* p, std::align_val_t) noexcept { 79 | (void)p; 80 | } 81 | 82 | CNC_TESTS_EXPORT void operator delete[](void* p, std::align_val_t) noexcept { 83 | (void)p; 84 | } 85 | 86 | CNC_TESTS_EXPORT void operator delete(void* p, size_t size, std::align_val_t val) noexcept { 87 | (void)p; 88 | (void)size; 89 | (void)val; 90 | } 91 | 92 | CNC_TESTS_EXPORT void operator delete[](void* p, size_t size, std::align_val_t val) noexcept { 93 | (void)p; 94 | (void)size; 95 | (void)val; 96 | } 97 | -------------------------------------------------------------------------------- /include/ztd/cuneicode/registry_options.h: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_REGISTRY_OPTIONS_H 31 | #define ZTD_CUNEICODE_REGISTRY_OPTIONS_H 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | ////// 38 | /// @addtogroup ztd_cuneicode_registry_options Conversion Registry Options 39 | /// 40 | /// @{ 41 | 42 | ////// 43 | /// @brief The options which change how a registry is initialized and adjusted upon creation. 44 | typedef enum cnc_registry_options { 45 | ////// 46 | /// @brief No options. 47 | cnc_registry_options_none = 0, 48 | ////// 49 | /// @brief Start with an empty registry that contains none of the platorm's default 50 | /// conversion 51 | /// entries. 52 | cnc_registry_options_empty = 1, 53 | ////// 54 | /// @brief Use the default options recommended when starting a registry. 55 | cnc_registry_options_default = cnc_registry_options_none, 56 | } cnc_registry_options; 57 | 58 | ////// 59 | /// @} 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /tests/allocation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | file(GLOB_RECURSE ztd.cuneicode.tests.allocation.sources 31 | LIST_DIRECTORIES FALSE 32 | CONFIGURE_DEPENDS 33 | source/*.cpp source/*.c) 34 | 35 | add_executable(ztd.cuneicode.tests.allocation ${ztd.cuneicode.tests.allocation.sources}) 36 | set_target_properties(ztd.cuneicode.tests.allocation PROPERTIES 37 | VERSION ${PROJECT_VERSION} 38 | ) 39 | target_compile_options(ztd.cuneicode.tests.allocation 40 | PRIVATE 41 | ${--utf8-literal-encoding} 42 | ${--utf8-source-encoding} 43 | ${--disable-permissive} 44 | ${--updated-cpp-version-flag} 45 | ${--warn-pedantic} 46 | ${--warn-all} 47 | ${--warn-extra} 48 | ${--warn-errors}) 49 | target_include_directories(ztd.cuneicode.tests.allocation 50 | PRIVATE 51 | ${CMAKE_CURRENT_SOURCE_DIR}/include 52 | ) 53 | target_link_libraries(ztd.cuneicode.tests.allocation 54 | PRIVATE 55 | ztd::cuneicode) 56 | 57 | add_test(NAME ztd.cuneicode.tests.allocation COMMAND ztd.cuneicode.tests.allocation) 58 | -------------------------------------------------------------------------------- /tests/registry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | file(GLOB_RECURSE ztd.cuneicode.tests.registry.sources 31 | LIST_DIRECTORIES FALSE 32 | CONFIGURE_DEPENDS 33 | source/*.cpp) 34 | 35 | add_executable(ztd.cuneicode.tests.registry ${ztd.cuneicode.tests.registry.sources}) 36 | set_target_properties(ztd.cuneicode.tests.registry PROPERTIES 37 | VERSION ${PROJECT_VERSION} 38 | ) 39 | target_compile_options(ztd.cuneicode.tests.registry 40 | PRIVATE 41 | ${--utf8-literal-encoding} 42 | ${--utf8-source-encoding} 43 | ${--disable-permissive} 44 | ${--updated-cpp-version-flag} 45 | ${--warn-pedantic} 46 | ${--warn-all} 47 | ${--warn-extra} 48 | ${--warn-errors}) 49 | target_include_directories(ztd.cuneicode.tests.registry PRIVATE 50 | ${CMAKE_CURRENT_SOURCE_DIR}/../include 51 | ) 52 | target_link_libraries(ztd.cuneicode.tests.registry 53 | PRIVATE 54 | Catch2::Catch2 55 | ztd::cuneicode 56 | ztd::cuneicode::shared) 57 | 58 | add_test(NAME ztd.cuneicode.tests.registry COMMAND ztd.cuneicode.tests.registry) 59 | -------------------------------------------------------------------------------- /tests/compile_time/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | file(GLOB_RECURSE ztd.cuneicode.tests.compile_time.sources 31 | LIST_DIRECTORIES FALSE 32 | CONFIGURE_DEPENDS 33 | source/*.cpp source/*.c) 34 | 35 | add_executable(ztd.cuneicode.tests.compile_time ${ztd.cuneicode.tests.compile_time.sources}) 36 | set_target_properties(ztd.cuneicode.tests.compile_time PROPERTIES 37 | VERSION ${PROJECT_VERSION} 38 | ) 39 | target_compile_options(ztd.cuneicode.tests.compile_time 40 | PRIVATE 41 | ${--utf8-literal-encoding} 42 | ${--utf8-source-encoding} 43 | ${--disable-permissive} 44 | ${--updated-cpp-version-flag} 45 | ${--warn-pedantic} 46 | ${--warn-all} 47 | ${--warn-extra} 48 | ${--warn-errors}) 49 | target_include_directories(ztd.cuneicode.tests.compile_time PRIVATE 50 | ${CMAKE_CURRENT_SOURCE_DIR}/../include 51 | ) 52 | target_link_libraries(ztd.cuneicode.tests.compile_time 53 | PRIVATE 54 | Catch2::Catch2 55 | ztd::cuneicode) 56 | 57 | add_test(NAME ztd.cuneicode.tests.compile_time COMMAND ztd.cuneicode.tests.compile_time) 58 | -------------------------------------------------------------------------------- /documentation/source/api.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | API Reference 32 | ============= 33 | 34 | This is simply a listing of all the available pages containing various APIs, or links to pages that link to API documentation. 35 | 36 | 37 | 38 | General Structures, Enumerations, and Constants 39 | ----------------------------------------------- 40 | 41 | .. toctree:: 42 | :maxdepth: 1 43 | 44 | api/mcerr 45 | api/open_err 46 | api/mcstate_t 47 | api/constants 48 | 49 | 50 | 51 | Typed Conversions 52 | ----------------- 53 | 54 | .. toctree:: 55 | :maxdepth: 1 56 | 57 | api/encodings 58 | api/typed conversions 59 | api/generic typed conversions 60 | 61 | 62 | 63 | Registry (Untyped) Conversions 64 | ------------------------------ 65 | 66 | .. toctree:: 67 | :maxdepth: 1 68 | 69 | api/registry 70 | api/registry_options 71 | api/registry_types 72 | api/conversion_info 73 | api/pivot_info 74 | api/registry conversion handles 75 | api/registry conversions 76 | api/heap 77 | -------------------------------------------------------------------------------- /examples/documentation/quick/setup/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | # accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License") for non-commercial use; you may not use this 18 | # file except in compliance with the License. You may obtain a copy of the 19 | # License at 20 | # 21 | # https://www.apache.org/licenses/LICENSE-2.0 22 | # 23 | # Unless required by applicable law or agreed to in writing, software 24 | # distributed under the License is distributed on an "AS IS" BASIS, 25 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | # See the License for the specific language governing permissions and 27 | # limitations under the License. 28 | # 29 | # ============================================================================> 30 | 31 | #[[ 32 | # === snippet-project-declaration-start 33 | project(my_app 34 | VERSION 1.0.0 35 | DESCRIPTION "My application." 36 | HOMEPAGE_URL "https://ztdcuneicode.readthedocs.io/en/latest/quick.html" 37 | LANGUAGES C 38 | ) 39 | 40 | include(FetchContent) 41 | 42 | FetchContent_Declare(ztd.cuneicode 43 | GIT_REPOSITORY https://github.com/soasis/cuneicode.git 44 | GIT_SHALLOW ON 45 | GIT_TAG main) 46 | FetchContent_MakeAvailable(ztd.cuneicode) 47 | # === snippet-project-declaration-end 48 | #]] 49 | 50 | # === snippet-library-start 51 | # … 52 | 53 | file(GLOB_RECURSE my_app_sources 54 | LIST_DIRECTORIES OFF 55 | CONFIGURE_DEPENDS 56 | source/*.c 57 | ) 58 | 59 | add_executable(my_app ${my_app_sources}) 60 | 61 | target_link_libraries(my_app PRIVATE ztd::cuneicode) 62 | # === snippet-library-end 63 | 64 | if (ZTD_CUNEICODE_TESTS) 65 | add_test(NAME ztd.cuneicode.examples.documentation.quick.my_app 66 | COMMAND my_app "Harold") 67 | endif() 68 | -------------------------------------------------------------------------------- /tests/compile_time/source/result_types.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | #if ZTD_IS_OFF(ZTD_COMPILER_VCXX) || ZTD_IS_OFF(ZTD_C) 33 | 34 | #define MAKE_GENERIC_TYPEDEFS(DECL_NAME) \ 35 | typedef DECL_NAME(char, char) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__); \ 36 | typedef DECL_NAME(char, unsigned char) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__); \ 37 | typedef DECL_NAME(char, ztd_char_t) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__); \ 38 | typedef DECL_NAME(char, ztd_wchar_t) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__); \ 39 | typedef DECL_NAME(char, ztd_char8_t) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__); \ 40 | typedef DECL_NAME(char, ztd_char16_t) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__); \ 41 | typedef DECL_NAME(char, ztd_char32_t) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__) 42 | 43 | MAKE_GENERIC_TYPEDEFS(cnc_result); 44 | MAKE_GENERIC_TYPEDEFS(cnc_error_result); 45 | MAKE_GENERIC_TYPEDEFS(cnc_single_result); 46 | MAKE_GENERIC_TYPEDEFS(cnc_single_error_result); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /tests/basic_run_time/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # 3 | # ztd.cuneicode 4 | # Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | # Contact: opensource@soasis.org 6 | # 7 | # Commercial License Usage 8 | # Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | # in accordance with the commercial license agreement provided with the 10 | # Software or, alternatively, in accordance with the terms contained in 11 | # a written agreement between you and Shepherd's Oasis, LLC. 12 | # For licensing terms and conditions see your agreement. For 13 | # further information contact opensource@soasis.org. 14 | # 15 | # Apache License Version 2 Usage 16 | # Alternatively, this file may be used under the terms of Apache License 17 | # Version 2.0 (the "License"); you may not use this file except in compliance 18 | # with the License. You may obtain a copy of the License at 19 | # 20 | # https://www.apache.org/licenses/LICENSE-2.0 21 | # 22 | # Unless required by applicable law or agreed to in writing, software 23 | # distributed under the License is distributed on an "AS IS" BASIS, 24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | # See the License for the specific language governing permissions and 26 | # limitations under the License. 27 | # 28 | # =========================================================================== # 29 | 30 | file(GLOB_RECURSE ztd.cuneicode.tests.basic_run_time.sources 31 | LIST_DIRECTORIES FALSE 32 | CONFIGURE_DEPENDS 33 | source/*.cpp) 34 | 35 | add_executable(ztd.cuneicode.tests.basic_run_time ${ztd.cuneicode.tests.basic_run_time.sources}) 36 | set_target_properties(ztd.cuneicode.tests.basic_run_time PROPERTIES 37 | VERSION ${PROJECT_VERSION} 38 | ) 39 | target_compile_options(ztd.cuneicode.tests.basic_run_time 40 | PRIVATE 41 | ${--utf8-literal-encoding} 42 | ${--utf8-source-encoding} 43 | ${--disable-permissive} 44 | ${--updated-cpp-version-flag} 45 | ${--warn-pedantic} 46 | ${--warn-all} 47 | ${--warn-extra} 48 | ${--warn-errors}) 49 | target_include_directories(ztd.cuneicode.tests.basic_run_time PRIVATE 50 | ${CMAKE_CURRENT_SOURCE_DIR}/../include 51 | ) 52 | target_link_libraries(ztd.cuneicode.tests.basic_run_time 53 | PRIVATE 54 | Catch2::Catch2 55 | ztd::cuneicode 56 | ztd::cuneicode::shared) 57 | 58 | add_test(NAME ztd.cuneicode.tests.basic_run_time COMMAND ztd.cuneicode.tests.basic_run_time) 59 | -------------------------------------------------------------------------------- /documentation/source/future.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | Progress & Future Work 32 | ====================== 33 | 34 | This is where the status and progress of the library will be kept up to date. You can also check the `Issue Tracker `_ for specific issues and things being worked on! 35 | 36 | 37 | 38 | More Encodings 39 | -------------- 40 | 41 | More encodings should be supported by this library, to make development for others easier and easier. A good start with be targeting all of :term:`iconv`'s encodings first and foremost. Then, integrating new encodings as individuals voice their need for them. 42 | 43 | 44 | 45 | Arbitrary Indirections 46 | ---------------------- 47 | 48 | Right now, encodings only traffic through the 3 well-known Unicode Encoding forms (UTF-8, UTF-16, UTF-32). It would be far more beneficial to allow connectivity through **any** encoding pair (but with preference shown to any Unicode encoding before taking the first go-between encoding that matches). 49 | -------------------------------------------------------------------------------- /documentation/source/known unicode encodings.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================= 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. =============================================================================> 30 | 31 | Known Unicode Encodings 32 | ======================= 33 | 34 | The list of known Unicode encodings is identical to the one found in a consuming project for C++ called ztd.text. That list can be `found here `_. 35 | 36 | The known Unicode encodings are important because they are evaluated before all other candidates as an intermediate in the service of performing an indirect encoding conversion; not every Unicode encoding is given such an elevated status, though. Only the encodings listed on the :doc:`indirect conversion desing documentation` are given the elevated encoding status and checked before all else: otherwise, the order of finding and the priority of picking such an indirect conversion is unspecified. A stronger guarantee can be made by using the select-based functions when opening a :doc:`cuneicode conversion routine in the registry `. 37 | -------------------------------------------------------------------------------- /documentation/source/api/generic typed conversions.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | Generic Typed Conversions 32 | ========================= 33 | 34 | Generic typed conversions rely on the types being put in to determine what encodings and conversions should be done. They are more flexibile when the input is generic, or the user has well-defined source and destination pointers to use with the API. The type-to-prefix/encoding mapping for this function is described in the :doc:`naming documentation `. When using these functions, using ``nullptr`` is ambiguous because the macro/template cannot understand what the to / from pointers should be. In those cases, cast the ``nullptr`` value with ``(CharTypeHere**)nullptr``. 35 | 36 | 37 | Bulk Conversion Functions 38 | ------------------------- 39 | 40 | .. doxygendefine:: cnc_cxsntocysn 41 | 42 | .. doxygendefine:: cnc_cxsnrtocysn 43 | 44 | 45 | 46 | Single Conversion Functions 47 | --------------------------- 48 | 49 | .. doxygendefine:: cnc_cxntocyn 50 | 51 | .. doxygendefine:: cnc_cxnrtocyn 52 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: WebKit 3 | IndentWidth: 5 4 | TabWidth: 5 5 | ContinuationIndentWidth: 5 6 | UseTab: ForIndentation 7 | 8 | # Namespaces 9 | NamespaceIndentation: All 10 | CompactNamespaces: true 11 | FixNamespaceComments: true 12 | 13 | # Overall Alignment 14 | ColumnLimit: 100 15 | AlignAfterOpenBracket: DontAlign # uses ContinuationIndentWidth for this instead 16 | AccessModifierOffset: -5 # do not push public: or private: around 17 | AlignConsecutiveAssignments: true # affects more than what's expected: do not use 18 | #AlignConsecutiveDeclarations: true # affects more than what's expected: do not use 19 | 20 | # Type Alignment 21 | DerivePointerAlignment: false 22 | PointerAlignment: Left 23 | AlwaysBreakTemplateDeclarations: true 24 | AlwaysBreakBeforeMultilineStrings: true 25 | 26 | # Comments 27 | AlignTrailingComments: true 28 | ReflowComments: true 29 | 30 | # Macros 31 | AlignEscapedNewlines: Left 32 | #IndentPPDirectives: None 33 | AttributeMacros: ['ZTD_CUNEICODE_FUNCTION_LINKAGE_I_', 'ZTD_CUNEICODE_API_LINKAGE_I_', 'ZTD_EXTERN_C_I_'] 34 | 35 | # Functions 36 | AllowShortFunctionsOnASingleLine: None 37 | AlwaysBreakAfterReturnType: None 38 | BreakConstructorInitializers: BeforeComma 39 | ConstructorInitializerIndentWidth: 0 40 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 41 | BinPackArguments: true 42 | BinPackParameters: true 43 | 44 | # Classes 45 | BreakBeforeInheritanceComma: false 46 | 47 | # Braces 48 | Cpp11BracedListStyle: false 49 | BreakBeforeBraces: Custom 50 | BraceWrapping: 51 | AfterEnum: false 52 | AfterStruct: false 53 | AfterUnion: false 54 | AfterControlStatement: false 55 | AfterClass: false 56 | AfterNamespace: false 57 | BeforeElse: true 58 | BeforeCatch: true 59 | IndentBraces: false 60 | SplitEmptyFunction: false 61 | SplitEmptyRecord: false 62 | SplitEmptyNamespace: true 63 | 64 | # Control Statements 65 | AllowShortIfStatementsOnASingleLine: false 66 | AllowShortLoopsOnASingleLine: false 67 | AllowShortCaseLabelsOnASingleLine: false 68 | IndentCaseLabels: false 69 | 70 | # Spaces 71 | SpaceAfterCStyleCast: false 72 | SpacesInCStyleCastParentheses: false 73 | SpaceAfterTemplateKeyword: true 74 | SpaceBeforeAssignmentOperators: true 75 | SpaceBeforeParens: ControlStatements 76 | SpaceInEmptyParentheses: false 77 | SpacesInAngles: false 78 | SpacesInParentheses: false 79 | SpacesInSquareBrackets: false 80 | MaxEmptyLinesToKeep: 3 81 | 82 | # Prevent OCD 83 | SortIncludes: false 84 | 85 | --- 86 | Language: Cpp 87 | Standard: Cpp11 88 | -------------------------------------------------------------------------------- /documentation/source/bibliography.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | Bibliography 32 | ============ 33 | 34 | These are all the resources that this documentation links to, in alphabetical order. 35 | 36 | 37 | .. glossary:: 38 | :sorted: 39 | 40 | iconv 41 | Bruno Haible and Daiki Ueno. libiconv. August 2020. URL: `https://savannah.gnu.org/projects/libiconv/ `_. `A software library `_ for working with and converting text. Typically ships on most, if not all, POSIX and Linux systems. 42 | 43 | ICU 44 | Unicode Consortium. "International Components for Unicode". April 17th, 2019. URL: `https://github.com/hsivonen/encoding_rs `_ The premiere library for not only performing encoding conversions, but performing other Unicode-related algorithms on sequences of text. 45 | 46 | simdutf 47 | Daniel Lemire et. al. "simdutf: Unicode at Gigabytes per Second." January 28th, 2022. URL: `https://github.com/simdutf/simdutf `_. 48 | -------------------------------------------------------------------------------- /examples/cconv/include/cconv/def.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_EXAMPLES_CCONV_DEF_HPP 31 | #define ZTD_CUNEICODE_EXAMPLES_CCONV_DEF_HPP 32 | 33 | #include 34 | 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | using utf8string = std::basic_string; 43 | using utf8string_view = std::basic_string_view; 44 | 45 | std::ostream& operator<<(std::ostream& stream, const utf8string_view& str); 46 | std::ostream& operator<<(std::ostream& stream, const utf8string& str); 47 | 48 | constexpr std::size_t minimum_buffer_size = 64; 49 | 50 | constexpr int exit_success = 0; 51 | constexpr int exit_file_write_failure = 1; 52 | constexpr int exit_file_read_failure = 2; 53 | constexpr int exit_conversion_failure = 3; 54 | constexpr int exit_open_failure = 4; 55 | constexpr int exit_locale_failure = 5; 56 | constexpr int exit_file_open_failure = 6; 57 | constexpr int exit_registry_open_failure = 7; 58 | constexpr int exit_option_failure = 8; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /documentation/source/api/registry.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | Conversion Registry 32 | =================== 33 | 34 | .. doxygentypedef:: cnc_conversion_registry 35 | 36 | .. doxygenfunction:: cnc_registry_new 37 | 38 | .. doxygenfunction:: cnc_registry_open 39 | 40 | .. doxygenfunction:: cnc_registry_add 41 | 42 | .. doxygenfunction:: cnc_registry_add_n 43 | 44 | .. doxygenfunction:: cnc_registry_add_multi 45 | 46 | .. doxygenfunction:: cnc_registry_add_multi_n 47 | 48 | .. doxygenfunction:: cnc_registry_add_single 49 | 50 | .. doxygenfunction:: cnc_registry_add_single_n 51 | 52 | .. doxygenfunction:: cnc_registry_add_c8 53 | 54 | .. doxygenfunction:: cnc_registry_add_c8n 55 | 56 | .. doxygenfunction:: cnc_registry_add_multi_c8 57 | 58 | .. doxygenfunction:: cnc_registry_add_multi_c8n 59 | 60 | .. doxygenfunction:: cnc_registry_add_single_c8 61 | 62 | .. doxygenfunction:: cnc_registry_add_single_c8n 63 | 64 | .. doxygenfunction:: cnc_registry_close 65 | 66 | .. doxygenfunction:: cnc_registry_delete 67 | 68 | .. doxygenfunction:: cnc_registry_heap 69 | 70 | .. doxygenfunction:: cnc_registry_pairs_list_c8n 71 | 72 | .. doxygenfunction:: cnc_registry_pairs_list_n 73 | -------------------------------------------------------------------------------- /tests/compile_time/source/result_types.c: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | #if ZTD_IS_OFF(ZTD_COMPILER_VCXX) && !(ZTD_IS_ON(ZTD_COMPILER_CLANG) && __STDC_VERSION__ < 201800L) 33 | 34 | // not sure what's going on with Clang and MSVC here, to be completely honest. 35 | // this is very boring, regular code 36 | #define MAKE_GENERIC_TYPEDEFS(DECL_NAME) \ 37 | typedef DECL_NAME(char, char) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__); \ 38 | typedef DECL_NAME(char, unsigned char) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__); \ 39 | typedef DECL_NAME(char, ztd_char_t) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__); \ 40 | typedef DECL_NAME(char, ztd_wchar_t) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__); \ 41 | typedef DECL_NAME(char, ztd_char8_t) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__); \ 42 | typedef DECL_NAME(char, ztd_char16_t) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__); \ 43 | typedef DECL_NAME(char, ztd_char32_t) ZTD_CONCAT_TOKENS_I_(t, __COUNTER__) 44 | 45 | MAKE_GENERIC_TYPEDEFS(cnc_result); 46 | MAKE_GENERIC_TYPEDEFS(cnc_error_result); 47 | MAKE_GENERIC_TYPEDEFS(cnc_single_result); 48 | MAKE_GENERIC_TYPEDEFS(cnc_single_error_result); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /documentation/source/index.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | ``ztd.cuneicode`` 32 | ================= 33 | 34 | The premiere library for handling text in different encoding forms for C software. 35 | 36 | 37 | 38 | Who Is This Library For? 39 | ------------------------ 40 | 41 | If: 42 | 43 | - you want to convert from one Unicode encoding to another Unicode encoding; 44 | - you want to prevent data in the wrong encoding from infiltrating your application and causing `Mojibake `_; 45 | - you want to have a flexible, growable registry of encodings that does not require compile-time modification of source code to expand; 46 | - you want a design that is better than the C Standard Library's and actually handles your encoding; 47 | - you want safe defaults for working with text; 48 | 49 | then ``ztd.cuneicode`` is for you! 50 | 51 | .. toctree:: 52 | :maxdepth: 1 53 | :caption: Contents: 54 | 55 | quick 56 | design 57 | api 58 | definitions 59 | known Unicode encodings 60 | future 61 | benchmarks 62 | license 63 | bibliography 64 | 65 | 66 | 67 | 68 | Indices & Search 69 | ================ 70 | 71 | .. toctree:: 72 | 73 | genindex 74 | -------------------------------------------------------------------------------- /include/ztd/cuneicode/prefix.h: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_PREFIX_H 31 | #define ZTD_CUNEICODE_PREFIX_H 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | #include 38 | 39 | #define __cnc_prefix_to_type_uc() unsigned char 40 | #define __cnc_prefix_to_type_mc() ztd_wchar_t 41 | #define __cnc_prefix_to_type_mwc() ztd_wchar_t 42 | #define __cnc_prefix_to_type_c8() ztd_char8_t 43 | #define __cnc_prefix_to_type_c16() ztd_char16_t 44 | #define __cnc_prefix_to_type_c32() ztd_char32_t 45 | 46 | ////// 47 | /// @brief Converts the given lowercase prefix name to the type it represents in the system. 48 | /// 49 | /// @param[in] _PREFIX The identifier that presents the prefix to convert to a type. 50 | /// 51 | /// @remarks The prefix ↔ type association is as follows: 52 | /// 53 | /// - uc: `unsigned char` (UTF-8) 54 | /// - mc: `ztd_char_t` (Execution) 55 | /// - mwc: `ztd_wchar_t` (Wide Execution) 56 | /// - c8: `char8_t` (UTF-8) 57 | /// - c16: `char16_t` (UTF-16) 58 | /// - c32: `char32_t` (UTF-32) 59 | /// 60 | /// Use of other prefixes is an error. 61 | #define cnc_prefix_to_type(_PREFIX) ZTD_CONCAT_TOKENS_I_(__cnc_prefix_to_type_, _PREFIX)() 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /source/include/ztd/cuneicode/detail/basic_conv.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #pragma once 31 | 32 | #ifndef ZTD_CUNEICODE_SOURCE_DETAIL_BASIC_CONV_HPP 33 | #define ZTD_CUNEICODE_SOURCE_DETAIL_BASIC_CONV_HPP 34 | 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #include 43 | #include 44 | #include 45 | 46 | namespace cnc { 47 | ZTD_CUNEICODE_INLINE_ABI_NAMESPACE_OPEN_I_ 48 | 49 | namespace __cnc_detail { 50 | 51 | inline constexpr size_t __wchar_t_pointer_size = (sizeof(ztd_wchar_t*) * CHAR_BIT); 52 | inline constexpr bool __least64_bit_pointers = __wchar_t_pointer_size >= 64; 53 | inline constexpr bool __least32_bit_pointers = __wchar_t_pointer_size >= 32; 54 | 55 | struct __c32_state { 56 | ztd_char32_t __accumulation : 32; 57 | unsigned char __accumulation_count : 8; 58 | unsigned char __expected_count : 8; 59 | unsigned char __locality : 8; 60 | unsigned char __phase : 8; 61 | }; 62 | } // namespace __cnc_detail 63 | ZTD_CUNEICODE_INLINE_ABI_NAMESPACE_CLOSE_I_ 64 | } // namespace cnc 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /source/ztd/cuneicode/mcn_mwcn_specialized.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | #include 33 | 34 | CNC_TYPED_CONVERSION_DEFN_I_(mc, mc, c8, mc, _utf8_exec); 35 | CNC_TYPED_CONVERSION_DEFN_I_(mc, mc, mc, c8, _exec_utf8); 36 | CNC_TYPED_CONVERSION_DEFN_I_(mc, mc, c8, c8, _utf8_utf8); 37 | 38 | CNC_TYPED_CONVERSION_DEFN_I_(mc, c32, c8, c32, _utf8); 39 | CNC_TYPED_CONVERSION_DEFN_I_(c32, mc, c32, c8, _utf8); 40 | 41 | CNC_TYPED_CONVERSION_DEFN_I_(mc, c16, c8, c16, _utf8); 42 | CNC_TYPED_CONVERSION_DEFN_I_(c16, mc, c16, c8, _utf8); 43 | 44 | CNC_TYPED_CONVERSION_DEFN_I_(mc, mwc, c8, mwc, _utf8_wide_exec); 45 | CNC_TYPED_CONVERSION_DEFN_I_(mwc, mc, mwc, c8, _wide_exec_utf8); 46 | CNC_TYPED_CONVERSION_DEFN_I_(mc, mwc, c8, c16, _utf8_utf16); 47 | CNC_TYPED_CONVERSION_DEFN_I_(mwc, mc, c16, c8, _utf16_utf8); 48 | CNC_TYPED_CONVERSION_DEFN_I_(mc, mwc, c8, c32, _utf8_utf32); 49 | CNC_TYPED_CONVERSION_DEFN_I_(mwc, mc, c32, c8, _utf32_utf8); 50 | 51 | CNC_TYPED_CONVERSION_DEFN_I_(mc, mwc, mc, c16, _exec_utf16); 52 | CNC_TYPED_CONVERSION_DEFN_I_(mwc, mc, c16, mc, _utf16_exec); 53 | CNC_TYPED_CONVERSION_DEFN_I_(mc, mwc, mc, c32, _exec_utf32); 54 | CNC_TYPED_CONVERSION_DEFN_I_(mwc, mc, c32, mc, _utf32_exec); 55 | -------------------------------------------------------------------------------- /examples/cconv/include/cconv/options.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_EXAMPLES_CCONV_OPTIONS_HPP 31 | #define ZTD_CUNEICODE_EXAMPLES_CCONV_OPTIONS_HPP 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | struct options { 42 | using some_handler 43 | = std::variant; 44 | bool list_encodings = false; 45 | bool show_version = false; 46 | bool verbose = false; 47 | bool show_help = false; 48 | std::optional maybe_output_file_name = std::nullopt; 49 | bool silent = false; 50 | utf8string from_code = reinterpret_cast(+u8"execution"); 51 | utf8string to_code = reinterpret_cast(+"utf-8"); 52 | some_handler error_handler = discard_handler(); 53 | std::vector input_files = {}; 54 | std::optional maybe_buffer_size = std::nullopt; 55 | }; 56 | 57 | std::optional parse_options(options& opt, int argc, char* argv[]); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /examples/extensions/source/special_functionality.stmt_exprs.c: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | int main(int argc, char* argv[]) { 39 | (void)argc; 40 | (void)argv; 41 | #if ZTD_IS_ON(ZTD_CUNEICODE_EXTENSION_FUNCTIONS) 42 | // This only works if we support extension functions! 43 | const ztd_char8_t str[] 44 | = u8"\"Saw a \U0001F9DC \u2014" 45 | u8"didn't catch her\u2026 \U0001F61E\"\n\t- Sniff"; 46 | const size_t str_n = ztdc_c_array_size(str); 47 | 48 | if (!cnc_cxsntocysn_into_is_valid(c16, str_n, str)) { 49 | // input not valid 50 | return 1; 51 | } 52 | 53 | ztd_char16_t utf16_str[CNC_C16_MAX * ztdc_c_array_size(str)]; 54 | const size_t utf16_str_max_size = ztdc_c_array_size(utf16_str); 55 | cnc_count_result_t utf16_str_count_result 56 | = cnc_cxsntocysn_into_count(c16, str_n, str); 57 | if (utf16_str_max_size < utf16_str_count_result.output_count) { 58 | // buffer too small 59 | return 2; 60 | } 61 | cnc_c8c16_result_t unbounded_result 62 | = cnc_cxsntocys_into_unbounded(utf16_str, str_n, str); 63 | if (unbounded_result.error_code != cnc_mcerr_ok) { 64 | // write failed 65 | return 3; 66 | } 67 | return 0; 68 | #else 69 | return 0; 70 | #endif 71 | } 72 | -------------------------------------------------------------------------------- /include/ztd/cuneicode/open_err.h: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_OPEN_ERR_H 31 | #define ZTD_CUNEICODE_OPEN_ERR_H 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | ////// 38 | /// @addtogroup ztd_cuneicode_registry_error_types Registry Error Types 39 | /// 40 | /// @{ 41 | 42 | ////// 43 | /// @brief The error that occurred when trying to open or create a conversion resource. 44 | typedef enum cnc_open_err { 45 | ////// 46 | /// @brief Returned when everything was okay. 47 | cnc_open_err_ok = 0, 48 | ////// 49 | /// @brief Returned when there is no conversion path between the specified from and to 50 | /// encodings. 51 | cnc_open_err_no_conversion_path = -1, 52 | ////// 53 | /// @brief Returned when there iss not enough output space to write into for creating the 54 | /// resource. 55 | cnc_open_err_insufficient_output = -2, 56 | ////// 57 | /// @brief Returned when there is an invalid parameter passed in for creating the 58 | /// resource. 59 | cnc_open_err_invalid_parameter = -3, 60 | ////// 61 | /// @brief Returned when a heap-related or allocation-related failure occurred. 62 | cnc_open_err_allocation_failure = -4 63 | } cnc_open_err; 64 | 65 | 66 | ////// 67 | /// @brief Returns a string representing the error code's name. 68 | ZTD_USE(ZTD_C_LANGUAGE_LINKAGE) 69 | ZTD_USE(ZTD_CUNEICODE_API_LINKAGE) const char* cnc_open_err_to_str(cnc_open_err __err); 70 | 71 | ////// 72 | /// @} 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /shared/include/ztd/cuneicode/shared/unicode_range.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_BENCHMARKS_SOURCE_UNICODE_RANGE_HPP 31 | #define ZTD_CUNEICODE_BENCHMARKS_SOURCE_UNICODE_RANGE_HPP 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | #include 38 | #include 39 | 40 | #include 41 | 42 | inline namespace ztd_cnc_shared { 43 | inline std::vector make_full_unicode_range() noexcept { 44 | std::vector data; 45 | for (ztd_char32_t expected_c = 0; expected_c < __ztd_idk_detail_last_unicode_code_point; 46 | ++expected_c) { 47 | if (__ztd_idk_detail_is_surrogate(expected_c)) { 48 | continue; 49 | } 50 | data.push_back(expected_c); 51 | } 52 | return data; 53 | } 54 | 55 | inline const std::vector& full_unicode_range() noexcept { 56 | static const auto range = make_full_unicode_range(); 57 | return range; 58 | } 59 | 60 | inline std::vector make_basic_source_range() noexcept { 61 | std::vector data(ztd::tests::u32_basic_source_character_set.begin(), 62 | ztd::tests::u32_basic_source_character_set.end()); 63 | return data; 64 | } 65 | 66 | inline const std::vector& basic_source_range() noexcept { 67 | static const auto range = make_basic_source_range(); 68 | return range; 69 | } 70 | } // namespace ztd_cnc_shared 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /paper.bib: -------------------------------------------------------------------------------- 1 | @online{bangbangcon-unicode, 2 | author = {JeanHeyd Meneide}, 3 | title = {Oh, no! The Lowest-level* Programming Language is Unicode-aware...}, 4 | year = {2021}, 5 | url = {"https://youtu.be/U6xSmkdz2Nk?t=327"} 6 | } 7 | 8 | @online{w3techs-survey, 9 | author = {Q-Success}, 10 | title = {Usage of character encodings broken down by ranking}, 11 | year = {2022}, 12 | url = {"https://w3techs.com/technologies/cross/character_encoding/ranking"} 13 | } 14 | 15 | @article{unicode-transcode-lemire, 16 | author = {Lemire, Daniel}, 17 | title = {Unicode at Gigabytes per Second}, 18 | journal = {String Processing and Information Retrieval}, 19 | publisher = {Springer}, 20 | keywords = {vectorization, internationalization, unicode}, 21 | edition = {28}, 22 | month = {September}, 23 | year = 2021, 24 | url = {https://link.springer.com/chapter/10.1007/978-3-030-86692-1_2}, 25 | } 26 | 27 | @online{unicode-validate-lemire, 28 | author = {Lemire, Daniel}, 29 | title = {}, 30 | month = October, 31 | year = 2020, 32 | url = {} 33 | } 34 | 35 | @online{iconv, 36 | author = {{Haible}, B.S., {Ueno}, D.}, 37 | title = {libiconv}, 38 | year = {2022}, 39 | url = {https://www.gnu.org/software/libiconv/} 40 | } 41 | 42 | @online{icu, 43 | author = {{Unicode Consortium}, {ICU Technical Committee}}, 44 | title = {International Components for Unicode - ICU-TC}, 45 | month = July, 46 | year = {2022}, 47 | url = {https://icu.unicode.org/} 48 | } 49 | 50 | @online{iso-c, 51 | author = {{Meneide}, JeanHeyd, {Wiedijk}, Freek}, 52 | title = {ISO/IEC 9899:yyyy — Programming Languages, C}, 53 | month = June, 54 | year = {2022}, 55 | url = {https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2912.pdf} 56 | } 57 | 58 | @online{@encoding_rs, 59 | author = {Sivonen, Henri}, 60 | title = {encoding_rs: a Web-Compatible Character Encoding Library in Rust}, 61 | month = May, 62 | year = 2018, 63 | url = {https://hsivonen.fi/encoding_rs/} 64 | } 65 | 66 | @online{@utf8-cpp, 67 | author = {Trifunovic, Nemanja}, 68 | title = {UTF8-CPP: UTF-8 with C++ in a Portable Way}, 69 | month = December, 70 | year = 2021, 71 | url = {https://github.com/nemtrif/utfcpp} 72 | } 73 | 74 | @article{stenography-noorani, 75 | author = {Farah R. Shareef Taka}, 76 | title = {Text Steganography based on Noorani and Darkness}, 77 | journal = {Journal of Information Hiding and Multimedia Signal Processing}, 78 | volume = {12}, 79 | edition = {3}, 80 | publisher = {Ubiquitous International}, 81 | month = September, 82 | year = 2021, 83 | url = {http://bit.kuas.edu.tw/~jihmsp/2021/vol12/n3/02.JIHMSP_1571_r2.pdf}, 84 | } 85 | 86 | @article{unishox, 87 | author = {Arundale Ramanathan}, 88 | title = {Unishox: A hybrid encoder for Short Unicode Strings}, 89 | journal = {Journal of Open Source Software}, 90 | month = January, 91 | year = 2022, 92 | url = {https://joss.theoj.org/papers/10.21105/joss.03919.pdf} 93 | } 94 | -------------------------------------------------------------------------------- /include/ztd/cuneicode/version.h: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_VERSION_H 31 | #define ZTD_CUNEICODE_VERSION_H 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | #include 38 | 39 | // clang-format off 40 | 41 | #if defined(ZTD_CUNEICODE_EXTENSION_FUNCTIONS) 42 | #if (ZTD_CUNEICODE_EXTENSION_FUNCTIONS != 0) 43 | #define ZTD_CUNEICODE_EXTENSION_FUNCTIONS_I_ ZTD_ON 44 | #else 45 | #define ZTD_CUNEICODE_EXTENSION_FUNCTIONS_I_ ZTD_OFF 46 | #endif 47 | #elif ZTD_IS_ON(ZTD_STMT_EXPR_USABLE) 48 | #define ZTD_CUNEICODE_EXTENSION_FUNCTIONS_I_ ZTD_DEFAULT_ON 49 | #else 50 | #define ZTD_CUNEICODE_EXTENSION_FUNCTIONS_I_ ZTD_DEFAULT_OFF 51 | #endif 52 | 53 | #if defined(ZTD_CUNEICODE_INTERMEDIATE_BUFFER_SUGGESTED_BYTE_SIZE) 54 | #define ZTD_CUNEICODE_INTERMEDIATE_BUFFER_SUGGESTED_BYTE_SIZE_I_ ZTD_CUNEICODE_INTERMEDIATE_BUFFER_SUGGESTED_BYTE_SIZE 55 | #else 56 | #define ZTD_CUNEICODE_INTERMEDIATE_BUFFER_SUGGESTED_BYTE_SIZE_I_ ZTD_INTERMEDIATE_BUFFER_SUGGESTED_BYTE_SIZE_I_ 57 | #endif // Intermediate buffer sizing 58 | 59 | #if defined(ZTD_CUNEICODE_ABI_NAMESPACE) 60 | #define ZTD_CUNEICODE_INLINE_ABI_NAMESPACE_OPEN_I_ inline namespace ZTD_CUNEICODE_ABI_NAMESPACE { 61 | #define ZTD_CUNEICODE_INLINE_ABI_NAMESPACE_CLOSE_I_ } 62 | #else 63 | #define ZTD_CUNEICODE_INLINE_ABI_NAMESPACE_OPEN_I_ inline namespace __v0 { 64 | #define ZTD_CUNEICODE_INLINE_ABI_NAMESPACE_CLOSE_I_ } 65 | #endif 66 | 67 | // clang-format on 68 | 69 | #include 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /examples/documentation/quick/basic/source/validate.utf16_to_utf8.c: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | int main(int argc, char* argv[]) { 39 | (void)argc; 40 | (void)argv; 41 | 42 | const ztd_char16_t utf16_text[] = u"🥺🙏"; 43 | 44 | const ztd_char16_t* count_input_ptr = utf16_text; 45 | // ztdc_c_array_size INCLUDES the null terminator in the size! 46 | const size_t initial_count_input_size = ztdc_c_array_size(utf16_text); 47 | size_t count_input_size = initial_count_input_size; 48 | cnc_mcstate_t count_state = { 0 }; 49 | // Use the function but with "nullptr" for the output pointer 50 | cnc_mcerr err = cnc_c16snrtoc8sn( 51 | // To get the proper size for this conversion, we use the same 52 | // function but with "NULL" specificers: 53 | NULL, NULL, 54 | // input second 55 | &count_input_size, &count_input_ptr, 56 | // state parameter 57 | &count_state); 58 | size_t input_read = (size_t)(initial_count_input_size - count_input_size); 59 | if (err != cnc_mcerr_ok) { 60 | const char* err_str = cnc_mcerr_to_str(err); 61 | fprintf(stderr, 62 | "An (unexpected) error occurred and the counting/validating could " 63 | "not happen!\nThe error happened at code unit %zu in the UTF-16 " 64 | "input.\nError string: %s (code: '%d')\n", 65 | input_read, err_str, (int)err); 66 | } 67 | 68 | printf( 69 | "The input UTF-16 is valid and consumed all %zu code units (elements) " 70 | "of input.\n", 71 | input_read); 72 | 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /source/include/ztd/cuneicode/detail/conversion.hpp: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_SOURCE_DETAIL_CONVERSION_HPP 31 | #define ZTD_CUNEICODE_SOURCE_DETAIL_CONVERSION_HPP 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | #include 38 | 39 | 40 | #if ZTD_IS_ON(ZTD_CXX) 41 | #include 42 | #include 43 | #else 44 | #include 45 | #include 46 | #include 47 | #endif 48 | 49 | typedef enum cnc_conv_props { 50 | CNC_CONV_PROPS_NONE = 0x0, 51 | CNC_CONV_PROPS_INDIRECT = 0x01 52 | } cnc_conv_props; 53 | 54 | typedef struct cnc_conversion { 55 | size_t __size; 56 | size_t __multi_conversion_minimum_byte_size; 57 | uint_least32_t __properties; 58 | cnc_conversion_registry* __registry; 59 | cnc_conversion_function* __single_conversion_function; 60 | cnc_state_is_complete_function* __state_is_complete_function; 61 | cnc_conversion_function* __multi_conversion_function; 62 | cnc_close_function* __close_function; 63 | } cnc_conversion; 64 | 65 | extern cnc_mcerr __cnc_multi_from_single_conversion(cnc_conversion* __conversion, 66 | size_t* __p_output_bytes_size, unsigned char** __p_output_bytes, size_t* __p_input_bytes_size, 67 | const unsigned char** __p_input_bytes, cnc_pivot_info* __p_pivot_info, void* __user_data) 68 | ZTD_USE(ZTD_NOEXCEPT_IF_CXX); 69 | extern cnc_mcerr __cnc_single_from_multi_conversion(cnc_conversion* __conversion, 70 | size_t* __p_output_bytes_size, unsigned char** __p_output_bytes, size_t* __p_input_bytes_size, 71 | const unsigned char** __p_input_bytes, cnc_pivot_info* __p_pivot_info, void* __user_data) 72 | ZTD_USE(ZTD_NOEXCEPT_IF_CXX); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /include/ztd/cuneicode/pivot_info.h: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_PIVOT_INFO_H 31 | #define ZTD_CUNEICODE_PIVOT_INFO_H 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | #include 38 | 39 | #if ZTD_IS_ON(ZTD_CXX) 40 | #include 41 | #else 42 | #include 43 | #endif 44 | 45 | ////// 46 | /// @addtogroup ztd_cuneicode_conversion Conversion Functions 47 | /// 48 | /// @{ 49 | 50 | ////// 51 | /// @brief A structure containing information for a "pivot buffer". 52 | /// 53 | /// @remarks When a failure happens due to an intermediate conversion failing, the `result` member 54 | /// of the cnc_pivot_info will be set to a non-cnc_mcerr_ok value reflecting the type of 55 | /// failure that happened within the intermediate conversion. 56 | typedef struct cnc_pivot_info { 57 | ////// 58 | /// @brief The number of bytes pointed to by bytes. 59 | size_t bytes_size; 60 | ////// 61 | /// @brief A pointer to a byte buffer to use for intermediate conversions. 62 | /// 63 | /// @remarks If this is a null pointer, it signifies that an internal buffer created in some 64 | /// fashion by the implementation should be used instead to perform the conversion. Otherwise, 65 | /// even if the buffer is insufficiently small, it will use this buffer. 66 | unsigned char* bytes; 67 | ////// 68 | /// @brief The error code representing any failed conversion specific to the intermediate/pivot 69 | /// step. 70 | /// 71 | /// @remarks If a conversion involving the intermediate buffer / pivot buffer - even the 72 | /// implementation-defined one - fails for any reason, it will be reported in this variable. 73 | cnc_mcerr error; 74 | } cnc_pivot_info; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /include/ztd/cuneicode/max_output.h: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_MAX_OUTPUT_H 31 | #define ZTD_CUNEICODE_MAX_OUTPUT_H 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | ////// 38 | /// @addtogroup ztd_cuneicode_max_macros Maximum-Size Macros 39 | /// @{ 40 | 41 | ////// 42 | /// @brief The maximum size that can be output by a single `cnc_cxnrtomcn` function call. 43 | #define CNC_MC_MAX 64 44 | ////// 45 | /// @brief The maximum size that can be output by a single `cnc_cxnrtomwcn` function call. 46 | #define CNC_MWC_MAX 32 47 | ////// 48 | /// @brief The maximum size that can be output by a single `cnc_cxnrtoc32n` function call. 49 | #define CNC_C32_MAX 16 50 | ////// 51 | /// @brief The maximum size that can be output by a single `cnc_cxnrtoc16n` function call. 52 | #define CNC_C16_MAX (CNC_C32_MAX * 2) 53 | ////// 54 | /// @brief The maximum size that can be output by a single `cnc_cxnrtoc8n` function call. 55 | #define CNC_C8_MAX (CNC_C32_MAX * 4) 56 | 57 | ////// 58 | /// @brief The maximum size that can be output by a single `cnc_cxnrtomcn` function call. 59 | #define CNC_MC_INPUT_MAX 17 60 | ////// 61 | /// @brief The maximum size that can be output by a single `cnc_cxnrtomwcn` function call. 62 | #define CNC_MWC_INPUT_MAX 17 63 | ////// 64 | /// @brief The maximum size that can be output by a single `cnc_cxnrtoc32n` function call. 65 | #define CNC_C32_INPUT_MAX 17 66 | ////// 67 | /// @brief The maximum size that can be output by a single `cnc_cxnrtoc16n` function call. 68 | #define CNC_C16_INPUT_MAX 17 69 | ////// 70 | /// @brief The maximum size that can be output by a single `cnc_cxnrtoc8n` function call. 71 | #define CNC_C8_INPUT_MAX 17 72 | 73 | ////// 74 | /// @} 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /documentation/source/api/heap.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | Conversion Heap and Functions 32 | ============================= 33 | 34 | For the type-erased, registry-based conversions, a heap is used to perform all allocations to ensure the end-user is in control of how much memory is ultimately used, even if they do not have full control over the type-erased data structures. To this end, the :cpp:class:`cnc_conversion_heap` is used, and it is described below in the convenience functions which will pass through the designated ``user_data`` and similar to the specified heap's given functionality. 35 | 36 | The default heap uses ``malloc``, ``free``, and ``realloc`` for its implementation, ignoring related alignment and user data parameters. It also performs no attempted shrinking or expanding of any given allocation, single ignoring all parameters and following the specification for performing no action. 37 | 38 | 39 | 40 | Function Calls 41 | -------------- 42 | 43 | .. doxygenfunction:: cnc_heap_allocate 44 | 45 | .. doxygenfunction:: cnc_heap_deallocate 46 | 47 | .. doxygenfunction:: cnc_heap_reallocate_allocation 48 | 49 | .. doxygenfunction:: cnc_heap_expand_allocation 50 | 51 | .. doxygenfunction:: cnc_heap_shrink_allocation 52 | 53 | 54 | 55 | Heap Object 56 | ----------- 57 | 58 | .. doxygenstruct:: cnc_conversion_heap 59 | :members: 60 | 61 | 62 | 63 | Types 64 | ----- 65 | 66 | .. doxygentypedef:: cnc_heap_allocate_function_ptr 67 | 68 | .. doxygentypedef:: cnc_heap_deallocate_function_ptr 69 | 70 | .. doxygentypedef:: cnc_heap_reallocate_allocation_function_ptr 71 | 72 | .. doxygentypedef:: cnc_heap_expand_allocation_function_ptr 73 | 74 | .. doxygentypedef:: cnc_heap_shrink_allocation_function_ptr 75 | -------------------------------------------------------------------------------- /include/ztd/cuneicode/max_input_output.h: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #ifndef ZTD_CUNEICODE_MAX_INPUT_OUTPUT_H 31 | #define ZTD_CUNEICODE_MAX_INPUT_OUTPUT_H 32 | 33 | #pragma once 34 | 35 | #include 36 | 37 | ////// 38 | /// @addtogroup ztd_cuneicode_max_macros Maximum-Size Macros 39 | /// @{ 40 | 41 | ////// 42 | /// @brief The maximum size that can be output by a single `cnc_cxnrtomcn` function call. 43 | #define CNC_MC_MAX 64 44 | ////// 45 | /// @brief The maximum size that can be output by a single `cnc_cxnrtomwcn` function call. 46 | #define CNC_MWC_MAX 32 47 | ////// 48 | /// @brief The maximum size that can be output by a single `cnc_cxnrtoc32n` function call. 49 | #define CNC_C32_MAX 16 50 | ////// 51 | /// @brief The maximum size that can be output by a single `cnc_cxnrtoc16n` function call. 52 | #define CNC_C16_MAX (CNC_C32_MAX * 2) 53 | ////// 54 | /// @brief The maximum size that can be output by a single `cnc_cxnrtoc8n` function call. 55 | #define CNC_C8_MAX (CNC_C32_MAX * 4) 56 | 57 | ////// 58 | /// @brief The maximum size that can be output by a single `cnc_cxnrtomcn` function call. 59 | #define CNC_MC_INPUT_MAX 17 60 | ////// 61 | /// @brief The maximum size that can be output by a single `cnc_cxnrtomwcn` function call. 62 | #define CNC_MWC_INPUT_MAX 17 63 | ////// 64 | /// @brief The maximum size that can be output by a single `cnc_cxnrtoc32n` function call. 65 | #define CNC_C32_INPUT_MAX 17 66 | ////// 67 | /// @brief The maximum size that can be output by a single `cnc_cxnrtoc16n` function call. 68 | #define CNC_C16_INPUT_MAX 17 69 | ////// 70 | /// @brief The maximum size that can be output by a single `cnc_cxnrtoc8n` function call. 71 | #define CNC_C8_INPUT_MAX 17 72 | 73 | ////// 74 | /// @} 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /documentation/source/api/mcstate_t.rst: -------------------------------------------------------------------------------- 1 | .. ============================================================================ 2 | .. 3 | .. ztd.cuneicode 4 | .. Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | .. Contact: opensource@soasis.org 6 | .. 7 | .. Commercial License Usage 8 | .. Licensees holding valid commercial ztd.cuneicode licenses may use this file in 9 | .. accordance with the commercial license agreement provided with the 10 | .. Software or, alternatively, in accordance with the terms contained in 11 | .. a written agreement between you and Shepherd's Oasis, LLC. 12 | .. For licensing terms and conditions see your agreement. For 13 | .. further information contact opensource@soasis.org. 14 | .. 15 | .. Apache License Version 2 Usage 16 | .. Alternatively, this file may be used under the terms of Apache License 17 | .. Version 2.0 (the "License") for non-commercial use; you may not use this 18 | .. file except in compliance with the License. You may obtain a copy of the 19 | .. License at 20 | .. 21 | .. https://www.apache.org/licenses/LICENSE-2.0 22 | .. 23 | .. Unless required by applicable law or agreed to in writing, software 24 | .. distributed under the License is distributed on an "AS IS" BASIS, 25 | .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | .. See the License for the specific language governing permissions and 27 | .. limitations under the License. 28 | .. 29 | .. ========================================================================= .. 30 | 31 | ``cnc_mcstate_t`` 32 | ================= 33 | 34 | The state object is used during conversions to provide a place for the function to write any temporary data into. This is useful for encodings such as IBM or Microsoft's rendition of SHIFT-JIS, where specific shift sequences are used to provide additional sequences or information for a given input or output string. 35 | 36 | .. note:: 37 | 38 | For the ``c8``, ``c16``, and ``c32`` prefixed/suffixed functions, it may **not** use the state objects to store "partial writes" or "partial reads" of the data. Any encoding defined as UTF-8, UTF-16, and UTF-32 used through the ``mc`` (:term:`execution encoding`-related) or ``mwc`` (:term:`wide execution encoding`-related) shall also not be used to store partial pieces of the input or partial pieces of the output in order to accumulate information before reading in more data or writing out. If there is insufficient space to do a write to the output, :cpp:enumerator:`cnc_mcerr_insufficient_output` must be returned. Similarly, if there is insufficient data and the data is at the very end, then :cpp:enumerator:`cnc_mcerr_incomplete_input` must be returned. 39 | 40 | An implementation may define encodings which are not UTF-8, UTF-16, or UTF-32 that **does** perform partial writes, such as a ``"UTF-8-partial"`` or ``"UTF-32-partial"``. But it shall not have the same ``LC_TYPE`` identifier as the UTF-8, UTF-16, or UTF-32 encodings. 41 | 42 | .. doxygenunion:: cnc_mcstate_t 43 | 44 | .. doxygenfunction:: cnc_mcstate_is_complete 45 | 46 | 47 | State Functions 48 | --------------- 49 | 50 | .. doxygenfunction:: cnc_mcstate_set_assume_valid 51 | 52 | .. doxygenfunction:: cnc_mcstate_is_assuming_valid 53 | -------------------------------------------------------------------------------- /examples/documentation/quick/basic/source/utf16_to_utf8.c: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // 3 | // ztd.cuneicode 4 | // Copyright © JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC 5 | // Contact: opensource@soasis.org 6 | // 7 | // Commercial License Usage 8 | // Licensees holding valid commercial ztd.cuneicode licenses may use this file 9 | // in accordance with the commercial license agreement provided with the 10 | // Software or, alternatively, in accordance with the terms contained in 11 | // a written agreement between you and Shepherd's Oasis, LLC. 12 | // For licensing terms and conditions see your agreement. For 13 | // further information contact opensource@soasis.org. 14 | // 15 | // Apache License Version 2 Usage 16 | // Alternatively, this file may be used under the terms of Apache License 17 | // Version 2.0 (the "License"); you may not use this file except in compliance 18 | // with the License. You may obtain a copy of the License at 19 | // 20 | // https://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | // ========================================================================= // 29 | 30 | #include 31 | 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | int main(int argc, char* argv[]) { 39 | (void)argc; 40 | (void)argv; 41 | 42 | const ztd_char16_t utf16_text[] = u"🥺🙏"; 43 | ztd_char8_t utf8_text[9] = { 0 }; 44 | 45 | // Now, actually output it 46 | const ztd_char16_t* p_input = utf16_text; 47 | ztd_char8_t* p_output = utf8_text; 48 | size_t input_size = ztdc_c_string_array_size(utf16_text); 49 | size_t output_size = ztdc_c_array_size(utf8_text); 50 | cnc_mcstate_t state = { 0 }; 51 | // call the function with the right parameters! 52 | cnc_mcerr err = cnc_c16snrtoc8sn( // formatting 53 | &output_size, &p_output, // output first 54 | &input_size, &p_input, // input second 55 | &state); // state parameter 56 | const size_t input_consumed = (ztdc_c_array_size(utf16_text) - input_size); 57 | const size_t output_written = (ztdc_c_array_size(utf8_text) - output_size); 58 | if (err != cnc_mcerr_ok) { 59 | const char* err_str = cnc_mcerr_to_str(err); 60 | fprintf(stderr, 61 | "An (unexpected) error occurred and the conversion could not " 62 | "happen! Error string: %s (code: '%d')\n", 63 | err_str, (int)err); 64 | return 1; 65 | } 66 | 67 | printf( 68 | "Converted %zu UTF-16 code units to %zu UTF-8 code units, giving the " 69 | "text:", 70 | input_consumed, output_written); 71 | // requires a capable terminal / output, but will be 72 | // UTF-8 text! 73 | fwrite(utf8_text, sizeof(ztd_char8_t), output_written, stdout); 74 | printf("\n"); 75 | 76 | return 0; 77 | } 78 | --------------------------------------------------------------------------------