How do I install language support?

I have this c code ill post below but it uses wprintf and im trying to print special characters like from other languages but it just prints a bunch of question marks. how can I add those languages to opensuse without changing defualt language?

#include <limits.h>
#include <stdio.h>
#include <wchar.h>

int
main(void) {
    wchar_t buf[2] = L" \0";

    int i = 0;

    while(i<=SHRT_MAX) {
        buf[0] = i;
        i++;
        wprintf(buf);
    }

}

IMHO you do not need language support, you need fonts installed that provide the glyphs for the characters you use.

The ?s you report (but we see nothing of what you do) seem to be the infills for absent characters.

alr so just install fonts then?

I installed a font and nothing changed could you recommend a font package that would fill some of those question marks.

If you are using KDE, the KDE Font manager will show you the glyphs which are available in a font you have installed.

1 Like

yea but i have no clue which font to install on yast that will fill in the question marks. thanks for pointing out font manager tho that’s pretty cool.

As we have no clue which characters you need, we can not advice on a font that contains them.

No font will contains all Unicode characters that are defined. When you want to have an idea about what is available, use YaST > Software > Software Management and put font in the Search field.

I, e.g. once wanted to have a font for the Devanagri script. The package indic-fonts contains them (and more) and after installing them I do have readable Devanagri characters in web pages.

BTW, as I hinted now for the second time, you never told us which Unicode characters you are missing. And also I doubt we have any idea if your program creates the correct UTF-8 codes for them. Thus installing fonts will only help if you do the correct programming.

1 Like

It all has nothing to do with fonts. Missing glyph is usually represented as empty rectangle or rectangle with hex code depending on used toolkit.

All wide character functions work according to the current locale. Every program starts with the default POSIX (a.k.a.C) locale, wprintf prints ? for wide characters that cannot be represented as strings in the default C locale. Note that it prints more than just an ASCII subset, and in principle, one could provide corresponding “translation” for every Unicode character, but I doubt mnemonic names using ASCII for foreign characters are very useful.

To convert in current locale program must set locale using setlocale (or equivalent) before using wide character functions.

P.S. and this topic is more appropriate for programming section.

1 Like

It is moved there…

ok thanks i will try.

what should the call to setlocale look like? i tried setlocale(LC_ALL, 0); but I can’t tell what its doing. I think i want to print Chinese characters and maybe arabic, honestly i want all the characters to print.

om gosh i just tried setlocale(LC_ALL, ""); and it printed other characters, woot!