Hello to all!
I have put data to clip board problem with russian windows 7 x64.
Google say that is microsoft problem with 1250 1251 1252 code pages
found some advice but can't understand what to do.
windows patch - bad way.
void ToClipboard(char* text)
{
if(OpenClipboard(0))
{
EmptyClipboard();
char* clip_data = (char*)(GlobalAlloc(GMEM_FIXED, MAX_PATH));
lstrcpy(clip_data, text);
SetClipboardData(CF_TEXT, (HANDLE)(clip_data));
LCID* lcid = (DWORD*)(GlobalAlloc(GMEM_FIXED, sizeof(DWORD)));
*lcid = MAKELCID(MAKELANGID(LANG_RUSSIAN, SUBLANG_NEUTRAL), SORT_DEFAULT);
SetClipboardData(CF_LOCALE, (HANDLE)(lcid));
CloseClipboard();
}
}
(http://b.radikal.ru/b07/2202/10/c3422b9ca780.png)
try to test as following.
local TestBuffer[256]:word
invoke MultiByteToWideChar,CP_ACP,0,clip_data,-1,addr TestBuffer,256
Making an UNICODE application is also one option.
GuiParas equ "Hello World", x660, y50, w400, h300, m4, b LiteBlueGreen ; position, margins, background colour
GuiMenu equ @File, &Open, &Save, -, E&xit, @Edit, Undo, Copy, Paste
include \masm32\MasmBasic\Res\MbGui.asm
GuiControl MyEdit, "edit", 'У меня проблема с "поместить данные в буфер обмена" в русской windows 7x64', font -18, bcol LiteBlueGreen
GuiControl MyStatus, "statusbar", "Use 'Copy' in the menu to copy 'русской' into the clipboard"
Event Command
Switch_ MenuID
Case_ 4 ; case Edit/Copy
.if Instr_(Win$(hMyEdit), "русской")
wSetClip$ wRec$(Left$(eax, 14))
SetStatus$ "String 'русской' copied"
.endif
Case_ 2: invoke SendMessage, hGui, WM_CLOSE, 0, 0
Endsw_
GuiEnd
great thanks.
obvious problem and no easy decision. I even don't understand essence of problem
clipboard not a memory, but a hide notebook window?
The essence of the problem is that you should use Unicode, UTF-16 and UTF-8. The old code pages are messy.
interesting the problem is to switch to RU language from ENG
shift ctrl or shit alt
(http://d.radikal.ru/d30/2202/f6/64c35d02382c.png)
deleted
LoadKeyboardLayout - must change locale of my pipe(?!)
invoke LoadKeyboardLayout,419, KLF_ACTIVATE
error
+-------------------------+-------------------------+
| SubLanguage ID | Primary Language ID |
+-------------------------+-------------------------+
15 10 9 0 bit
invoke GetKeyboardLayout,0 -> 67699721 = 100000010010000010000001001 it is english
Quote from: nidud on February 11, 2022, 10:59:29 PMThe problem is most likely that he do not have a Russian version of Windows but an English version with a language pack.
I have an Italian OS, and my code above works just fine with Russian. How many times do we have to discuss this?
Attached the Chinese version. I definitely don't have a Chinese language pack, this is just standard Windows 7.
.asc how open asc?
deleted
Quote from: bomz on February 11, 2022, 11:48:45 PM
.asc how open asc?
RichMasm (http://masm32.com/board/index.php?topic=5314.0), Wordpad, MS Word. It's a *.rtf file. Oops, I just realised it's called Chinese version but the text is Arabic - my bad :tongue:
Quote from: nidud on February 12, 2022, 12:49:44 AMNot sure what the angle is here and why you insist on promoting this bullshit (you get paid for this?). Russians should use a Russian version of Windows for the same reason you use an Italian version. The Windows API's wont work without language support as it forces the use of Unicode.
You are truly obsessed with this weird Norwegian point of view. Get over it, Utf-8 and Utf-16 have been around for a really long time.
deleted
This is google translate.
This is a test of English to Russian text done in Google translation.
Это тест англо-русского текста, выполненный в переводе Google.
I could paste it directly into my editor but if you save it as text, reopening it produce ?????????? text. It needs a UNICODE editor. Tested in the UNICODE editor it displays correctly.
deleted
Nidud, I am so sorry that your tools don't allow to work with all languages supported by Windows :tongue:
(http://www.jj2007.eu/pics/RussianOnItalianOS.png)
(http://www.jj2007.eu/pics/ChineseOnItalianOS.png)
Thanks. Why this don't work?
invoke LoadKeyboardLayout,0419h, KLF_ACTIVATE
http://d.radikal.ru/d34/2202/dd/bc95aced2e17.jpg
http://d.radikal.ru/d17/2202/11/ab7ada8b1edf.jpg
http://a.radikal.ru/a33/2202/87/64ad05119bf2.jpg
invoke ActivateKeyboardLayout,HKL_NEXT,0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
invoke ActivateKeyboardLayout,0419h,0 - RUS
invoke ActivateKeyboardLayout,0409h,0 - ENG
Win32 have function MultiByteToWideChar(CP_UTF8, 0, ... and WideCharToMultiByte(CP_UTF8, 0, .. for UTF-8 strings.
Web pages are mostly UTF-8 and also MS help files.
EDIT:
The sad history of Unicode printf-style format specifiers in Visual C++ (https://devblogs.microsoft.com/oldnewthing/20190830-00/?p=102823)
Free Clipboard Viewer (https://freeclipboardviewer.com/)
Quote from: TimoVJL on February 12, 2022, 08:26:41 PM
Win32 have function MultiByteToWideChar(CP_UTF8, 0, ... and WideCharToMultiByte(CP_UTF8, 0, .. for UTF-8 strings.
Web pages are mostly UTF-8 and also MS help files.
Even Explorer, it seems (except in Norway). On the surface, at least - under the hood, it's surely UTF-16.
invoke GetClipboardData,CF_UNICODETEXT
invoke MessageBoxW,0,eax,addr mestitle,MB_ICONASTERISK
include \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0)
$Data 你在胡说八道,我的朋友!
$Data Mluvíš nesmysly, příteli!
$Data Вы говорите глупости, мой друг!
$Data أنت تتحدث عن هراء يا صديقي!
$Data אתה מדבר שטויות, ידידי!
$Data あなたはナンセンスを話している、私の友人!
Init
Read my$()
wMsgBox 0, wRec$(Join$(my$())), "Windows works fine everywhere in the World", MB_OK
EndOfCode
And guess what, friend from Norway, it doesn't even need MasmBasic - see attachment PureMasm32SDK :tongue:
I honestly don't know what the big deal is here, Windows has supported UNICODE since 1994 in NT4 and with UNICODE fonts, you can produce just about any language on the planet. Natural languages that can be represented with single byte character sets can use the old code page system but it was a pain to use where UNICODE easily handled entirely different language and character formats, Chinese, Japanese, Georgian, Russian etc .....
I am lazy in that as an English speaker, ASCII does the job in most instances where UNICODE requires storing string data in a different manner.
Windows NT was born from start with UNICODE, like Windows NT 3.1
:cool:
Since NT, Windows is internally using Unicode only (since Windows 2000 this is UTF-16). All the ASCII functions of the win32 API are just Wrappers which allocate additional memory to convert the ASCII string and then call the Unicode version of the function and vice versa. They do only exist because of compatibility reasons with old applications.
"New applications"(sic!) should use Unicode in general.
Hi,bomz
the OS(non ansi) uses unicode API defaultly.
or use
LOCAL ansiBuf[2048]:BYTE
invoke OpenClipboard,NULL
invoke GetClipboardData,CF_UNICODETEXT ;CF_TEXT
mov hClipdata,rax
invoke GlobalLock,hClipdata
mov lpStr,rax
invoke SetDlgItemTextW,hWnd,IDC_OUTPUT2,lpStr
invoke RtlZeroMemory,addr ansiBuf,sizeof ansiBuf
invoke WideCharToMultiByte,CP_ACP,0,lpStr,-1,addr ansiBuf,2048,NULL,NULL
invoke SetDlgItemTextA,hWnd,IDC_OUTPUT1,addr ansiBuf
invoke GlobalUnlock,hClipdata
invoke EmptyClipboard
invoke CloseClipboard
invoke ActivateKeyboardLayout,0419h,0
interesting how use cf-text and cf_oemtext for input
can anybody say how works cf-locale?
;invoke ActivateKeyboardLayout,0419h,0
invoke OpenClipboard,NULL
;invoke GetClipboardData,CF_LOCALE
;invoke MessageBox,0,eax,0,MB_ICONASTERISK
;invoke wsprintf,ADDR buffer,ADDR form,dword ptr[eax]
;invoke MessageBox,0,ADDR buffer,ADDR mestitle,MB_ICONASTERISK
invoke SetClipboardData, CF_LOCALE, 0419h
invoke GetClipboardData,CF_OEMTEXT
invoke MessageBox,0,eax,0,MB_ICONASTERISK
invoke CloseClipboard
invoke ExitProcess,0
Forget about CF_LOCAL, instead use CF_UNICODE and your problems fade away.
deleted
Using Free Clipboard Viewer someone could look what formats are already there, if someone copy something from another application.
deleted
invoke OpenClipboard,NULL
invoke GetUserDefaultLCID
invoke SetClipboardData, CF_LOCALE, eax
invoke GetClipboardData,CF_UNICODETEXT
invoke MessageBoxW,0,eax,0,MB_ICONASTERISK
invoke CloseClipboard
invoke ExitProcess,0
deleted
deleted
deleted
Guys,
can we keep this squabling out of the campus ?
I did ask to keep the squabling out of the campus.