开发者

C# mysql newline on insert turns into a square in text column [duplicate]

开发者 https://www.devze.com 2023-03-10 06:56 出处:网络
This question already has answers here: MySQL C# Text Encoding Problems (6 answers) Closed 2 years ago. 开发者_如何转开发
This question already has answers here: MySQL C# Text Encoding Problems (6 answers) Closed 2 years ago. 开发者_如何转开发

This ones pretty simple, i'm not very familiar with mysql, but I have a c# app inserting found data. That data contains \n, but as I said it turns into the funny square


When you're looking at a text column it'll probably get converted to ascii. Since the newline character isnt ascii but Unicode it'll show up as the 'unknown' character aka the little square.

The conversion can occur when inserting the data in code, conversion in the database in the insert query, when showing the data or reading the data in code. So there are a lot of places this can go wrong.

Read up about text encoding and see the link pRimE posted.


like Bala R wrote in the comment, it depend's where you display your text.

a non multiline textbox control might screw up if it encounters a newline char.

additionally, begining a new line is a platform dependant thing ... on *NIX like platforms you usually have \n and that's it. windows usually uses \r\n as sequence for a linebreak

0

精彩评论

暂无评论...
验证码 换一张
取 消