Page 1 of 2
How to Paste text into .txt file with Unicode support?
Posted: 07 Apr 2015 22:23
by JimXYUser
Hi,
When i copy some text and -> Paste Special -> Paste Text Into New File
It create a ANSI encoded text file.
How can I paste into a Unicode text file? (reason, some Unicode is not supported in ANSI).
thanks
Re: How to Paste text into .txt file with Unicode support?
Posted: 08 Apr 2015 01:34
by highend
I tried it on the latest beta with:
in the clipboard and the file contains these chars afterwards...
EditPad Pro states: UTF-16LE BOM...
Re: How to Paste text into .txt file with Unicode support?
Posted: 08 Apr 2015 10:41
by PeterH
Tested with highend's text:
- pasted it into command line: shown OK
- pasted/special into New File
- Preview it: OK
- Raw View: garbage (but says: UTF-16LE file, Ascii view)
- check per editor: OK
Didn't expect that Raw View shows it as ASCII - but as it says so I'd say it's correct.
Re: How to Paste text into .txt file with Unicode support?
Posted: 09 Apr 2015 08:13
by admin
Raw is raw: it shows the bytes -- in this case as-if-they-were-ASCII.
Re: How to Paste text into .txt file with Unicode support?
Posted: 09 Apr 2015 11:26
by PeterH
admin wrote:Raw is raw: it shows the bytes -- in this case as-if-they-were-ASCII.
Yes, but sometimes I need a quick look at a file that happens to be UTF, but that's not a Previewed filetype. (.gpx, for example, but others, too.)
Here it would be very convenient if I could switch in Raw View between Hex, ASCII,
and UTF, to be able to read the contents. Now I always must open it in some editor, just to have a readable view.
So I'd
wish a radio button instead of the Hex selection field.
Re: How to Paste text into .txt file with Unicode support?
Posted: 09 Apr 2015 11:52
by admin
I see, maybe later.
Re: How to Paste text into .txt file with Unicode support?
Posted: 21 Feb 2025 00:34
by noembryo
Is it possible to have a setting or a hack, to always create a UTF-8 file when pasting to a new text file, instead of an ANSI one?
Now I have to Paste to a new file, open it with an editor, change the encoding to UTF-8, and re-save.
(Which beats the purpose of this shortcut since it has the same or even more steps than to just open the editor, paste and save..

)
I hope that I'm not missing a very obvious solution somewhere..
P.S. Sorry for the necro (and hijacking), but this thread was very close to my request..
Re: How to Paste text into .txt file with Unicode support?
Posted: 21 Feb 2025 00:53
by highend
Code: Select all
writefile("Clipboard-" . formatdate(, "yyyymmdd") . ".txt", <clp>, , "utf8");
?
Re: How to Paste text into .txt file with Unicode support?
Posted: 21 Feb 2025 01:32
by noembryo
Thank you @highend for your code, but I was thinking more of a setting to the native Ctrl+Alt+V shortcut or the "Paste Text into New File" menu action.
I can try and create a CB with your code, and then somehow assign it the Ctrl+Alt+V keyboard shortcut (I hope that the shortcuts work if the CB is not visible)..

Re: How to Paste text into .txt file with Unicode support?
Posted: 21 Feb 2025 01:49
by jupe
You just need to set the shortcut key via
UDC no need for a CTB, you must first unset the default shortcut key via
CKS though.
FYI with the default action, if the clipboard has unicode text on it then the file will get saved with a BOM automatically.
Re: How to Paste text into .txt file with Unicode support?
Posted: 21 Feb 2025 11:01
by noembryo
jupe wrote: ↑21 Feb 2025 01:49
FYI with the default action, if the clipboard has unicode text on it then the file will get saved with a BOM automatically.
There is this great mixup about Unicode<>utf-8, but from what I understand, if I copy some text that should be Unicode, like this: "διεθνές κείμενο", and paste it with ctrl+alt+V, I get an ANSI text file.
I couldn't find a way to copy anything and get a UTF-8 text file with paste..

Re: How to Paste text into .txt file with Unicode support?
Posted: 21 Feb 2025 11:05
by admin
No. If you ctrl+alt+V "διεθνές κείμενο", you (should!) get a UTF-16LE BOM file.
Re: How to Paste text into .txt file with Unicode support?
Posted: 21 Feb 2025 11:21
by noembryo
admin wrote: ↑21 Feb 2025 11:05
No. If you ctrl+alt+V "διεθνές κείμενο", you (should!) get a UTF-16LE BOM file.
Well, not here..
OS: Windows 10 Pro, 64-bit, Version 22H2, Build 19045.3324 (10.0), .NET v4.8.09037
Time Zone: GTB Standard Time, GTB Daylight Time UTC Offset: +02:00
Windows UI Language: English LongPathAware: No
Themes: Yes (Dark) RealSystem32: Yes User Role: User
System / Thread Locale ID: 1032 (el-GR) / 1032 (el-GR)
Default ANSI Code Page: 1253 (ANSI - Greek)
Active ANSI Code Page: 1253 (ANSI - Greek)
Default OEM code page: 737 (OEM - Greek 437G)
Active OEM Code Page: 737 (OEM - Greek 437G)
DBCS Code Page: No
Main Contents Font: Segoe UI 9,75
Buttons & Labels Font: Segoe UI 9,75
Re: How to Paste text into .txt file with Unicode support?
Posted: 21 Feb 2025 11:22
by admin
Try these and post the results:
Code: Select all
echo isunicode("διεθνές κείμενο", 0);
Code: Select all
echo isunicode("διεθνές κείμενο", 1);
Re: How to Paste text into .txt file with Unicode support?
Posted: 21 Feb 2025 11:23
by noembryo
This is what I get with ctrl+alt+V
Clipboard-20250221.txt