{"id":21708254,"url":"https://github.com/yurtrimu/binaryconversion","last_synced_at":"2025-10-30T21:03:47.650Z","repository":{"id":211647650,"uuid":"729650397","full_name":"yurtrimu/BinaryConversion","owner":"yurtrimu","description":"An open library which is mainly used to convert and revert Strings and Integers to Binary","archived":false,"fork":false,"pushed_at":"2023-12-10T00:51:19.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-08T11:04:17.508Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yurtrimu.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}},"created_at":"2023-12-09T22:36:20.000Z","updated_at":"2024-07-17T23:07:37.000Z","dependencies_parsed_at":"2024-11-25T22:37:22.468Z","dependency_job_id":null,"html_url":"https://github.com/yurtrimu/BinaryConversion","commit_stats":null,"previous_names":["yurtrimu/binaryconversionlibrary","yurtrimu/binaryconversion"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yurtrimu/BinaryConversion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yurtrimu%2FBinaryConversion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yurtrimu%2FBinaryConversion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yurtrimu%2FBinaryConversion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yurtrimu%2FBinaryConversion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yurtrimu","download_url":"https://codeload.github.com/yurtrimu/BinaryConversion/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yurtrimu%2FBinaryConversion/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265436550,"owners_count":23764967,"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":[],"created_at":"2024-11-25T22:22:23.668Z","updated_at":"2025-10-30T21:03:47.640Z","avatar_url":"https://github.com/yurtrimu.png","language":"C","readme":"# BinaryConversion Library\nAn open, two-file library mainly used to convert and revert strings and integers to binary \n\nThe current functions are\n```c\nvoid PrintArray(int *arr, size_t array_size);\nvoid PrintBinaryString(int **arr, size_t strlen, size_t char_size);\nvoid ReverseArray(int *arr, int *dest, size_t dest_size);\nint *TrimBinary(int *b, size_t binary_size, size_t *return_size);\nint IntFromBinary(int *b, size_t binary_size);\nvoid IntToBinary(int n, int *dest, size_t dest_size);\nchar *IntToString(int *arr, size_t array_size);\nvoid StringToInt(char *str, size_t strlen, int *dest, size_t dest_size);\nvoid StringToBinary(char *str, size_t strlen, int **dest, size_t char_size);\nchar *StringFromBinary(int **binary, size_t binary_size, size_t char_size);\n```\n\n## Examples \u0026\u0026 Documentation\n\n\n### PrintArray\n```c\n#include \"BinaryConversion.h\"\n\n#define ARRAY_SIZE 8\n\nvoid main() {\n    \n    int Array[ARRAY_SIZE] = { 3, 1, 0, 0, 0, 0, 6, 9 };\n    PrintArray(Array, ARRAY_SIZE); // Output: \"[3,1,0,0,0,0,6,9]\"\n}\n```\n\n### PrintBinaryString\n```c\n#include \"BinaryConversion.h\"\n\n#define ARRAY_SIZE 12\n#define CHAR_BIT_SIZE 8\n\nvoid main() {\n    \n    char Text[ARRAY_SIZE] = \"Hello World!\";\n\n    int **binary = NULL;\n    binary = (int **)calloc(ARRAY_SIZE, sizeof(int));  // Allocate memory to the 'binary' variable's first pointer\n\n    StringToBinary(\u0026Text, ARRAY_SIZE, binary, CHAR_BIT_SIZE); // Converts string to Binary\n    PrintBinaryString(binary, ARRAY_SIZE, CHAR_BIT_SIZE); // Output: \"[01001000,01100101,01101100,01101100,01101111,00100000,01010111,01101111,01110010,01101100,01100100,00100001]\"\n}\n```\n\n### ReverseArray\n```c\n#include \"BinaryConversion.h\"\n\n#define ARRAY_SIZE 8\n\nvoid main() {\n    \n    int Array[ARRAY_SIZE] = {0, 0, 0, 0, 0, 0, 0, 1};\n\n    PrintArray(Array, ARRAY_SIZE); // Output: \"[0, 0, 0, 0, 0, 0, 0, 1]\"\n\n    ReverseArray(\u0026Array, \u0026Array, ARRAY_SIZE); // Reverses the int array\"\n\n    PrintArray(Array, ARRAY_SIZE);// Output: \"[1, 0, 0, 0, 0, 0, 0, 0]\"\n}\n```\n\n### TrimBinary\n```c\n#include \"BinaryConversion.h\"\n\n#define ARRAY_SIZE 8\n\nvoid main() {\n    \n    int Array[ARRAY_SIZE] = {0, 0, 0, 0, 0, 0, 1, 0};\n\n    PrintArray(Array, ARRAY_SIZE); // Output: \"[0, 0, 0, 0, 0, 0, 1, 0]\"\n\n    int return_size = 0; // Return size\n    int *TrimmedArray = TrimBinary(\u0026Array, ARRAY_SIZE, \u0026return_size); // Trims the unnecessary zeros in the binary\"\n\n    PrintArray(TrimmedArray, return_size);// Output: \"[1, 0]\"\n}\n```\n\n### IntFromBinary\n```c\n#include \"BinaryConversion.h\"\n\n#define ARRAY_SIZE 8\n\nvoid main() {\n    \n    int BinaryArray[ARRAY_SIZE] = {0, 0, 0, 0, 0, 0, 1, 0};\n\n    PrintArray(BinaryArray, ARRAY_SIZE); // Output: \"[0, 0, 0, 0, 0, 0, 1, 0]\"\n\n    int ConvertedBinary = IntFromBinary(BinaryArray, ARRAY_SIZE); // '00000001' as binary is '2' as decimal\n\n    printf(\"%d\\n\", ConvertedBinary); // Output: \"2\"\n}\n```\n\n### IntToBinary\n```c\n#include \"BinaryConversion.h\"\n\n#define ARRAY_SIZE 8\n\nvoid main() {\n\n    int Decimal = 2;\n\n    int *ConvertedDecimal = (int *)calloc(ARRAY_SIZE, sizeof(int)); // Allocate memory to the pointer\n    IntToBinary(Decimal, ConvertedDecimal, ARRAY_SIZE); // '2' as decimal is '00000001' as binary\n\n    PrintArray(ConvertedDecimal, ARRAY_SIZE); // Output: \"[0, 0, 0, 0, 0, 0, 1, 0]\"\n}\n```\n\n### IntToString\n```c\n#include \"BinaryConversion.h\"\n\n#define ARRAY_SIZE 12\n\nvoid main() {\n\n    int ASCIIArray[12] = {72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33};\n    char *ConvertedASCII = StringFromInt(ASCIIArray, ARRAY_SIZE); // Converts the ASCII Array to string\n\n    printf(\"%s\\n\", ConvertedASCII); // Output: \"Hello World!\"\n}\n```\n\n### StringToInt\n```c\n#include \"BinaryConversion.h\"\n\n#define ARRAY_SIZE 13\n\nvoid main() {\n\n    char Text[13] = \"Hello World!\";\n\n    int *ASCIIArray = (int *)calloc(ARRAY_SIZE, sizeof(int)); // Allocate memory to the pointer\n    StringToInt(\u0026Text, ARRAY_SIZE, ASCIIArray, ARRAY_SIZE); // Converts string to ASCII Array\n\n    PrintArray(ASCIIArray, ARRAY_SIZE); // Output: \"[72,101,108,108,111,32,87,111,114,108,100,33]\"\n}\n```\n\n### StringToBinary\n```c\n#include \"BinaryConversion.h\"\n\n#define ARRAY_SIZE 12\n#define CHAR_BIT_SIZE 8\n\nvoid main() {\n    \n    char Text[ARRAY_SIZE] = \"Hello World!\";\n\n    int **binary = NULL;\n    binary = (int **)calloc(ARRAY_SIZE, sizeof(int));  // Allocate memory to the 'binary' variable's first pointer\n\n    StringToBinary(\u0026Text, ARRAY_SIZE, binary, CHAR_BIT_SIZE); // Convert string to Binary\n    PrintBinaryString(binary, ARRAY_SIZE, CHAR_BIT_SIZE); // Output: \"[01001000,01100101,01101100,01101100,01101111,00100000,01010111,01101111,01110010,01101100,01100100,00100001]\"\n}\n```\n\n### StringFromBinary\n```c\n#include \"BinaryConversion.h\"\n\n#define ARRAY_SIZE 12\n#define CHAR_BIT_SIZE 8\n\nvoid main() {\n    \n    char Text[ARRAY_SIZE] = \"Hello World!\";\n\n    int **binary = NULL;\n    binary = (int **)calloc(ARRAY_SIZE, sizeof(int));  // Allocate memory to the 'binary' variable's first pointer\n\n    StringToBinary(\u0026Text, ARRAY_SIZE, binary, CHAR_BIT_SIZE); // Converts string to Binary\n    PrintBinaryString(binary, ARRAY_SIZE, CHAR_BIT_SIZE); // Output: \"[01001000,01100101,01101100,01101100,01101111,00100000,01010111,01101111,01110010,01101100,01100100,00100001]\"\n\n    char *ConvertedText = StringFromBinary(binary, ARRAY_SIZE, CHAR_BIT_SIZE); // Convert Binary to String\n    printf(\"%s\\n\", ConvertedText); // Output: \"Hello World!\"\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyurtrimu%2Fbinaryconversion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyurtrimu%2Fbinaryconversion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyurtrimu%2Fbinaryconversion/lists"}