1

I'm having an issue where I can't get this symbol "℗" to render in a .tsv file. I'm using powershell to add data to my .tsv that has copyright info, so I need to have it copy over correctly. I use add-content -path C:\blah and I include the -encoding parameter at the end, but all of the encoding choices I've tried cannot render this sound recording copyright symbol. Anyone have any idea if this can work? UTF8 and UTF32 render the © symbol correctly, for what it's worth. What's also sort of funny is that Powershell ISE can render the symbol correctly.

Thanks for any help.

Edit: I'm thinking now it may just be a limitation of the .tsv file? I just tried opening the .tsv in excel, pasting the "℗" symbol into an empty cell, and when I save and re-open the file, the "℗" is replaced by a "?".

Edit 2: If I use import-csv -path -delimiter and import the .tsv, the symbol does render correctly in Powershell. I would like it to render correctly in Excel if that's possible. I also tried to load it using Google Sheets but it had the same problem.

Matthew Goode
  • 105
  • 1
  • 9
  • 1
    If you write it in PowerShell with the encoding, and then read it back in PowerShell with the same encoding, does it seem to render correctly? Maybe it's the application you're using to view it that is wrong? – briantist May 05 '16 at 17:44
  • 1
    This is not a limitation of tsv, in utf8 hex `31 09 e2 84 97 09 33 0a` translates to `13`. – Andrey May 05 '16 at 18:01
  • @Briantist I'm not sure if this satisfies your question, but yes I can get the symbol to render in the PowerShell console (and in the scripting window). And Andrey, is there anything else I can try that might help me out? Is it possible to enter that character explicitly as hex? Perhaps that would help. Also, just for more information, I'm using Excel to open the .tsv. Excel can render the symbol correctly if I copy and paste directly into it. – Matthew Goode May 05 '16 at 18:29
  • 2
    @MatthewGoode maybe Excel is not reading the file encoding correctly then? It sounds like PowerShell is doing what it's supposed to. What if you use Unicode? – briantist May 05 '16 at 18:32
  • Unicode gives even funkier outputs. Before, I was getting just a "?", but if I try some other encoding then the characters just become more random. – Matthew Goode May 05 '16 at 18:44
  • Ah just updated the OP with some more info. When I import the .tsv into powershell, the symbol does render correctly in utf 8. So is Excel messing with it? – Matthew Goode May 05 '16 at 18:50
  • 1
    This [discussion](http://stackoverflow.com/q/6002256/3476320) might help. It seems that it's an Excel issue. Other programs, e.g. LibreOffice and R have no problems with such a file. – Andrey May 05 '16 at 19:13
  • Thanks Andrey for the link! I believe the marked solution there did work, but I didn't want to go through Excel's import process every time. But you kept my brain rolling to try some more stuff and I figured out a workaround, so thanks for that. I posted it as a solution here. – Matthew Goode May 05 '16 at 20:04

1 Answers1

0

This turns out to be sort of a workaround I think, but the end result is what I wanted.

There seems to be some type of problem with excel and the encoding of .tsv, .csv, etc. So what I found worked for me was opening whatever file I wanted (in Excel), saving as a "Unicode .txt", then just renaming the file extension from .txt to .tsv. The file still opens correctly as a .tsv spreadsheet, but for whatever reason the encoding works now so that the "℗" saves correctly. And it looks like I only need to do this once and I can keep appending to the same .tsv. Strange solution, but I'll take it.

And just to clarify, if I open the file as a .txt in Excel, it also retains the correct formatting. I just changed the extension to .tsv so that a double click will open to Excel rather than notepad. I believe the file is technically still saved as a Unicode .txt file.

Matthew Goode
  • 105
  • 1
  • 9