Skip to content

Smart quotes aren't escaped #1718

Answered by JoshClose
jdege asked this question in Q&A
Discussion options

You must be logged in to vote

At some point, you'll need to convert the UTF-8 text into ISO-8859-1 before it hits the TextWriter.

Some options that I can think of.

  1. You could convert before setting the properties of the model.
  2. If this is coming from a DB
    1. The DB might have a way to do it before returning the results.
    2. An ORM like Entity Framework could probably do it by hooking into the process.
  3. You could override CsvWriter.WriteToBuffer and convert it, then call the base method.
  4. You could create a type converter to do the conversion and register it for all string types.

This example works correctly. Strings in the IDE are UTF-16, which is why I used that there.

void Main()
{
	var text = "one “two” three";
	var stri…

Replies: 9 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by JoshClose
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1716 on February 24, 2021 17:01.