Author Topic: Unicode converting error  (Read 12055 times)

Arhon

  • Guest
Unicode converting error
« on: May 26, 2008, 09:11:12 pm »
wchar_t ws[] = L"english language";    // its OK
wchar_t ws[] = L"other language";       // compile error - converting to execution character set: Illegal byte sequence|

as be? what to do?

my code page cp1251 (russian) Windows Vista
Code::Blocks 8.02, settings default

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Unicode converting error
« Reply #1 on: May 26, 2008, 10:08:25 pm »
as be? what to do?
Nice to know about OS, compiler, version... etc... probably steps to reproduce /  sample project... What's the relation to C::B? We won't just solve compiler errors here. Currently you don't provide enough information!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Ramazan Kartal

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Unicode converting error
« Reply #2 on: May 26, 2008, 10:57:09 pm »
Hi,

I am not sure about your problem, but I use "-finput-charset=latin5" to get rid of this error. You may use a similar "-finput-charset=cyrillic" in "Compiler Settings/Other Options". I hope this helps.

Regards,
Ramazan Kartal

Arhon

  • Guest
Re: Unicode converting error
« Reply #3 on: May 26, 2008, 11:50:23 pm »
Thank you, Ramazan Kartal.
-finput-charset=windows-1251 - good

As be if using several language in code ?.

For MortenMacFly.

// main.c

#define UNICODE
#include <windows.h>
//---------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    wchar_t capt[] = L"Sample text";
    wchar_t text_en[] = L"Hello";
    wchar_t text_ru[] = L"Привет";  // (russian string) error - converting to execution character set: Illegal byte sequence

    MessageBoxExW(NULL, text_en, capt, MB_OK, 0);
    MessageBoxExW(NULL, text_ru, capt, MB_OK, 0);

    return 0;
}
//---------------------------------------------------------------------------
/*
    OS - Windows Vista Ultimate x64 version 6.0.6000 (build 6000), russian (cp1251)
    IDE - Code::Blocks 8.02 Build: Feb 27 2008, 20:59:09 (distrib: "codeblocks-8.02mingw-setup.exe", download: 16.03.2008)
    Selected compiler - GNU GCC compiler

    Project steps:
    File->New->Project->Win32GUI->FrameBased
    Delete default code
    Insert this code (this code as sample)
    Build!

    Build log:
    -------------- Build: Release in proba ---------------
    mingw32-gcc.exe -Wall  -O2     -c D:\Projects\CodeBlocks\proba\main.c -o obj\Release\main.o
    D:\Projects\CodeBlocks\proba\main.c:10:25: converting to execution character set: Illegal byte sequence
    Process terminated with status 1 (0 minutes, 0 seconds)
    1 errors, 0 warnings

    All !
    Enough information ?
*/

    (Sorry, i bad speek english)


Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Unicode converting error
« Reply #4 on: May 27, 2008, 02:35:29 am »
-finput-charset=windows-1251 - good

As be if using several language in code ?.

Your code is compiled without any problem when English characters are used, but fails when Russian characters are used. Make sure that the GCC version you are using is linked against iconv. Otherwise the Unicode conversion may not work.
Be a part of the solution, not a part of the problem.