Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6734885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:56:32+00:00 2026-05-26T10:56:32+00:00

Can anyone Provide a Simple Example to Read and Write in the Unicode File

  • 0

Can anyone Provide a Simple Example to Read and Write in the Unicode File a Unicode Character ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:56:33+00:00Added an answer on May 26, 2026 at 10:56 am

    On linux I use the iconv (link) library which is very standard. An overly simple program is:

    #include <stdio.h>
    #include <stdlib.h>
    #include <iconv.h>
    
    #define BUF_SZ  1024
    int main( int argc, char* argv[] )
    {
        char bin[BUF_SZ];
        char bout[BUF_SZ];
        char* inp;
        char* outp;
        ssize_t bytes_in;
        size_t bytes_out;
        size_t conv_res;
        if( argc != 3 )
        {
            fprintf( stderr, "usage: convert from to\n" );
            return 1;
        }
        iconv_t conv = iconv_open( argv[2], argv[1] );
        if( conv == (iconv_t)(-1) )
        {
            fprintf( stderr, "Cannot conver from %s to %s\n",  argv[1], argv[2] );
            return 1;
        }
    
        bytes_in = read( 0, bin, BUF_SZ );
        {
            bytes_out = BUF_SZ;
            inp = bin;
            outp = bout;
            conv_res = iconv( conv, &inp, &bytes_in, &outp, &bytes_out );
            if( conv_res >= 0 )
            {
                write( 1, bout, (size_t)(BUF_SZ) - bytes_out );
            }
        }
        iconv_close( conv );
        return 0;
    }
    

    This is overly simple to demonstrate the conversion. In the real world you would normally have two nested loops:

    • One reading input, so handle when its more than BUF_SZ
    • One converting input to output. Remember if you’re converting from ascii to UTF-32LE you will end up with each iunput byte being 4 bytes of output. So the inner loop would handle this by examining conv_res and then checking errno.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone provide just a simple example of how to use wxSockets write, because
Hopefully this is a simple one, but can anyone provide some simple c# code
Can anyone provide a clear explanation / example of what these functions do, and
Can anyone provide me with a hello world example for a major mode in
Can anyone provide me an example of how to use WM_CLOSE to close a
What are the benefits/advantages of using delegates? Can anyone provide any simple examples?
Can anyone provide me with a web-link which describes attribute-based simple one-to-many mapping very
Can anyone provide some real examples as to how best to keep script files
Can anyone provide some pseudo code for a roulette selection function? How would I
Can anyone provide me with a link to good article about using Firebird.NET with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.