Author Topic: non-english windows clipboard problem  (Read 3968 times)

bomz

  • Member
  • **
  • Posts: 60
non-english windows clipboard problem
« on: February 11, 2022, 12:50:11 PM »
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.
Code: [Select]
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();
    }
}

six_L

  • Member
  • ***
  • Posts: 316
Re: non-english windows clipboard problem
« Reply #1 on: February 11, 2022, 05:21:25 PM »
try to test as following.
Code: [Select]
local TestBuffer[256]:word

invoke MultiByteToWideChar,CP_ACP,0,clip_data,-1,addr TestBuffer,256
Say you, Say me, Say the codes together for ever.

TimoVJL

  • Member
  • *****
  • Posts: 1320
Re: non-english windows clipboard problem
« Reply #2 on: February 11, 2022, 08:11:53 PM »
Making an UNICODE application is also one option.
May the source be with you

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: non-english windows clipboard problem
« Reply #3 on: February 11, 2022, 08:22:38 PM »
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

bomz

  • Member
  • **
  • Posts: 60
Re: non-english windows clipboard problem
« Reply #4 on: February 11, 2022, 09:16:08 PM »
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?

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: non-english windows clipboard problem
« Reply #5 on: February 11, 2022, 10:22:56 PM »
The essence of the problem is that you should use Unicode, UTF-16 and UTF-8. The old code pages are messy.

bomz

  • Member
  • **
  • Posts: 60
Re: non-english windows clipboard problem
« Reply #6 on: February 11, 2022, 10:34:13 PM »
interesting the problem is to switch to RU language from ENG

shift ctrl or shit alt



nidud

  • Member
  • *****
  • Posts: 2388
    • https://github.com/nidud/asmc
Re: non-english windows clipboard problem
« Reply #7 on: February 11, 2022, 10:59:29 PM »
deleted
« Last Edit: February 24, 2022, 05:01:48 PM by nidud »

bomz

  • Member
  • **
  • Posts: 60
Re: non-english windows clipboard problem
« Reply #8 on: February 11, 2022, 11:07:56 PM »
LoadKeyboardLayout - must change locale of my pipe(?!)

invoke LoadKeyboardLayout,419, KLF_ACTIVATE
error

Code: [Select]
+-------------------------+-------------------------+
|     SubLanguage ID      |   Primary Language ID   |
+-------------------------+-------------------------+
15                    10  9                         0   bit

invoke GetKeyboardLayout,0 -> 67699721 = 100000010010000010000001001 it is english


jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: non-english windows clipboard problem
« Reply #9 on: February 11, 2022, 11:31:51 PM »
The 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.

bomz

  • Member
  • **
  • Posts: 60
Re: non-english windows clipboard problem
« Reply #10 on: February 11, 2022, 11:48:45 PM »
.asc how open asc?

nidud

  • Member
  • *****
  • Posts: 2388
    • https://github.com/nidud/asmc
Re: non-english windows clipboard problem
« Reply #11 on: February 12, 2022, 12:49:44 AM »
deleted
« Last Edit: February 24, 2022, 05:02:06 PM by nidud »

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: non-english windows clipboard problem
« Reply #12 on: February 12, 2022, 04:01:41 AM »
.asc how open asc?

RichMasm, 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:

Not 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.

nidud

  • Member
  • *****
  • Posts: 2388
    • https://github.com/nidud/asmc
Re: non-english windows clipboard problem
« Reply #13 on: February 12, 2022, 06:20:47 AM »
deleted
« Last Edit: February 24, 2022, 05:02:21 PM by nidud »

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: non-english windows clipboard problem
« Reply #14 on: February 12, 2022, 07:56:53 AM »
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.

hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: