0

am trying to use a form that has a textarea and uploads a file , now when the user writes arabic it saves to mysql like this :

بسيبيبي&

Note that the encoding for the Field in mysql is utf8-general-ci , so i think that the problem is in using enctype= multipart/form-data , so what do you think i should do ?

test
  • 301
  • 2
  • 7
  • 16
  • [Handling Unicode Front To Back In A Web App](http://kunststube.net/frontback/) – deceze Apr 09 '13 at 12:29
  • possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – deceze Apr 09 '13 at 12:29
  • Just add accept-charset="utf-8" would that help you? – Kees Sonnema Apr 09 '13 at 12:30
  • possible duplicate of [Save Data in Arabic in MySQL database](http://stackoverflow.com/questions/6859018/save-data-in-arabic-in-mysql-database) – Dipesh Parmar Apr 09 '13 at 12:30
  • These are HTML escape sequences. This means one of two things. **1)** Either you use a JavaScript editor component on the client side that is set to return HTML and sends the text exactly in that manner. **2)** Or you use some sort of HTML-encoding function on the server side before you store the string. The one thing it definitely has nothing to do with is mySQL. – Tomalak Apr 09 '13 at 12:31
  • @Tomalak It most likely means the browser is trying to submit the data in Latin1 because he's missing the appropriate encoding declarations in the page. Characters that can't be encoded in Latin1 will be submitted as HTML entities. – deceze Apr 09 '13 at 22:48
  • @deceze Is that in a spec somewhere? Doesn't sound right to me - the browser submits *byte sequences*, not HTML. Why would it arbitrarily submit some bytes as HTML entities? – Tomalak Apr 09 '13 at 22:55
  • @Tomalak I don't know if it's in the spec somewhere, but a quick test confirms that it actually works that way. It makes the most sense as fallback next to flat out dropping the characters. The browser can't URL encode the values, since they're invalid byte sequences in the specified encoding. – deceze Apr 09 '13 at 23:03

3 Answers3

1

Use enctype="multipart/form-data;charset=UTF-8" instead of only enctype= multipart/form-data in your form, so the full form code example is:

<form action="" method="POST" enctype="multipart/form-data;charset=UTF-8">

UPDATE - also Use utf8_decode() to convert form text to normal ISO-8859-1 characters.

Ramy Ahmed
  • 133
  • 1
  • 9
1

Before inserting the Arabic text (textarea) in database, convert it from charset "iso-8859-1" to charset "WINDOWS-1256" or charset "UTF-8" depends on the Arabic charset you use

Ahmed
  • 11
  • 3
0
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

and the collation for the table should be utf8-general-ci

Amir
  • 4,089
  • 4
  • 16
  • 28