It's not very useful to paste unicode text from clipboard always with special paste.
Is there a way to detect if text in clipboard is in unicode ?
Detect unicode text in clipboard
Code: Select all
if ClipBoard.HasFormat(CF_UNICODETEXT) then ...
This doesn't work because it always has CF_UNICODETEXT even if ANSI text in clipboard.
I know it's not a problem for english characters but for national...
When someone copies text from Windows notepad (it copies in unicode) some national symbols, like russian and pastes it into RichViewEdit by default - he will get ????????????????. But when using special unicode paste - everything is ok.
I tryed to play with clipboard and found that it's always has unicode and ansi text flags together.
I know it's not a problem for english characters but for national...
When someone copies text from Windows notepad (it copies in unicode) some national symbols, like russian and pastes it into RichViewEdit by default - he will get ????????????????. But when using special unicode paste - everything is ok.
I tryed to play with clipboard and found that it's always has unicode and ansi text flags together.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
NT-based systems (including WinXP) convert CF_TEXT and CF_UNICODETEXT Clipboard formats to each other automatically.
I.e., you can copy only ANSI text, but both ANSI and Unicode texts will be available for pasting. The same happens when you copy Unicode text.
Copy-pasting is performed without any problems (and completely transparent for users) in one case: copying from Unicode application as Unicode text, and pasting in Unicode application as Unicode text. In other cases, conversion between Unicode and ANSI occurs, and the result depends on the code page (text language) used for this conversion.
By default (Ctrl+V, or calling RichViewEdit.Paste), TRichViewEdit pastes Unicode text if the current text style is Unicode, and ANSI text otherwise. So if you got different results on Paste and PasteTextW, you do not use Unicode in RichViewEdit.
What happens when you paste ANSI text: the language of the keyboard layout AT THE MOMENT OF THE TEXT COPYING is used for the conversion of Unicode to ANSI (identifier of this language is copied by Windows to the Clipboard together with the text). So, if you want to paste Russian characters in non-Unicode application, you must activate Russian keyboard layout at the moment of copying. THIS IS HOW ALL WINDOWS APPLICATIONS WORK. This rule applies not only to RichViewEdit, but to all Windows applications (again, except for the case when all copy-pasting is made via Unicode). This is not something that should be changed in RichViewEdit, any change here will be against rules how Windows applications must work.
What happens when you paste Unicode text (in non-Unicode RichViewEdit): RichViewEdit reads Unicode text string as it was copied by Notepad. When it inserts it in editor, this string is converted to ANSI. The language for the conversion is determined by the Charset of the current text style. If it is DEFAULT_CHARSET, the language for the conversion is defined in RVStyle.DefCodePage. By default, it's CP_ACP, i.e. default Windows language. What's why you can see Russian characters on Russian Windows. But on different editions of Windows, the results will be different.
I.e., you can copy only ANSI text, but both ANSI and Unicode texts will be available for pasting. The same happens when you copy Unicode text.
Copy-pasting is performed without any problems (and completely transparent for users) in one case: copying from Unicode application as Unicode text, and pasting in Unicode application as Unicode text. In other cases, conversion between Unicode and ANSI occurs, and the result depends on the code page (text language) used for this conversion.
By default (Ctrl+V, or calling RichViewEdit.Paste), TRichViewEdit pastes Unicode text if the current text style is Unicode, and ANSI text otherwise. So if you got different results on Paste and PasteTextW, you do not use Unicode in RichViewEdit.
What happens when you paste ANSI text: the language of the keyboard layout AT THE MOMENT OF THE TEXT COPYING is used for the conversion of Unicode to ANSI (identifier of this language is copied by Windows to the Clipboard together with the text). So, if you want to paste Russian characters in non-Unicode application, you must activate Russian keyboard layout at the moment of copying. THIS IS HOW ALL WINDOWS APPLICATIONS WORK. This rule applies not only to RichViewEdit, but to all Windows applications (again, except for the case when all copy-pasting is made via Unicode). This is not something that should be changed in RichViewEdit, any change here will be against rules how Windows applications must work.
What happens when you paste Unicode text (in non-Unicode RichViewEdit): RichViewEdit reads Unicode text string as it was copied by Notepad. When it inserts it in editor, this string is converted to ANSI. The language for the conversion is determined by the Charset of the current text style. If it is DEFAULT_CHARSET, the language for the conversion is defined in RVStyle.DefCodePage. By default, it's CP_ACP, i.e. default Windows language. What's why you can see Russian characters on Russian Windows. But on different editions of Windows, the results will be different.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
1) Make the editor Unicode completely: http://www.trichview.com/forums/viewtopic.php?t=70
or
2) User must switch the keyboard to Russian layout when copying Russian text
or
2) User must switch the keyboard to Russian layout when copying Russian text