2

In my form, i want to use a placeholder text for my textarea. It works fine except no turkish chars.

<form action="http://localhost:8082/kaybeden/index.php/details/newcomment" method="post" accept-charset="utf-8" class="form-horizontal">
<div class="control-group">
  <div class="controls">
    <textarea name="comment_body" cols="150" rows="10" id="comment_body" placeholder="yazd���n yorum zeka bar�nd�rs�n." ></textarea>
  </div>
</div>
<div class="control-group">
  <div class="controls">
    <input type="submit" name="submit" value="Yolla" class="btn" />
  </div>
</div>

"yazd���n yorum zeka bar�nd�rs�n" string is the output, normally it should be "yazdığın yorum zeka barındırsın.". My HTML charset is UTF-8. All the turkish chars are fine except placeholder.

gunes
  • 23
  • 1
  • 4
  • On which browser(s) does this happen? – Jukka K. Korpela Mar 05 '13 at 15:35
  • What do you mean that the string is “the output”? It is broken in the HTML *source* included in the question. – Jukka K. Korpela Mar 05 '13 at 15:35
  • well i actually copied it from page source via chrome. i am new to stackoverflow. sorry for bad formatting. anyway pekka solved the problem. – gunes Mar 05 '13 at 15:41
  • @gunes you should then accept his answer, this indicates to future visitors which solution worked for this problem. You can do so by ticking the check mark to the left of his answer. – Jack Mar 05 '13 at 17:30

2 Answers2

4

This

placeholder="yazd���n yorum zeka bar�nd�rs�n."

is indicative of non-UTF-8 characters entered in a UTF-8 context.

Make sure in your text editor or IDE that your HTML file is properly UTF-8 encoded.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • i used "UTF-8 without BOM" formatting from notepad++. Still the same. Like i mentioned placeholder part is the problem. Other turkish chars are fine. – gunes Mar 05 '13 at 15:33
  • 1
    @gunes when they are broken once, changing the encoding will not fix them. You would have to enter them again in the new encoding. Have you tried that? – Pekka Mar 05 '13 at 15:34
  • seems like i haven't :) Thx a lot. they are ok now. – gunes Mar 05 '13 at 15:37
2

Use the HTML entity codes (On the website it is called numerical code) instead of the real characters. You can find a table here

For example:

<input type="text" placeholder="Kushadas&#305;"/>

NielsInc
  • 426
  • 7
  • 23
  • 1
    HTML entities are not necessary when you have a character set issue. It's much better to fix the underlying issue instead. – Pekka Mar 05 '13 at 15:21
  • @pekka it good and common practice to encode special characters. – Vince V. Mar 05 '13 at 16:16
  • @Vince no, it's not. It's completely unnecessary when all encodings are lined up properly. – Pekka Mar 05 '13 at 16:24
  • 1
    @Pekka웃 If you don't use entities, users with another charset are going to have a messed up page either way. that's the main use of html entities. Because not all users have all charsets. So your argument is invalid. – Vince V. Mar 05 '13 at 19:30
  • @Vince that's nonsense. It may have been true in 1996, but it's 2013 now. A web page (or any other data source) declares a character set. If the characters inside the page conform with that encoding, there will be **zero** problems. This is why I downvote answers suggesting HTML entities (nothing personal) - they support the superstition that entities are somehow necessary, and they provide a seemingly successful short cut that doesn't fix the actual problem, which may come back to bite you later. – Pekka Mar 05 '13 at 19:48
  • If you do a good job declaring your character set, all is well and there is no need to use entities. There are very esoteric edge cases where you don't have another choice, but those are extremely specialized situations and this isn't one of them. – Pekka Mar 05 '13 at 19:49
  • @Vince relevant discussion: [When Should One Use HTML Entities](http://stackoverflow.com/q/436615) especially William's answer – Pekka Mar 05 '13 at 19:53
  • Ok thanks for linking :) Seems interesting. But still most european is the point valid of the accepted post in that link. Turkish symbols aren't on my keyboard. So the right answer is to use the UTF symbol? – Vince V. Mar 05 '13 at 20:00
  • @Vince you can get every UTF-8 character on any keyboard using a key combination that is as complicated to look up as the HTML entity. (Plus arguably, that will not happen too often in real world situations... usually when you type Turkish text, you will have a Turkish keyboard) – Pekka Mar 05 '13 at 20:33
  • Ok fair enough. Thanks for the explanation :-) – Vince V. Mar 06 '13 at 11:56