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 7583401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:40:08+00:00 2026-05-30T18:40:08+00:00

In porting a big app from a Windows to Linux, I need to be

  • 0

In porting a big app from a Windows to Linux, I need to be able to convert between wide characters and multibyte characters. To do this, I have code that looks like this:

void IConv(const InType* begin, const InType* end, const char* inCode, OutType* outBegin,  OutType*& outEnd, const char* outCode)
{
    assert(end >= begin);
    assert(outEnd > outBegin);

    iconv_t cd = iconv_open(outCode, inCode);
    if (cd == reinterpret_cast<iconv_t>(-1))
        throw (InvalidLocale ());
 /* blah, blah, blah other code we never reach */
 }

That code is always throwing an exception. To debug this, I created a simpler version that uses the same parameters as the code that fails. Here’s my test code

int main( void )
{

    const char outCode[] = ""; 
    const char inCode[] = "wchar_t";

    //Using wchar_t and "" means that iconv will just use the system locale settings.
    iconv_t cd = iconv_open(outCode, inCode); 
    if (cd == reinterpret_cast<iconv_t>(-1))
    {
        printf("iconv failed to use outCode %s and inCode %s\n",outCode, inCode);
        return 1;
    }

    iconv_close(cd);
    return 0;
}

Notice that the code is pretty much the same. But in my test code I never see a failure, whereas the IConv function always fails. The locale on the system is set via the LANG env variable, which in this case is always ISO-8859-1.

So, the question is, does anyone know of any particular behavior in iconv that might present itself in a big app, but not in a simple case?
Thank you

  • 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-30T18:40:10+00:00Added an answer on May 30, 2026 at 6:40 pm

    The problem is likely that the target machine doesn’t have the appropriate iconv libraries and indexes installed. See /usr/lib[64]/gconv. The shared libraries are typically part of the glibc installation. Tools such as localedef can create them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Porting an application from C# (1.1 framework) to VB.NET (3.5 framework), and I have
Im porting a project from php to java. The project is a web-app based
We are porting our app to Delphi XE2 from Delphi 6. Problem is, the
I am porting some stuff from C# to Java and I need a class
How would I convert a byte array, Byte[] from small to big endian. I'm
I have my first app, not that big, but it is the first step.
I have a big problem, and I hope you can help me. I'm porting
I am planning to port my application from Windows to Linux, currently my application
While porting an application from Linux x86 to iOS ARM (iPhone 4), I've discovered
Good day, Stackoverflow! I have a little (big) problem with porting one of my

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.