Get CSV Data from Clipboard (pasted from Excel) that contains accented characters

后端 未结 2 947
夕颜
夕颜 2021-01-31 16:48

SCENARIO

  • My users will copy cells from Excel (thus placing it into the clipboard)
  • And my application will retrieve those cells from the clipboard
  • <
2条回答
  •  旧巷少年郎
    2021-01-31 17:00

    Your encoding of the stream as UTF8 is not working. The bytes for the umlaut are being converted into the "replacement character" unicode character.

    Instead, just look at the stream's data without any extra encoding instructions. The data will be in some set format used by Excel. You should be able to tell by looking at the byte(s) where the unlaut is. You should then be able to convert it to UTF-8.

    Worst case is if the CSV Formatter throws out everything that is not Ascii. In that case, you might be able to write your own Data formatter.

    In some cases, the Excel folks have figured that CSV means Ascii only. See http://www.tech-archive.net/Archive/Excel/microsoft.public.excel.misc/2008-07/msg02270.html

提交回复
热议问题