NO

Author Topic: How to use unicode strings in edit dialog?  (Read 1027 times)

Offline bitcoin

  • Member
  • *
  • Posts: 152
How to use unicode strings in edit dialog?
« on: November 27, 2021, 01:51:36 pm »
Hello,
I have some dialog with edit control, but I can't copy-paste symbols like ☣ - it transforms to ?

Project-properties-encoding == utf-16 . What can I do?


Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1974
Re: How to use unicode strings in edit dialog?
« Reply #1 on: November 28, 2021, 09:32:03 am »
Have you defined UNICODE in project
May the source be with you

Offline John Z

  • Member
  • *
  • Posts: 433
Re: How to use unicode strings in edit dialog?
« Reply #2 on: November 28, 2021, 12:06:42 pm »
Hello,
I have some dialog with edit control, but I can't copy-paste symbols like ☣ - it transforms to ?

Project-properties-encoding == utf-16 . What can I do?

It is not very simple to do.  How the C source code page is encoded itself really has nothing to do with it unless the source module is actually loading or storing Unicode characters for example into an array of characters.  So a project could have source files in ANSI, UTF-8, UTF-16 all in the same build.  Micro$oft windows controls all use UTF-16 internally.  Are you sure you know you are pasting a Unicode character?  It might be UTF-8 for example.

TimoVJL points you to how to start . . .a lot of study after that. 

John Z

Try copying smile from here and paste into your control:
https://de.wikipedia.org/wiki/Unicodeblock_Smileys

 😀

Copy the face 😇 not the code U+1F607 (128519)
« Last Edit: November 28, 2021, 02:45:54 pm by John Z »

Offline bitcoin

  • Member
  • *
  • Posts: 152
Re: How to use unicode strings in edit dialog?
« Reply #3 on: November 29, 2021, 11:27:03 pm »
Have you defined UNICODE in project
how to do this? Can't find in help.

Are you sure you know you are pasting a Unicode character?  It might be UTF-8 for example.

May be.. But Visual Studio dialogs accept such symbols (project-general-character set)

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1974
Re: How to use unicode strings in edit dialog?
« Reply #4 on: November 30, 2021, 10:32:15 am »
Project options -> Compiler -> Preprocessor -> Define symbols

pocc -DUNICODE
May the source be with you

Offline John Z

  • Member
  • *
  • Posts: 433
Re: How to use unicode strings in edit dialog?
« Reply #5 on: November 30, 2021, 11:15:34 am »
Have you defined UNICODE in project
how to do this? Can't find in help.

If using the Pelles C UI IDE then
 
Code: [Select]
#define WIN32_LEAN_AND_MEAN
/* #define NOCRYPT */
/* #define NOSERVICE */
/* #define NOMCX */
/* #define NOIME */
#define UNICODE
#define _UNICODE

#include <windows.h>
#include <windowsx.h>
is an example of where you might place the UNICODE defines.  Be prepared to learn about
 MultiByteToWideChar  and
 WideCharToMultiByte as well.

In Pelles C Help search for _UNICODE click on the topic '<tchar.h> include files' you will find more information on using UNICODE

Also look at 'Program startup: the main and WinMain functions' in Pelles Help.


John Z
« Last Edit: November 30, 2021, 11:21:36 am by John Z »

Offline bitcoin

  • Member
  • *
  • Posts: 152
Re: How to use unicode strings in edit dialog?
« Reply #6 on: November 30, 2021, 11:32:06 am »
Project options -> Compiler -> Preprocessor -> Define symbols

pocc -DUNICODE
Quote
fatal error #1051: Invalid -D or -U argument: -DUNICODE.


Quote from: John Z
#define UNICODE
#define _UNICODE
This works!

Offline John Z

  • Member
  • *
  • Posts: 433
Re: How to use unicode strings in edit dialog?
« Reply #7 on: November 30, 2021, 12:57:11 pm »
Project options -> Compiler -> Preprocessor -> Define symbols

pocc -DUNICODE
Quote
fatal error #1051: Invalid -D or -U argument: -DUNICODE.
TimoVJL was mentioning two different methods: A) where in the UI IDE and B) an example of compiling from the command line and passing a command line option.  See attachments below.

I found doing UNICODE is hard work, but worth it eventually. :)

John Z


Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1974
Re: How to use unicode strings in edit dialog?
« Reply #8 on: November 30, 2021, 02:38:57 pm »
Pelles C Add-Ins use UNICODE.
All sources, that needs UNICODE version might just use #define UNICODE and then readers know that too.

MS Visual Studio hides too many things and it's slow and awkward, needs very fast PC.

May the source be with you