Problems saving XML file with special character in the database (ç, ã, etc)

Asked

Viewed 809 times

0

My problem is this: I am issuing an electronic correction letter in C# and at the time of saving the XML of the event returned by SEFAZ, as much as all the characters in the file are normal, when saving in the database as blob they look like this, with these strange characters ("xE7, xE3") when I export the file:

inserir a descrição da imagem aqui

Does anyone have any idea how to fix this?

Edit1: And when I try to load this xml with these strange characters it launches Xmlexception complaining of invalid character

  • What kind of data in the column where you are saving this Xml?

  • the data type of the column is longblob

  • the collation is latin-swedish_ci, I imagine that’s it

  • Characters are truced your database does not support utf-8 or latin characters.

  • Set to utf-8

2 answers

1

I solved the problem by making an Encoding.Convert from latin1 to utf-8 before giving Writeallbytes, then it came right and gave no more error when giving Load by invalid character.

inserir a descrição da imagem aqui

  • NOTE: The solution is mixed (VB and C#), so the file I ended up solving was in VB, I was trying to solve in the C part#

0

Taking advantage that you are using Notepad++ go to the Encoding menu and change from UTF-8 to ANSI will not be the solution to your problem, but will show you the result with the correct characters.

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

Check the files of your system, this having an incompatibility between your project and the data you receive, one with ANSI (probably yours) and the other as UTF-8

Browser other questions tagged

You are not signed in. Login or sign up in order to post.