{"id":18716687,"url":"https://github.com/maxdz-gmbh/mdz_string","last_synced_at":"2026-04-12T13:34:26.359Z","repository":{"id":208427004,"uuid":"571944393","full_name":"maxdz-gmbh/mdz_string","owner":"maxdz-gmbh","description":"Very lightweight and portable ANSI C 89/90 compliant library for handling single-byte (ASCII/ANSI) strings and Unicode strings.","archived":false,"fork":false,"pushed_at":"2024-10-01T14:03:01.000Z","size":246,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-12-28T10:33:06.231Z","etag":null,"topics":["android","ansible","ascii","c","freebsd","library","linux","macos","portable","strings","unicode","utf-16","utf-32","utf-8","utf16","utf32","utf8","wchar","windows"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxdz-gmbh.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.txt","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-29T08:17:48.000Z","updated_at":"2024-10-01T14:03:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"56334c54-e1e9-4c20-8d6b-c36b9598dc48","html_url":"https://github.com/maxdz-gmbh/mdz_string","commit_stats":null,"previous_names":["maxdz-gmbh/mdz_string"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxdz-gmbh%2Fmdz_string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxdz-gmbh%2Fmdz_string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxdz-gmbh%2Fmdz_string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxdz-gmbh%2Fmdz_string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxdz-gmbh","download_url":"https://codeload.github.com/maxdz-gmbh/mdz_string/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239581798,"owners_count":19662958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","ansible","ascii","c","freebsd","library","linux","macos","portable","strings","unicode","utf-16","utf-32","utf-8","utf16","utf32","utf8","wchar","windows"],"created_at":"2024-11-07T13:13:25.267Z","updated_at":"2025-10-11T01:32:03.680Z","avatar_url":"https://github.com/maxdz-gmbh.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"**September 2024 NOTE:** This repo is obsolete. Please use following repos for processing single-byte (ASCII/ANSI) strings instead:\n- [mdz_ansi_alg] for string processing algorithms\n- [mdz_ansi_16] for short attached strings\n- [mdz_ansi_dyn] for long dynamically-allocated strings\n\nRepos with unicode-strings functions (for UTF-8, UTF-16, UTF-32, wchar_t) will come soon.\n\n**NOTE:** All 0.x releases are kind of \"alpha-versions\" without expectations of API backward-compatibility.\n\n## Table of Contents\n[mdz_string Overview](#mdz_string-Overview)\u003cbr\u003e\n[mdz_string Advantages](#mdz_string-Advantages)\u003cbr\u003e\n[Performance Comparison](#performance-comparison)\u003cbr\u003e\n[mdz_string Usage](#mdz_string-Usage)\u003cbr\u003e\n[mdz_ansi Overview](#mdz_ansi-Overview)\u003cbr\u003e\n[mdz_wchar Overview](#mdz_wchar-Overview)\u003cbr\u003e\n[mdz_utf8 Overview](#mdz_utf8-Overview)\u003cbr\u003e\n[mdz_utf16 Overview](#mdz_utf16-Overview)\u003cbr\u003e\n[mdz_utf32 Overview](#mdz_utf32-Overview)\u003cbr\u003e\n[Licensing info](#Licensing-info)\u003cbr\u003e\n\n## mdz_string Overview\n\nWiki: [mdz_string Wiki]\u003cbr\u003e\nfile: *\"mdz_string.h\"*\n\nPlease take a look at *\"mdz_string.h\"* file or [mdz_string Wiki] site for detailed functions descriptions.\n\n[mdz_string Wiki]: https://github.com/maxdz-gmbh/mdz_string/wiki/mdz_string-overview\n\n[mdz_string] - very lightweight and versatile C library for handling single-byte (ASCII/ANSI) strings and Unicode strings, developed by [maxdz Software GmbH].The library supports ASCII/ANSI, UTF8, UTF16, UTF32, wchar strings. Source code of library is highly-portable, conforms to ANSI C 89/90 Standard. Builds for Win32/Win64, Linux, FreeBSD, Android, macOS are available.\n\nOnly shared/dynamically loaded libraries (*.so* and *.dll* files with import libraries) are available for evaluation testing purposes. Static libraries/source code are covered by our commercial licenses.\n\n**Linux** binaries are built against Linux Kernel 2.6.18 - and thus should be compatible with Debian (from ver. 4.0), Ubuntu (from ver. 8.04), Fedora (from ver. 9)\n\n**FreeBSD** binaries - may be used from FreeBSD ver. 7.0\n\n**Win32** binaries are built using Visual Studio Platform Toolset \"v90\", thus are compatible with Windows versions from Windows 2000.\u003cbr\u003e\n**Win64** binaries are built using Visual Studio Platform Toolset \"v100\", thus are compatible with Windows versions from Windows XP.\u003cbr\u003e\n\n**Android** x86/armeabi-v7a binaries - may be used from Android API level 16 (\"Jelly Bean\" ver. 4.1.x)\u003cbr\u003e\n**Android** x86_64/arm64-v8a binaries - may be used from Android API level 21 (\"Lollipop\" ver. 5.0)\n\n**macOS** binaries - x86_64, from *MacOS X v10.6.0*\n\n[mdz_string]: https://github.com/maxdz-gmbh/mdz_string\n[maxdz Software GmbH]: https://maxdz.com/\n[mdz_ansi_alg]: https://github.com/maxdz-gmbh/mdz_ansi_alg\n[mdz_ansi_16]: https://github.com/maxdz-gmbh/mdz_ansi_16\n[mdz_ansi_dyn]: https://github.com/maxdz-gmbh/mdz_ansi_dyn\n\n## mdz_string Advantages\n\n**1. High portability:** the whole code conforms to ANSI C 89/90 Standard. Multithreading/asynchronous part is POSIX compatible (under UNIX/Linux).\n\n**2. Little dependencies:** basically *mdz_string* functions are only dependend on standard C-library memory-management/access functions. Multithreading part is dependend on POSIX *pthreads* API (under UNIX/Linux) and old process control/synchronization API (from Windows 2000). It means you can use library in your code withouth any further dependencies except standard platform libraries/APIs.\n\n**3. Fast:** Our single-byte (ASCII/ANSI) strings are very fast, concerning operations like searching, insertion, deletion, etc. especially for very large (like hundreds of megabytes or gigabytes) strings.\n\n**4. Flexibilty:** nearly all functions our single-byte (ASCII/ANSI) strings, contain not only \"left position\" but also \"right position\" parameters to limit processed area from right. Also library contains more string functions than according STL, boost or glib analogs have.\n\n**5. Extended error-checking:** all functions preserve internal error-code pointing the problem. It is possible to use strict error-checking (when all preserved error-codes should be *MDZ_ERROR_NONE*) or \"relaxed\"-checking - when only returned *mdz_false* will indicate error.\n\n**6. Extended control:** strings do only explicit operations. It means for example, when \"insert\" function is called with auto-reservation flag set in *mdz_false* - it will return error if there is not enough capacity in string. No implicit reservations will be made.\n\n**7. Attached usage:** strings should not necessarily use dynamically-allocated memory - which may be not available on your embedded system (or if malloc()/free() are forbidden to use in your safety-critical software). Just attach string/data to your statically-allocated memory and use all strings functionality.\n\n**8. Cache-friendly:** it is possible to keep controlling and data parts together in memory using \"embedded part\".\n\n**9. Unicode support:** UTF-8, UTF-16, UTF-32 are supported.\n\n**10. wchar_t support:** also wchar_t strings are supported, with 2 and 4 bytes-large *wchar_t* characters.\n\n**11. Endianness-aware strings:** wchar, utf16 and utf32 strings are endiannes-aware thus may be used to produce and manipulate strings with pre-defined endianness even if endianness of host differs.\n\n**12. Unicode \"surrogate-pairs\" awareness:** 2-byte Unicode strings correctly process/distinguish \"surrogate-pairs\" as 1 Unicode symbol.\n\n**13. Asynchronous execution:** almost all functions of single-byte (ASCII/ANSI) strings and *insert* functions can be executed asynchronously\n\n## Performance Comparison\n\nPerformance comparison tables for *[mdz_ansi_find]*() and *[mdz_ansi_firstOf]*() give an idea about *mdz_ansi* library overall performance on different platforms compared to STL and standard C library. Modern implementationsof STL and standard C library are pretty fast, using optimized versions of memory-access functions.\n\n- **[mdz_ansi_find]() Test**\n\nFollowing tests are executed:\n\n- Test *1/100M*\": Find 1 byte - in the end of 100M bytes long string\u003cbr\u003e\n- Test *5/100M*\": Find 5 bytes long string - in the end of 100M bytes long string\u003cbr\u003e\n- Test *10/100M*\": Find 10 bytes long string - in the end of 100M bytes long string\u003cbr\u003e\n- Test *100/100M*\": Find 100 bytes long string - in the end of 100M bytes long string\u003cbr\u003e\n- Test *1K/100M*\": Find 1K bytes long string - in the end of 100M bytes long string\u003cbr\u003e\n- Test *500K/1M*\": Find 500K bytes long string - in the end of 1M bytes long string\u003cbr\u003e\n- Test *100M-100/100M*\": Find \"100M minus 100\" bytes long string - in the end of 100M bytes long string\u003cbr\u003e\n- Test *100M/100M*\": Find 100M bytes long string - in 100M bytes long string\u003cbr\u003e\n\nFor **Windows 10 (64-bit)** on *Intel i5-6600 @ 3.30GHz (4 cores/4 threads)*\u003cbr\u003e\n\n**Monotone test** : \"long string\" and \"string to find\" are both filled with '1's; on the last position of both strings is '2'\n\nmonotone = MDZ_FIND_MONOTONE method\u003cbr\u003e\nclib = MDZ_FIND_CLIB method (standard C library)\u003cbr\u003e\nbrute = MDZ_FIND_BRUTE method\u003cbr\u003e\nbmh = MDZ_FIND_BMH method\n\n- VC++ toolset v140 (32-bit)\u003cbr\u003e\n(all numbers are in microseconds measured using *QueryPerformanceCounter()* in main execution thread)\n\n| Test  | mdz_ansi, monotone | mdz_ansi, clib | mdz_ansi, brute |  mdz_ansi, bmh |std::string.find() | clib (strstr())|\n| :---:| ---: | ---: | ---: | ---: | ---: | ---: |\n| 1/100M| **70,351** |  |  |  | 162,681 | 70,579 |\n| 5/100M| **407,668** | 460,052 | 3,045,869 | 781,655 | 3,381,061 | 482,075 |\n| 10/100M| 1,334,782 | **707,712** | 4,394,022 | 780,128 | 4,206,329 | 731,395 |\n| 100/100M| 1,333,516 | 10,914,646 | 15,779,350 | **781,370** | 15,652,407 | 11,253,026 |\n| 1K/100M| 1,332,838 | 70,179,989 | 139,398,637 | **781,439** | 139,808,212 | 75,808,535 |\n| 500K/1M| 13,202 | 166,409,422 | 323,375,345 | **9,411** | 324,276,637 | 178,302,908 |\n| 100M-100/100M| 1,262,919 | 10,884,012 | 14,182,350 | **1,066,737** | 14,150,110 | 10,383,086 |\n| 100M/100M| 117,970 | |  |  | 144,573 | **114,565** |\n\n- MinGW/gcc toolset (32-bit)\u003cbr\u003e\n(all numbers are in microseconds measured using *QueryPerformanceCounter()* in main execution thread)\n\n| Test  | mdz_ansi, monotone | mdz_ansi, clib | mdz_ansi, brute |  mdz_ansi, bmh |\n| :---:| ---: | ---: | ---: | ---: |\n| 1/100M| 148,067 |  |  |  |\n| 5/100M| **534,070** | 1,599,882 | 6,825,862 | 784,326 |\n| 10/100M| **551,404** | 3,635,378 | 7,898,385 | 783,832 |\n| 100/100M| **550,701** | 32,447,796 | 20,451,496 | 786,006 |\n| 1K/100M| **551,213** | 348,052,489 | 117,762,194 | 784,335 |\n| 500K/1M| 7,851 | 814,620,053 | 246,574,213 | **6,263** |\n| 100M-100/100M| 997,729 | 33,028,357 | 11,705,985| **456,680** |\n| 100M/100M| 328,564 | |  |  |\n\n- **[mdz_ansi_firstOf]() Test**\n\nFollowing tests are executed:\n\n- Test *1/100M*\": Find first of 1 byte - in the end of 100M bytes long string\u003cbr\u003e\n- Test *5/100M*\": Find first of 5 bytes - in the end of 100M bytes long string\u003cbr\u003e\n- Test *20/100M*\": Find first of 20 bytes - in the end of 100M bytes long string\u003cbr\u003e\n- Test *50/100M*\": Find first of 50 bytes - in the end of 100M bytes long string\u003cbr\u003e\n- Test *100/100M*\": Find first of 100 bytes - in the end of 100M bytes long string\u003cbr\u003e\n\nFor **Windows 10 (64-bit)** on *Intel i5-6600 @ 3.30GHz (4 cores/4 threads)*\u003cbr\u003e\n\n- VC++ toolset v140 (32-bit)\u003cbr\u003e\n(all numbers are in microseconds measured using *QueryPerformanceCounter()* in main execution thread)\n\n| Test  | mdz_ansi| std::string.find_first_of() | clib (strcspn())|\n| :---:| ---: | ---: | ---: |\n| 1/100M| **70,078** | 163,666 | 2,085,714 |\n| 5/100M| **370,204** | 3,719,660 | 2,077,677 |\n| 20/100M| **369,162** | 5,714,212 | 2,076,031 |\n| 50/100M| **368,994** | 10,965,401 | 2,078,038 |\n| 100/100M| **369,360** | 18,727,283 | 2,076,740 |\n\n- MinGW/gcc toolset (32-bit)\u003cbr\u003e\n(all numbers are in microseconds measured using *QueryPerformanceCounter()* in main execution thread)\n\n| Test  | mdz_ansi|\n| :---:| ---: |\n| 1/100M| 153,511 |\n| 5/100M| 278,387 |\n| 20/100M| 276,389 |\n| 50/100M| 275,956 |\n| 100/100M| 277,709 |\n\n[mdz_ansi_find]: https://github.com/maxdz-gmbh/mdz_ansi/wiki/mdz_ansi_find_async\n[mdz_ansi_firstOf]: https://github.com/maxdz-gmbh/mdz_ansi/wiki/mdz_ansi_firstOf_async\n\n## mdz_string Usage\n\n**mdz_string** is implemented with strict input parameters checking. It means *mdz_false* or some other error indication will be returned if one or several input parameters are invalid - even if such an invalidity doesn't lead to inconsistence (for example adding or removing 0 items).\n\n**Test license generation:** - in order to get free test-license, please proceed to our Shop page [maxdz Shop] and register an account. After registration you will be able to obtain free 30-days test-licenses for our products using \"Obtain for free\" button. \nTest license data should be used in *mdz_string_init()* call for library initialization.\n\n**NOTE:** All 0.x releases are kind of \"beta-versions\" and can be used 1) only with test-license (during test period of 30 days, with necessity to re-generate license for the next 30 days test period) and 2) without expectations of interface backward-compatibility.\n\n[mdz_string Wiki]: https://github.com/maxdz-gmbh/mdz_string/wiki/mdz_string-overview\n[maxdz Shop]: https://maxdz.com/shop.php\n\n#### Code Example\n\n*mdz_string_init()* with license information should be called for library initialization before any subsequent calls:\n\n```\n#include \u003cmdz_string.h\u003e\n\nint main(int argc, char* argv[])\n{\n  /* mdz_string library initialization using test info retrieved after license generation (see \"Test license generation\" above) */\n  \n  mdz_bool bRet = mdz_string_init(\"\u003cfirst-name-hash\u003e\", \"\u003clast-name-hash\u003e\", \"\u003cemail-hash\u003e\", \"\u003clicense-hash\u003e\");\n  ...\n\n  mdz_string_uninit(); /* call for un-initialization of library */\n  \n  return 0;  \n}\n```\n\n[mdz_utf8_create]: https://github.com/maxdz-gmbh/mdz_string/wiki/mdz_utf8_create\n[mdz_utf8_destroy]: https://github.com/maxdz-gmbh/mdz_string/wiki/mdz_utf8_destroy\n\nAfter library initialization call *[mdz_utf8_create]*() for **utf8** string creation. There should be also symmetric *[mdz_utf8_destroy]*() call for every create, otherwise allocated for string memory remains occupied:\n\n```\n#include \u003cmdz_string.h\u003e\n#include \u003cmdz_utf8.h\u003e\n\nint main(int argc, char* argv[])\n{\n  mdz_bool bRet = mdz_string_init(\"\u003cfirst-name-hash\u003e\", \"\u003clast-name-hash\u003e\", \"\u003cemail-hash\u003e\", \"\u003clicense-hash\u003e\");\n  \n  // initialize pAnsi\n  \n  mdz_Utf8* pUtf8 = mdz_utf8_create(0); // create utf8-string\n  ...\n  ...\n  // use pUtf8\n  ...\n  ...\n  // destroy pUtf8\n  \n  mdz_utf8_destroy(\u0026pUtf8); // after this pUtf8 should be NULL\n  \n  mdz_string_uninit();\n  ...\n}\n```\n\nUse *mdz_Utf8** pointer for subsequent library calls:\n\n```\n#include \u003cmdz_string.h\u003e\n#include \u003cmdz_utf8.h\u003e\n\nint main(int argc, char* argv[])\n{\n  mdz_bool bRet = mdz_string_init(\"\u003cfirst-name-hash\u003e\", \"\u003clast-name-hash\u003e\", \"\u003cemail-hash\u003e\", \"\u003clicense-hash\u003e\");\n  \n  mdz_Utf8* pUtf8 = mdz_utf8_create(0); // create utf8-string\n\n  // reserve memory for 5 elements\n  \n  bRet = mdz_utf8_reserve(pUtf8, 5);\n  \n  // insert 'b' in front position with auto-reservation if necessary\n  \n  bRet = mdz_utf8_insertAnsi(pUtf8, 0, \"b\", 1, mdz_true); // \"b\" after this call\n  \n  // append string with \"cde\" with auto-reservation if necessary\n  \n  bRet = mdz_utf8_insert(pUtf8, (size_t) -1, \"cde\", 3, mdz_true); // \"bcde\" after this call\n  \n  ...\n  \n  mdz_utf8_destroy(\u0026pUtf8);\n  \n  mdz_string_uninit();\n  ...\n}\n```\n\n## mdz_ansi Overview\nWiki: [mdz_ansi Wiki]\u003cbr\u003e\nfile: *\"mdz_ansi.h\"*\n\nPlease take a look at *\"mdz_ansi.h\"* file or [mdz_ansi Wiki] site for detailed functions descriptions.\n\n[mdz_ansi Wiki]: https://github.com/maxdz-gmbh/mdz_string/wiki/mdz_ansi-overview\n\n## mdz_wchar Overview\nWiki: [mdz_wchar Wiki]\u003cbr\u003e\nfile: *\"mdz_wchar.h\"*\n\nPlease take a look at *\"mdz_wchar.h\"* file or [mdz_wchar Wiki] site for detailed functions descriptions.\n\n[mdz_wchar Wiki]: https://github.com/maxdz-gmbh/mdz_string/wiki/mdz_wchar-overview\n\n## mdz_utf8 Overview\nWiki: [mdz_utf8 Wiki]\u003cbr\u003e\nfile: *\"mdz_utf8.h\"*\n\nPlease take a look at *\"mdz_utf8.h\"* file or [mdz_utf8 Wiki] site for detailed functions descriptions.\n\n[mdz_utf8 Wiki]: https://github.com/maxdz-gmbh/mdz_string/wiki/mdz_utf8-overview\n\n## mdz_utf16 Overview\nWiki: [mdz_utf16 Wiki]\u003cbr\u003e\nfile: *\"mdz_utf16.h\"*\n\nPlease take a look at *\"mdz_utf16.h\"* file or [mdz_utf16 Wiki] site for detailed functions descriptions.\n\n[mdz_utf16 Wiki]: https://github.com/maxdz-gmbh/mdz_string/wiki/mdz_utf16-overview\n\n## mdz_utf32 Overview\nWiki: [mdz_utf32 Wiki]\u003cbr\u003e\nfile: *\"mdz_utf32.h\"*\n\nPlease take a look at *\"mdz_utf32.h\"* file or [mdz_utf32 Wiki] site for detailed functions descriptions.\n\n[mdz_utf32 Wiki]: https://github.com/maxdz-gmbh/mdz_string/wiki/mdz_utf32-overview\n\n## Licensing info\n\nUse of **mdz_string** library is regulated by license agreement in *LICENSE.txt*\n\nBasically private non-commercial \"test\" usage is unrestricted. Commercial usage of library (incl. its source code) will be regulated by according license agreement.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxdz-gmbh%2Fmdz_string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxdz-gmbh%2Fmdz_string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxdz-gmbh%2Fmdz_string/lists"}