Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Russian character
Message
De
22/03/2021 10:50:44
 
 
À
21/03/2021 23:32:20
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Divers
Thread ID:
01679204
Message ID:
01679224
Vues:
42
>My client wants to input the Russian characters, such as БПЭ3-1003ПТМ
>but when I copy & paste, it becomes ???3-1003???
>is that a way to accept that characters?

Jerry, you may use VFP2C32 and some additional Win32API declarations to get the clipboard Unicode data translated to a specific Windows code page.

Keep in mind that the result will be in ANSI, meaning that to be properly stored and reused you'll need to keep track of the conversion settings (Listing 1).

Also, you'll have to address the possibility of the clipboard holding other kind of Unicode data, not only Cyrillic. Instead of asking VFP2C32 to perform the translation, you may ask it just to read it back to you, as a regular VFP string, and let STRCONV() execute the translation and eventually store your data as Unicode, UTF-8 or not (Listing 2).

Listing 1.
SET LIBRARY TO LOCFILE("VFP2C32.FLL")

* Clipboard operations
DECLARE LONG OpenClipboard IN WIN32API LONG HWND
DECLARE LONG CloseClipboard IN WIN32API
DECLARE LONG GetClipboardData IN WIN32API Long ClipBoardDataFormat

OpenClipboard(_Screen.HWnd)

LOCAL AnsiString AS String

#DEFINE UNICODE_CLIPBOARD_DATA_FORMAT 13
#DEFINE CYRILLIC_WINDOWS_CODE_PAGE 1251
#DEFINE CYRILLIC_FONT_CHARSET 204
#DEFINE MAX_BUFFER 256

* get an ANSI version of the Unicode content of the clipboard
m.AnsiString = ReadWCharArray(GetClipboardData(UNICODE_CLIPBOARD_DATA_FORMAT), ;
    MAX_BUFFER, ;
    CYRILLIC_WINDOWS_CODE_PAGE)

CloseClipBoard()

? m.AnsiString FONT "Arial", 11, CYRILLIC_FONT_CHARSET
Listing 2.
DECLARE LONG OpenClipboard IN WIN32API LONG HWND
DECLARE LONG CloseClipboard IN WIN32API
DECLARE LONG GetClipboardData IN WIN32API Long ClipBoardDataFormat

SET LIBRARY TO LOCFILE("VFP2C32.FLL")

OpenClipboard(_Screen.HWnd)

LOCAL AnsiString AS String
LOCAL UnicodeString AS String

#DEFINE UNICODE_CLIPBOARD_DATA_FORMAT 13
#DEFINE CYRILLIC_WINDOWS_CODE_PAGE 1251
#DEFINE CYRILLIC_FONT_CHARSET 204
#DEFINE MAX_BUFFER 256

m.UnicodeString = ReadBytes(GetClipboardData(UNICODE_CLIPBOARD_DATA_FORMAT), MAX_BUFFER * 2)

CloseClipBoard()

* you may store the Unicode in your system as binary data
m.AnsiString = STRCONV(m.UnicodeString, 6, CYRILLIC_WINDOWS_CODE_PAGE, 1)

? LEFT(m.AnsiString, AT(CHR(0), m.AnsiString + CHR(0)) - 1) FONT "Arial", 11, CYRILLIC_FONT_CHARSET
----------------------------------
António Tavares Lopes
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform