Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect behaviour of api #1494

Closed
demhademha opened this issue Dec 11, 2023 · 1 comment
Closed

incorrect behaviour of api #1494

demhademha opened this issue Dec 11, 2023 · 1 comment
Labels
question A question

Comments

@demhademha
Copy link

the following code allows a user to enter text, which should be presented as braille, using Liblouis dot format. This does not occur however:


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <liblouis/liblouis.h>

#define BUF_SIZE 1024

int main() {
    const char* table = "en-ueb-g2.ctb"; // Replace this with the desired Braille table

    char input[BUF_SIZE];

    printf("Enter a string: ");
    fgets(input, BUF_SIZE, stdin);

    // Remove newline character at the end of input
    input[strcspn(input, "\n")] = 0;

    // Allocate buffer for the translated string
    widechar* output = (widechar*)malloc(BUF_SIZE * sizeof(widechar));

    // Initialize input and output length variables
    int inlen = strlen(input);
    int outlen = BUF_SIZE;

    // Translate the input string to Braille
    int result = lou_translateString(table, (const widechar*)input, &inlen, output, &outlen, NULL, NULL,68);

    if (result >= 0) {
        printf("Braille representation: ");
        for (int i = 0; i < outlen; i++) {
            printf("%u ", output[i]); // Print Braille characters
        }
        printf("\n");
    } else {
        printf("Translation failed\n");
    }

    // Free allocated memory for output
    lou_free();

    return 0;
}

@bertfrees bertfrees added the question A question label Dec 11, 2023
@bertfrees
Copy link
Member

Where did you find this information? This is not how the API works. Your input variable should be a widechar*, which is a UCS-2 or UCS-4 encoded string, depending on how Liblouis was compiled. You are casting a char* to a widechar*, that seems fishy.

@bertfrees bertfrees added needs news Update to NEWS file needed and removed needs news Update to NEWS file needed labels May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question
Projects
None yet
Development

No branches or pull requests

2 participants