{"id":20027436,"url":"https://github.com/huidaecho/libaprintf","last_synced_at":"2026-06-13T14:03:38.383Z","repository":{"id":138941529,"uuid":"256907033","full_name":"HuidaeCho/libaprintf","owner":"HuidaeCho","description":"Aligned printf C library","archived":false,"fork":false,"pushed_at":"2024-04-23T04:23:45.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T04:43:26.515Z","etag":null,"topics":["c","c-library","cjk","formatter","formatting","library","print","printf"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HuidaeCho.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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":"2020-04-19T03:39:37.000Z","updated_at":"2024-04-23T04:23:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"79b3534f-d8c8-4195-9ed5-b287391f52e3","html_url":"https://github.com/HuidaeCho/libaprintf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HuidaeCho/libaprintf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuidaeCho%2Flibaprintf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuidaeCho%2Flibaprintf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuidaeCho%2Flibaprintf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuidaeCho%2Flibaprintf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HuidaeCho","download_url":"https://codeload.github.com/HuidaeCho/libaprintf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuidaeCho%2Flibaprintf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286079811,"owners_count":27282121,"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","status":"online","status_checked_at":"2025-11-26T02:00:06.075Z","response_time":193,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["c","c-library","cjk","formatter","formatting","library","print","printf"],"created_at":"2024-11-13T09:10:18.916Z","updated_at":"2025-11-26T14:01:54.303Z","avatar_url":"https://github.com/HuidaeCho.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Libaprintf\n\nLibaprintf is the aligned printf C library. Functionally, it is similar to the [CJK Format](https://github.com/HuidaeCho/cjkformat) Python 3 module.\n\nIn the C language, the `strlen()` of a CJK character is not 1 because `strlen()` returns the byte length of a string and CJK characters use more than one byte per character. For example, `strlen(\"가\")` returns 3 because Hangul syllable Ga (가) consists of `0xEA`, `0xB0`, and `0x80`. The same byte length applies to `printf()`'s string specifier (`%s`). Again, \"가\" in `printf(\"%-10s|\", \"가\")` will consume three bytes internally and leave seven spaces resulting in\n\n![Ga misaligned](ga-misaligned.png \"Ga misaligned\")\n\nThe pipe character (`|`) is at column 10, not at 11 (10 characters from `%-10s` plus `|`) as in\n\n![Ga aligned](ga-aligned.png \"Ga aligned\")\n\nThis misalignment issue occurs because CJK characters' byte length (3) and display length (2) are different.\n\nThe libaprintf library tries to fix this problem and defines the following functions:\n* `int count_wide_chars(const char *str)` counts the number of wide characters in a string,\n* `int count_wide_chars_in_cols(const char *str, int ncols, int *nbytes)` counts the numbers of wide characters and bytes in a string in a number of columns,\n* `int aprintf(const char *format, ...)` adjusts the width of string specifiers to the display space instead of the number of bytes for wide characters and printf them using the adjusted display width,\n* `int faprintf(FILE *stream, const char *format, ...)` is the `fprintf()` version of `aprintf()`,\n* `int saprintf(char *str, const char *format, ...)` is the `sprintf()` version of `aprintf()`, and\n* `int snaprintf(char *str, size_t size, const char *format, ...)` is the `snprintf()` version of `aprintf()`.\n\n## Installation\n\n```bash\n# build the library and test\nmake\n\n# test\n./test\n```\n\n![Test](test.png \"Test\")\n\n## License\n\nCopyright (C) 2020, Huidae Cho \u003c\u003chttps://idea.isnew.info\u003e\u003e\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see \u003c\u003chttp://www.gnu.org/licenses/\u003e\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuidaecho%2Flibaprintf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuidaecho%2Flibaprintf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuidaecho%2Flibaprintf/lists"}