How to use unicode strings in edit dialog?

Started by bitcoin, November 27, 2021, 01:51:36 PM

Previous topic - Next topic

bitcoin

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?


TimoVJL

May the source be with you

John Z

#2
Quote from: 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?

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)

bitcoin

Quote from: TimoVJL on November 28, 2021, 09:32:03 AM
Have you defined UNICODE in project
how to do this? Can't find in help.

Quote from: John Z on November 28, 2021, 12:06:42 PM
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)

TimoVJL

Project options -> Compiler -> Preprocessor -> Define symbols

pocc -DUNICODE
May the source be with you

John Z

#5
Quote from: bitcoin on November 29, 2021, 11:27:03 PM
Quote from: TimoVJL on November 28, 2021, 09:32:03 AM
Have you defined UNICODE in project
how to do this? Can't find in help.

If using the Pelles C UI IDE then

#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

bitcoin

Quote from: TimoVJL on November 30, 2021, 10:32:15 AM
Project options -> Compiler -> Preprocessor -> Define symbols

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


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

John Z

Quote from: bitcoin on November 30, 2021, 11:32:06 AM
Quote from: TimoVJL on November 30, 2021, 10:32:15 AM
Project options -> Compiler -> Preprocessor -> Define symbols

pocc -DUNICODE
Quotefatal 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


TimoVJL

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