From 17693cdfabafd71954721ab7a7c060efe2f08d91 Mon Sep 17 00:00:00 2001 From: Clecio Jung Date: Mon, 17 Apr 2023 18:34:38 -0300 Subject: Removing a test file commited by mistake --- ini_file.c | 22 ++++++++++++ main.c | 114 ------------------------------------------------------------- 2 files changed, 22 insertions(+), 114 deletions(-) delete mode 100644 main.c diff --git a/ini_file.c b/ini_file.c index 0f8adf5..e2bce71 100644 --- a/ini_file.c +++ b/ini_file.c @@ -1,3 +1,25 @@ +/* MIT License + * + * Copyright (c) 2023 CLECIO JUNG + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ /*------------------------------------------------------------------------------ * SOURCE diff --git a/main.c b/main.c deleted file mode 100644 index f2a63c6..0000000 --- a/main.c +++ /dev/null @@ -1,114 +0,0 @@ -#if 0 -#include -#include -#include - -size_t strlen_utf8(const char *str) { - size_t len = 0; - for (; *str; str++) { - if ((*str & 0xc0) != 0x80) { - len++; - } - } - return len; -} - -int main(void) { - // Read a encoded string from a file - FILE *fp = fopen("text.txt", "r,ccs=utf16le"); - if (fp == NULL) { - perror("Error opening file"); - return EXIT_FAILURE; - } - char str[4096]; - if (fgets(str, sizeof(str), fp) == NULL) { - perror("Error in gets"); - //return EXIT_FAILURE; - } - printf("strlen=%ld, strlen_utf8=%ld, str=%s\n", strlen(str), strlen_utf8(str), str); - return EXIT_SUCCESS; -} -#elif 1 - -#include -#include -#include -#include -#include - -int main() { - // Set locale to support UTF-16LE encoding - char *local = setlocale(LC_ALL, "en_US.UTF-16"); - if (local == NULL) { - perror("setlocale"); - return EXIT_FAILURE; - } - printf("locale: %s\n", local); - - FILE* file = fopen("text.txt", "rb"); - if (file == NULL) { - perror("fopen"); - return EXIT_FAILURE; - } - fseek(file, 0, SEEK_END); - int file_size = ftell(file); - fseek(file, 0, SEEK_SET); - - // Allocate buffer for file contents - wchar_t* file_contents = malloc(file_size); - if (file_contents == NULL) { - perror("malloc"); - return EXIT_FAILURE; - } - - printf("file_size=%d\n", file_size); - // Read file contents - size_t bytes_read = fread(file_contents, 1, file_size, file); - printf("bytes_read=%ld\n", bytes_read); - if (bytes_read != file_size) { - printf("Error: Failed to read file\n"); - return 1; - } - - // Close file - fclose(file); - - // Convert wide string to multibyte string in UTF-8 encoding - int buffer_size = wcstombs(NULL, file_contents, 0) + 1; - printf("buffer_size=%d\n", buffer_size); - char* buffer = malloc(buffer_size); - - // Print multibyte string to console - printf("%s", buffer); - - // Free buffers - free(file_contents); - free(buffer); - - return 0; -} - -#else - -/* wcstombs example */ -#include /* printf */ -#include /* wcstombs, wchar_t(C) */ -#include - -int main() { - const wchar_t str[] = L"ç ~^ âãáà êẽéè õôóò"; - char buffer[32]; - int ret; - - setlocale(LC_ALL, ""); - - printf ("wchar_t string: %ls \n",str); - - ret = wcstombs ( buffer, str, sizeof(buffer) ); - if (ret==32) buffer[31]='\0'; - if (ret) printf ("multibyte string: %s \n",buffer); - - return 0; -} - -#endif \ No newline at end of file -- cgit v1.2.3