Textbox encoding

Textbox encoding

robsreichrobsreich Posts: 5Questions: 1Answers: 0

hello

I hope someone can help me. I have some troubles with special characters and my knowledge and the web couldn’t help me.
It look's like datatables writes/encodes not very propper:

I'm using .NET framework and MS SQLEXPRESS 2017 (SQL_Latin_General_CP850_CI_AS)

line 1 was created with datatables

line 2 was created with SQL-Query

In the header of the html file i'm using:

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

and in web.config:
<globalization requestEncoding="utf-8" responseEncoding="utf-8" fileEncoding="utf-8" />

Response:
{"draw":null,"data":[{"DT_RowId":"row_6","tooltype":"&#230;","toolname":"&#230;","modell":"&#230;","serial":"&#230;","merknad":"&#230;","arsmodell":"&#230;","lokasjon":"&#230;"}],"recordsTotal":null,"recordsFiltered":null,"error":null,"fieldErrors":[],"id":null,"meta":{},"options":{},"files":{},"upload":{"id":null},"debug":null,"cancelled":[]}

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @robsreich ,

    It's not a DataTables issue, since it doesn't do anything special with the strings, it'll be to do with the encoding in the database. This thread here should give you a few pointers.

    Cheers,

    Colin

  • robsreichrobsreich Posts: 5Questions: 1Answers: 0
    edited February 2019

    Hi @collin,

    I found the thread you are referring to and read it multiple times before. I can’t see a similarity to the framework I’m using.

    When I’m adding the charset attribute to my connection string, I’m getting a “System.ArgumentException: 'Keyword not supported: 'charset'.'” Error.

    For me it still looks like the client side is here the issue. When was the json response encoded? Before or after database encoding? Why works database encoding korrekt with a SQL query?

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    If the database is a latin charset, why mark the page as utf8? Are you converting it somewhere?

    What are you using for the server-side action here - is it any of the libraries that we provide? I wouldn't have expected to see the HTML encoded entity in the JSON response. It would be much better to just have the character.

    Allan

  • robsreichrobsreich Posts: 5Questions: 1Answers: 0
    edited February 2019

    Hi Allen,

    I have the same issue with the demo code and the code from the generator. I've only changed the settings. I've testet with three databases and one of them was totaly plain and i let datatables generate the tables. I started with Danish_Norwegian_CI_AS and now ended up with latin.

    I wouldn't have expected to see the HTML encoded entity in the JSON response. It would be much better to just have the character.

    So you agree that the database is not the issue and something is worong on the client side? As I said I'm testing with your (99% amazing) codework.

  • robsreichrobsreich Posts: 5Questions: 1Answers: 0

    Hei

    the PHP code from the generator works fine !

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Can you convert your database to be UTF8? That would be the best option if possible.

    The client-side doesn't do any character encoding conversation, so I'm fairly certain that its a server-side issue, particularly given that the data loaded from the server is already entity encoded as you noted above, but the question is how to narrow it down.

    Regarding your last message, if you use æ characters in the code made by generator, can you confirm that everything is okay?

    Allan

  • robsreichrobsreich Posts: 5Questions: 1Answers: 0

    Hi Allen

    my last message was maybe a bit to cryptic :smile:. Sorry for that.

    With the PHP code made by the generator everything works fine. I can store whatever I find on my Norwegian keyboard in the same database which doesn’t work with the .NET framework.

This discussion has been closed.