{"id":18406979,"url":"https://github.com/nvzqz/c-utf8-rs","last_synced_at":"2025-04-07T08:32:34.150Z","repository":{"id":57614955,"uuid":"136903952","full_name":"nvzqz/c-utf8-rs","owner":"nvzqz","description":"UTF-8 encoded C strings for Rust","archived":false,"fork":false,"pushed_at":"2024-06-04T01:37:29.000Z","size":41,"stargazers_count":7,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-22T15:51:38.529Z","etag":null,"topics":["c","rust","string","text","unicode","utf-8"],"latest_commit_sha":null,"homepage":"https://docs.rs/c_utf8/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nvzqz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2018-06-11T09:26:27.000Z","updated_at":"2025-02-01T12:57:38.000Z","dependencies_parsed_at":"2024-11-06T03:15:59.434Z","dependency_job_id":"50a2a3b9-f3fa-4d06-9575-5ba9d20eb7a9","html_url":"https://github.com/nvzqz/c-utf8-rs","commit_stats":{"total_commits":51,"total_committers":1,"mean_commits":51.0,"dds":0.0,"last_synced_commit":"e874130e12a45e000a9db096e5def4b52c0007d5"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvzqz%2Fc-utf8-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvzqz%2Fc-utf8-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvzqz%2Fc-utf8-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvzqz%2Fc-utf8-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nvzqz","download_url":"https://codeload.github.com/nvzqz/c-utf8-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247620535,"owners_count":20968229,"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":["c","rust","string","text","unicode","utf-8"],"created_at":"2024-11-06T03:11:45.892Z","updated_at":"2025-04-07T08:32:33.818Z","avatar_url":"https://github.com/nvzqz.png","language":"Rust","funding_links":["https://www.patreon.com/nvzqz","https://www.paypal.me/nvzqz"],"categories":[],"sub_categories":[],"readme":"# C-Style UTF-8 Strings for Rust\n\n[![Build status][travis-badge]][travis]\n![Crate version](https://img.shields.io/crates/v/c_utf8.svg)\n![rustc version](https://img.shields.io/badge/rustc-^1.20.0-blue.svg)\n\nThis project makes it easier to establish guarantees when interfacing with\n[nul-terminated C string][c_str] APIs that require [UTF-8] encoding.\n\n[Documentation](https://docs.rs/c_utf8/)\n\n\u003ca href=\"https://www.patreon.com/nvzqz\"\u003e\n    \u003cimg src=\"https://c5.patreon.com/external/logo/become_a_patron_button.png\" alt=\"Become a Patron!\" height=\"35\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.paypal.me/nvzqz\"\u003e\n    \u003cimg src=\"https://buymecoffee.intm.org/img/button-paypal-white.png\" alt=\"Buy me a coffee\" height=\"35\"\u003e\n\u003c/a\u003e\n\n## What is UTF-8?\n\n[UTF-8] is the character encoding chosen by much of the programming community\nsince 2008, including Rust with its [`str`] primitive.\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://en.wikipedia.org/wiki/File:Utf8webgrowth.svg\"\u003e\n        \u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/c/c4/Utf8webgrowth.svg\"\n             alt=\"The usage of the main encodings on the web as recorded by Google\"\n             width=550\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n[UTF-8] is capable of representing all 1,112,064 code points of the [Unicode]\nstandard. Code points are variable-width, ranging from 8 to 32 bits wide.\n\n## Where does UTF-8 appear in C?\n\n### UTF-8 in SDL\n\nThe [Simple DirectMedia Layer (SDL)][sdl] library exposes certain APIs that only\ninterface with UTF-8 encoded C strings. Here's a potential wrapper one could\ncreate around SDL:\n\n```rust\nimpl Window {\n    /* ... */\n\n    fn title(\u0026self) -\u003e \u0026CUtf8 {\n        unsafe {\n            let title = SDL_GetWindowTitle(self.inner);\n            CUtf8::from_ptr(title).unwrap()\n        }\n    }\n\n    fn set_title(\u0026mut self, title: \u0026CUtf8) {\n        unsafe {\n            SDL_SetWindowTitle(self.inner, title.as_ptr());\n        }\n    }\n\n    /* ... */\n}\n```\n\nCreating a [`\u0026CUtf8`](https://docs.rs/c_utf8/*/c_utf8/struct.CUtf8.html)\ninstance to interface with the above code can be done easily via the\n[`c_utf8!`](https://docs.rs/c_utf8/*/c_utf8/macro.c_utf8.html) macro:\n\n```rust\nwindow.set_title(c_utf8!(\"MyAwesomeApp\"));\n```\n\n## Installation\n\nThis crate is available [on crates.io][crate] and can be used by adding the\nfollowing to your project's [`Cargo.toml`]:\n\n```toml\n[dependencies]\nc_utf8 = \"0.1.0\"\n```\n\nand this to your crate root (`lib.rs` or `main.rs`):\n\n```rust\n#[macro_use]\nextern crate c_utf8;\n```\n\n## License\n\nThis project is licensed under either of\n\n- Apache License, Version 2.0 ([`LICENSE-APACHE`] or\n  http://www.apache.org/licenses/LICENSE-2.0)\n\n- MIT License ([`LICENSE-MIT`] or http://opensource.org/licenses/MIT)\n\nat your option.\n\n[`Cargo.toml`]: https://doc.rust-lang.org/cargo/reference/manifest.html\n[`str`]:        https://doc.rust-lang.org/std/primitive.str.html\n[sdl]:          https://en.wikipedia.org/wiki/Simple_DirectMedia_Layer\n[c_str]:        https://en.wikipedia.org/wiki/Null-terminated_string\n[UTF-8]:        https://en.wikipedia.org/wiki/UTF-8\n[Unicode]:      https://en.wikipedia.org/wiki/Unicode\n\n[crate]: https://crates.io/crates/c_utf8\n\n[travis]:       https://travis-ci.com/nvzqz/c-utf8-rs\n[travis-badge]: https://travis-ci.com/nvzqz/c-utf8-rs.svg?branch=master\n\n[`LICENSE-APACHE`]: https://github.com/nvzqz/c-utf8-rs/blob/master/LICENSE-APACHE\n[`LICENSE-MIT`]:    https://github.com/nvzqz/c-utf8-rs/blob/master/LICENSE-MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnvzqz%2Fc-utf8-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnvzqz%2Fc-utf8-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnvzqz%2Fc-utf8-rs/lists"}