Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
chcp 10000
echo hell☺ w☻rld♥! >> "UTF-16 file☺☻♥♦♣♠"

OK, it creates correct file, but in the content there are question marks instead of unicode characters. How to fix it?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I'm not sure what you are trying to do here, but that's not a Unicode code page. See http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx.

10000   macintosh   MAC Roman; Western European (Mac)
...
1200    utf-16      Unicode UTF-16, little endian byte order (BMP of ISO 10646); available only to managed applications
1201    unicodeFFFE Unicode UTF-16, big endian byte order; available only to managed applications
...
12000   utf-32      Unicode UTF-32, little endian byte order; available only to managed applications
12001   utf-32BE    Unicode UTF-32, big endian byte order; available only to managed applications
...
65000   utf-7       Unicode (UTF-7)
65001   utf-8       Unicode (UTF-8)

I'm not sure why, but the Command Prompt seems to interpret them as control characters when pasted, specifically SOH (Start of Heading, 01), STX (Start of Text, 02) and ETX (End of Text, 03).

On the plus side, PowerShell seems to handle this properly. Notepad++ opened the resultant text file as "UCS-2 Little Endian" automatically, and it displays the correct characters.


Ok, I've figured out why UTF-8 wasn't working for me. The font should be set to Lucida Console, since the default Raster Fonts don't have Unicode support.

share|improve this answer
    
chcp 1200 : console says: "Invalid code page", as well ass with chcp 1201. Why? –  0x6B6F77616C74 May 26 '12 at 11:50
1  
@kutacz available only to managed applications. Use PowerShell for proper Unicode support, since the UTF-8 option (65001) doesn't seem to work in the Command Prompt for this case. –  Bob May 26 '12 at 11:52
    
In case of UTF-8(after chcp 65001) it works fine... –  0x6B6F77616C74 May 26 '12 at 11:54
    
@kutacz Well, then, use UTF-8. It didn't seem to work for me, but I'm still not sure what you're trying to do. UTF-16 is not possible in the standard Command Prompt. Managed applications probably refers to the .NET Framework. PowerShell runs on the .NET Framework, so it works for UTF-16. –  Bob May 26 '12 at 12:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.