I would like to make my C program print signs from other charset, not from the ASCII table as it is default. For example, I want to print chars in range [200,250] from the ISO-8859 charset. Is it possible at all? How the compiler should be set? Thanks in advance for help!
Is it possible to change charset encoding in C?
1.1k views Asked by ChillyWilly88 At
2
There are 2 answers
5
David Ranieri
On
Setting you locales and using wide characters:
#include <stdio.h>
#include <wchar.h>
#include <locale.h>
int main(void)
{
setlocale(LC_CTYPE, "");
for (wchar_t c = 200; c < 250; c++)
{
wprintf(L"%lc", c);
}
wprintf(L"\n");
return 0;
}
Output:
ÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øù
Related Questions in C
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in ENCODING
- When sanitize/encode while implementing tags system like on SO
- Generating synthetic data for .ORC file in python
- WebClient.UploadData is returning control characters after non-ascii characters
- How to switch encoding of LibreOffice strings in Java UNO API?
- Userform to answer original userform
- Encoding problem on MySQL: Why some non-ASCII characters get encoded on more than 4 bytes?
- What encoding does the 'text' response type option in HttpClient use?
- Issue downloading audio with ytdlp on a raspberry pi
- KeyError: "['Building Age', 'Floor', 'Number of Floors'] not in index"
- FFMPEG fast quality video encoding without quality loss & less storage occupancy (maybe using GPU)
- Encoding attributes in an Genetic Algorithm
- React - MP4 - The file was loaded in a wrong encoding - 'UTF-8'
- How to re-encode an audio to match another one, to avoid re-encoding the whole audio
- Sqlalchemy - PostgreSQL - UnicodeDecodeError
- Calculate difference in encoding WITHOUT actually writing to a file?
Related Questions in ASCII
- Dart: how to convert Hex String to Ascii string
- Reading character entity reference tag content in C++
- Convet byte[] in ASCII
- Visual C++ - how can I turn a unicode character into char or string?
- Saving a numpy array in ascii format
- Ascii doc syntaxes not provide consistent output & not working as expected
- Why does $'\141' convert to ASCII 'a' as expected, but constructing the same string doesn't convert?
- How would one render a QR code in the logs of a GitHub workflow?
- Is there a recommended way to plot data using ascii symbols?
- Converting ASCII to Unary
- Doesnt \n remain in the buffer?
- Are we able to specify the Answer's XML encoding? Or does Mturk control that?
- C ASCII to Hex (atoh) Function
- ASCII to decimal conversion
- Bcrypt Password Truncation issue solution or Hashing Long Passwords with Bcrypt in Java?
Related Questions in ISO-8859-2
- PHP read a line from a csv file return wrong in charset
- HTML ISO-8859-2 form encoding
- How to convert diacritical words to text in browser using C# .NET (UTF-8/Unicode)?
- BOM (byte order mark) of ISO Encoding
- Generate UTF-8 character list
- Character encoding mystery ( working flawlessly for me, but unfortunately not for all )
- Is it possible to change charset encoding in C?
- How to pass correctly latin chars like "ś" in jmeter login post request
- Informix JDBC ISO-8859-2 encoding problem
- Use of ISO-8859-2 encoding in PHPMailer
- Get raw binary data from XML attribute's value parsed with SAX in Java
- How can I use uconv to convert utf-8 with latin1 and latin2 special characters to latin1 using the transliterate feature?
- MYSQL Column Collations: Difference between latin1 and latin2
- Node.js convert string from ISO-8859-2 to UTF-8
- DB2 Code conversion from Unicode to ISO8859-2 and back
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
In fact C functions don't care about encoding, so if you have a code like that:
It will print out 'germanzied' "Hello World" in exactly the encoding of the C source file, indepedent from system settings etc. The same is true of course if you print strings that you read from a file. If you want to reencode strings (say from UTF-8 to ISO-8859) you have to do t manually or search for an appropriate library