Pelles C forum

C language => Windows questions => Topic started by: bitcoin on November 27, 2021, 01:51:36 pm

Title: How to use unicode strings in edit dialog?
Post by: bitcoin 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?

Title: Re: How to use unicode strings in edit dialog?
Post by: TimoVJL on November 28, 2021, 09:32:03 am
Have you defined UNICODE in project
Title: Re: How to use unicode strings in edit dialog?
Post by: John Z 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)
Title: Re: How to use unicode strings in edit dialog?
Post by: bitcoin 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)
Title: Re: How to use unicode strings in edit dialog?
Post by: TimoVJL on November 30, 2021, 10:32:15 am
Project options -> Compiler -> Preprocessor -> Define symbols

pocc -DUNICODE
Title: Re: How to use unicode strings in edit dialog?
Post by: John Z 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
Title: Re: How to use unicode strings in edit dialog?
Post by: bitcoin 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!
Title: Re: How to use unicode strings in edit dialog?
Post by: John Z 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

Title: Re: How to use unicode strings in edit dialog?
Post by: TimoVJL 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.