Unicode issue

  • I am trying to write to a file using .Net. In one column, I am wrapping the output in a unicode char(164)

    i.e.

    select char(164) + ColumnText + char(164)

    The char(164) appears correctly in SQL and in the file I am writing to...as long as I open the file with Notepad.

    However, when I open the file in WordPad, the char(164) ends up char(194)char(164) ColumnText char(194)char(164)

    I've tried to replace the char(194), I've tried chopping the string off using substring to no avail

    Any ideas?

  • Robert Heynen-454800 (8/27/2014)


    I am trying to write to a file using .Net. In one column, I am wrapping the output in a unicode char(164)

    i.e.

    select char(164) + ColumnText + char(164)

    The char(164) appears correctly in SQL and in the file I am writing to...as long as I open the file with Notepad.

    However, when I open the file in WordPad, the char(164) ends up char(194)char(164) ColumnText char(194)char(164)

    I've tried to replace the char(194), I've tried chopping the string off using substring to no avail

    Any ideas?

    Quick thought, if the file is a unicode file, use the NCHAR() instead of the CHAR() function.

    😎

  • I tried that first...didn't work

    I researched a bit and found something called a surrogate pair, where if the char number is higher than a certain range, it introduces two chars instead of one...

    If anyone has solved this, please let me know!

    thanks!

  • Robert Heynen-454800 (8/27/2014)


    I tried that first...didn't work

    I researched a bit and found something called a surrogate pair, where if the char number is higher than a certain range, it introduces two chars instead of one...

    If anyone has solved this, please let me know!

    thanks!

    Question still remains, is the output file a unicode encoded file?

    😎

  • Robert Heynen-454800 (8/27/2014)


    I tried that first...didn't work

    I researched a bit and found something called a surrogate pair, where if the char number is higher than a certain range, it introduces two chars instead of one...

    If anyone has solved this, please let me know!

    thanks!

    Trying still to understand your problem, the character you are using is not in the higher range, consistently there in the lower range through out most western collations I know of. Per se it is a YAA (yet another ascii). I have often used this symbol among other as delimiter in both unicode and ascii files without any problems.

    😎

  • There seems to be an issue in regards to ANSI vs Unicode

    When the file is viewed as an ANSI encoded file, both chars show

    When the file is viewed as an UTF-8 endoded file, only the right char shows....which is the behavior I need

    Is there a way to force SQL to write one way or another?

  • Robert Heynen-454800 (8/27/2014)


    There seems to be an issue in regards to ANSI vs Unicode

    When the file is viewed as an ANSI encoded file, both chars show

    When the file is viewed as an UTF-8 endoded file, only the right char shows....which is the behavior I need

    Is there a way to force SQL to write one way or another?

    My question is, why if writing anything in Unicode do you expect it to display properly as ANSI/ASCII single byte? Puzzles me!

    😎

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply