How to Paste text into .txt file with Unicode support?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
JimXYUser
Posts: 23
Joined: 23 Nov 2012 00:26

How to Paste text into .txt file with Unicode support?

Post 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

highend
Posts: 14245
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to Paste text into .txt file with Unicode support?

Post by highend »

I tried it on the latest beta with:

Code: Select all

正體字/繁
in the clipboard and the file contains these chars afterwards...

EditPad Pro states: UTF-16LE BOM...
One of my scripts helped you out? Please donate via Paypal

PeterH
Posts: 2814
Joined: 21 Nov 2005 20:39
Location: Germany

Re: How to Paste text into .txt file with Unicode support?

Post 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.
Win11 Pro 23H2 Gerrman

admin
Site Admin
Posts: 63614
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: How to Paste text into .txt file with Unicode support?

Post by admin »

Raw is raw: it shows the bytes -- in this case as-if-they-were-ASCII.

PeterH
Posts: 2814
Joined: 21 Nov 2005 20:39
Location: Germany

Re: How to Paste text into .txt file with Unicode support?

Post 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.
Win11 Pro 23H2 Gerrman

admin
Site Admin
Posts: 63614
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: How to Paste text into .txt file with Unicode support?

Post by admin »

I see, maybe later.

noembryo
Posts: 140
Joined: 13 Apr 2022 21:40
Contact:

Re: How to Paste text into .txt file with Unicode support?

Post 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.. :roll: )

I hope that I'm not missing a very obvious solution somewhere.. :oops:

P.S. Sorry for the necro (and hijacking), but this thread was very close to my request..
Check my free programs here..

highend
Posts: 14245
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to Paste text into .txt file with Unicode support?

Post by highend »

Code: Select all

writefile("Clipboard-" . formatdate(, "yyyymmdd") . ".txt", <clp>, , "utf8");
?
One of my scripts helped you out? Please donate via Paypal

noembryo
Posts: 140
Joined: 13 Apr 2022 21:40
Contact:

Re: How to Paste text into .txt file with Unicode support?

Post 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).. :maf:
Check my free programs here..

jupe
Posts: 3242
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: How to Paste text into .txt file with Unicode support?

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

noembryo
Posts: 140
Joined: 13 Apr 2022 21:40
Contact:

Re: How to Paste text into .txt file with Unicode support?

Post 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.. :(
Check my free programs here..

admin
Site Admin
Posts: 63614
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: How to Paste text into .txt file with Unicode support?

Post by admin »

No. If you ctrl+alt+V "διεθνές κείμενο", you (should!) get a UTF-16LE BOM file.

noembryo
Posts: 140
Joined: 13 Apr 2022 21:40
Contact:

Re: How to Paste text into .txt file with Unicode support?

Post 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.. :oops:

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
Check my free programs here..

admin
Site Admin
Posts: 63614
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: How to Paste text into .txt file with Unicode support?

Post by admin »

Try these and post the results:

Code: Select all

charview "διεθνές κείμενο";

Code: Select all

echo isunicode("διεθνές κείμενο", 0);

Code: Select all

echo isunicode("διεθνές κείμενο", 1);

noembryo
Posts: 140
Joined: 13 Apr 2022 21:40
Contact:

Re: How to Paste text into .txt file with Unicode support?

Post by noembryo »

This is what I get with ctrl+alt+V
Clipboard-20250221.txt
(15 Bytes) Downloaded 51 times
Last edited by noembryo on 21 Feb 2025 11:25, edited 1 time in total.
Check my free programs here..

Post Reply