Python Forum
non-latin characters in console from clipboard
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
non-latin characters in console from clipboard
#1
In interactive console session mode Python 3.12 (after entering commands line by line),
the code with the Polish letter "ł" does not open any window.
But just remove the letter 'ł' and everything is OK.
The problem is only in the console.
How to get around this?
# -*- coding: utf-8 -*-
import tkinter as tk
root = tk.Tk()
root.title("title with ł character")
label = tk.Label(root, text="------===== long text, to see ... full title =====---------")
label.pack()
root.mainloop()
After placing the code in the 'test.py' file and running it in CMD: python trest.py it is OK

==== PL ====
W trybie interaktywnej sesji konsoli Python 3.12 (po wpisaniu poleceń linia po linii)
powyższy kod z polską literą 'ł' w tytule okna nie wykonuje się,
ale wystarczy usunąć literę 'ł' i wszystko jest OK.
Po umieszczeniu kodu w pliku 'test.py' i uruchomieniu w CMD: python trest.py też jest Ok
Jak to obejść?
buran write Oct-26-2023, 01:00 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
I can't reproduce the bug. The code works for me with Python 3.10 in Linux.
Reply
#3
Small correction:
I edit the file as UTF-8 in the Notepad++ editor:
# -*- coding: utf-8 -*-
import tkinter as tk
root = tk.Tk()
# ąĄćĆęĘłŁńŃóÓśŚŻżŹź
root.title("title with ł character")
label = tk.Label(root, text="------===== long text, to see ... full title =====---------")
label.pack()
root.mainloop()
After copying to the clipboard and pasting into the Python 3.12 console (code page => 65001 UTF-8),
the window is empty, without a name, but ... just move the file with the comment one line higher - before 'root',
# -*- coding: utf-8 -*-
import tkinter as tk
# ąĄćĆęĘłŁńŃóÓśŚŻżŹź
root = tk.Tk()
root.title("title with ł character")
label = tk.Label(root, text="------===== long text, to see ... full title =====---------")
label.pack()
root.mainloop()
This is ok

Interesting:
Two lines can be copied:
# -*- coding: utf-8 -*-
import tkinter as tk
root = tk.Tk()
then 'manually' enter the line:
# ąĄćĆęĘłŁńŃóÓśŚŻżŹź
and then paste the rest of the line:
root.title("title with ł character")
label = tk.Label(root, text="------===== long text, to see ... full title =====---------")
label.pack()
root.mainloop()
and... now it's OK

???
Windows clipboard problem?
Reply
#4
I don't have any problems using Windows, but it could be that the characters were changed when you posted the code.

I have a lot of problems with character encoding in windows.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  saving and loading text from the clipboard with python program MaartenRo 2 1,666 Jan-22-2022, 05:04 AM
Last Post: MaartenRo
  "If Len(Word) == 0" Code Block in Pig Latin Program new_coder_231013 3 2,081 Jan-02-2022, 06:03 PM
Last Post: deanhystad
  How to listen to clipboard content change without polling the clipboard continuously? edgelord 0 2,493 Nov-27-2020, 06:07 AM
Last Post: edgelord
  Problem posting image to clipboard noel 0 2,177 Sep-26-2020, 10:50 AM
Last Post: noel
  Pressing non-latin characters? Murlog 0 1,539 Jul-25-2020, 03:10 PM
Last Post: Murlog
  Remove escape characters / Unicode characters from string DreamingInsanity 5 13,777 May-15-2020, 01:37 PM
Last Post: snippsat
  How to copy data to clipboard OAP 10 7,890 Mar-19-2020, 10:32 PM
Last Post: OAP
  How can I paste an entire file from clipboard to a folder? daverave1212 5 8,511 Feb-08-2020, 04:33 PM
Last Post: snippsat
  I want to filter out words with one letter in a string (pig latin translator) po0te 1 2,112 Jan-08-2020, 08:02 AM
Last Post: perfringo
  Auto-copy all displayed "print" results into clipboard? smallabc 1 1,664 Dec-16-2019, 02:10 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020