{"id":13721800,"url":"https://github.com/Tehreer/SheenBidi","last_synced_at":"2025-05-07T14:30:47.141Z","repository":{"id":23240254,"uuid":"26597967","full_name":"Tehreer/SheenBidi","owner":"Tehreer","description":"A sophisticated implementation of Unicode Bidirectional Algorithm","archived":false,"fork":false,"pushed_at":"2025-05-01T08:14:40.000Z","size":3883,"stargazers_count":138,"open_issues_count":7,"forks_count":24,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-01T09:23:11.678Z","etag":null,"topics":["ansi-c","bidi","c","c-plus-plus","c89","i18n","internationalization","library","script","text","uax-24","uax-9","uba","unicode","unicode-bidirectional-algorithm","writing"],"latest_commit_sha":null,"homepage":"","language":"C","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/Tehreer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2014-11-13T16:57:28.000Z","updated_at":"2025-03-21T16:10:10.000Z","dependencies_parsed_at":"2024-01-06T00:44:56.547Z","dependency_job_id":"e247c8c9-490c-4b18-b50d-777807ccc369","html_url":"https://github.com/Tehreer/SheenBidi","commit_stats":null,"previous_names":["mta452/sheenbidi"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tehreer%2FSheenBidi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tehreer%2FSheenBidi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tehreer%2FSheenBidi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tehreer%2FSheenBidi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tehreer","download_url":"https://codeload.github.com/Tehreer/SheenBidi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252895483,"owners_count":21821167,"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":["ansi-c","bidi","c","c-plus-plus","c89","i18n","internationalization","library","script","text","uax-24","uax-9","uba","unicode","unicode-bidirectional-algorithm","writing"],"created_at":"2024-08-03T01:01:21.519Z","updated_at":"2025-05-07T14:30:47.123Z","avatar_url":"https://github.com/Tehreer.png","language":"C","funding_links":[],"categories":["C","Font"],"sub_categories":[],"readme":"SheenBidi\n=========\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Travis-CI Build Status](https://app.travis-ci.com/Tehreer/SheenBidi.svg?branch=master)](https://app.travis-ci.com/github/Tehreer/SheenBidi)\n[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/k2vvegcdqsb9ld5a?svg=true)](https://ci.appveyor.com/project/mta452/sheenbidi)\n[![Coverage Status](https://coveralls.io/repos/github/Tehreer/SheenBidi/badge.svg?branch=master)](https://coveralls.io/github/Tehreer/SheenBidi)\n\nSheenBidi implements Unicode Bidirectional Algorithm available at http://www.unicode.org/reports/tr9. It is a sophisticated implementation which provides the developers an easy way to use UBA in their applications.\n\nHere are some of the advantages of SheenBidi.\n\n* Object based.\n* Optimized to the core.\n* Designed to be thread safe.\n* Lightweight API for interaction.\n* Supports UTF-8, UTF-16 and UTF-32 encodings.\n\n## API\n\u003cimg src=\"https://user-images.githubusercontent.com/2664112/39663208-716af1c4-5088-11e8-855c-ababe3e58c58.png\" width=\"350\"\u003e\nThe above screenshot depicts a visual representation of the API on a sample text.\n\n### SBCodepointSequence\nIt works as a code point decoder by accepting a string buffer in specified encoding.\n\n### SBAlgorithm\nIt provides bidirectional type of each code unit in source string. Paragraph boundaries can be queried from it as determined by rule [P1](https://www.unicode.org/reports/tr9/#P1). Individual paragraph objects can be created from it by explicitly specifying the base level or deriving it from rules [P2](https://www.unicode.org/reports/tr9/#P2)-[P3](https://www.unicode.org/reports/tr9/#P3).\n\n### SBParagraph\nIt represents a single paragraph of text processed with rules [X1](https://www.unicode.org/reports/tr9/#X1)-[I2](https://www.unicode.org/reports/tr9/#I2). It provides resolved embedding levels of all the code units of a paragraph.\n\n### SBLine\nIt represents a single line of text processed with rules [L1](https://www.unicode.org/reports/tr9/#L1)-[L2](https://www.unicode.org/reports/tr9/#L2). However, it provides reordered level runs instead of reordered characters.\n\n### SBRun\nIt represents a sequence of characters which have the same embedding level. The direction of a run would be right-to-left, if its embedding level is odd.\n\n### SBMirrorLocator\nIt provides the facility to find out the mirrored characters in a line as determined by rule [L4](https://www.unicode.org/reports/tr9/#L4).\n\n### SBScriptLocator\nNot directly related to UBA but can be useful for text shaping. It provides the facility to find out the script runs as specified in [UAX #24](https://www.unicode.org/reports/tr24/).\n\n## Dependency\nSheenBidi does not depend on any external library. It only uses standard C library headers ```stddef.h```, ```stdint.h``` and ```stdlib.h```.\n\n## Configuration\nThe configuration options are available in `Headers/SBConfig.h`.\n\n* ```SB_CONFIG_LOG``` logs every activity performed in order to apply bidirectional algorithm.\n* ```SB_CONFIG_UNITY``` builds the library as a single module and lets the compiler make decisions to inline functions.\n\n## Compiling\nSheenBidi can be compiled with any C compiler. The best way for compiling is to add all the files in an IDE and hit build. The only thing to consider however is that if ```SB_CONFIG_UNITY``` is enabled then only ```Source/SheenBidi.c``` should be compiled.\n\n### CMake\n\nSheenBidi can also be compiled and installed with CMake:\n\n```bash\ncmake -S. -Bbuild-rel -DCMAKE_BUILD_TYPE=Release\ncmake --build build-rel -j $(getconf _NPROCESSORS_ONLN)\nsudo cmake --install build-rel\n```\n\nThe installed package can be found in other CMake projects via\n`find_package(SheenBidi)`.\n\nSheenBidi provides a single target, `SheenBidi::sheenbidi`.\nSheenBidi can also be used via `FetchContent`.\n\n### Testing with CMake\n\nIf you're working on SheenBidi itself, you can build and run the tests with:\n\n```bash\ncmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug\ncmake --build build -j $(getconf _NPROCESSORS_ONLN)\nctest --test-dir build --output-on-failure -j $(getconf _NPROCESSORS_ONLN)\n```\n\n## Example\nHere is a simple example written in C11.\n\n```c\n#include \u003cstdint.h\u003e\n#include \u003cstdio.h\u003e\n#include \u003cstring.h\u003e\n\n#include \u003cSheenBidi.h\u003e\n\nint main(int argc, const char * argv[]) {\n    /* Create code point sequence for a sample bidirectional text. */\n    const char *bidiText = \"یہ ایک )car( ہے۔\";\n    SBCodepointSequence codepointSequence = { SBStringEncodingUTF8, (void *)bidiText, strlen(bidiText) };\n\n    /* Extract the first bidirectional paragraph. */\n    SBAlgorithmRef bidiAlgorithm = SBAlgorithmCreate(\u0026codepointSequence);\n    SBParagraphRef firstParagraph = SBAlgorithmCreateParagraph(bidiAlgorithm, 0, INT32_MAX, SBLevelDefaultLTR);\n    SBUInteger paragraphLength = SBParagraphGetLength(firstParagraph);\n\n    /* Create a line consisting of whole paragraph and get its runs. */\n    SBLineRef paragraphLine = SBParagraphCreateLine(firstParagraph, 0, paragraphLength);\n    SBUInteger runCount = SBLineGetRunCount(paragraphLine);\n    const SBRun *runArray = SBLineGetRunsPtr(paragraphLine);\n\n    /* Log the details of each run in the line. */\n    for (SBUInteger i = 0; i \u003c runCount; i++) {\n        printf(\"Run Offset: %ld\\n\", (long)runArray[i].offset);\n        printf(\"Run Length: %ld\\n\", (long)runArray[i].length);\n        printf(\"Run Level: %ld\\n\\n\", (long)runArray[i].level);\n    }\n\n    /* Create a mirror locator and load the line in it. */\n    SBMirrorLocatorRef mirrorLocator = SBMirrorLocatorCreate();\n    SBMirrorLocatorLoadLine(mirrorLocator, paragraphLine, (void *)bidiText);\n    const SBMirrorAgent *mirrorAgent = SBMirrorLocatorGetAgent(mirrorLocator);\n\n    /* Log the details of each mirror in the line. */\n    while (SBMirrorLocatorMoveNext(mirrorLocator)) {\n        printf(\"Mirror Index: %ld\\n\", (long)mirrorAgent-\u003eindex);\n        printf(\"Actual Code Point: %ld\\n\", (long)mirrorAgent-\u003ecodepoint);\n        printf(\"Mirrored Code Point: %ld\\n\\n\", (long)mirrorAgent-\u003emirror);\n    }\n\n    /* Release all objects. */\n    SBMirrorLocatorRelease(mirrorLocator);\n    SBLineRelease(paragraphLine);\n    SBParagraphRelease(firstParagraph);\n    SBAlgorithmRelease(bidiAlgorithm);\n\n    return 0;\n}\n```\n\n## License\n```\nCopyright (C) 2014-2022 Muhammad Tayyab Akram\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n  http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTehreer%2FSheenBidi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTehreer%2FSheenBidi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTehreer%2FSheenBidi/lists"}