tags:

views:

27

answers:

2

hi

I built form here, When I input utf-8 data to it at firefox 3.6.8 it is like this:

but it works fine with IE.8

alt text

It seems that while typing (or filling) the input box, the characters are all uppercase. Just like that you are holding shift and type it.

anyone knows what is the problem with firefox?


edit :

it is a simple form

<form enctype="multipart/form-data" action="print $_SERVER['PHP_SELF'];" method="post" accept-charset="utf-8">

<br><input name="f_name" type="text"><br>

</form>
A: 

Hmm. When I try this, it seems to work fine; I'm not familiar with Arabic, but it appears that the characters are showing up in lowercase, not uppercase, when I type in the form. Here is the full example I am using:

<!DOCTYPE html>
<html>
  <head>
    <title>Test</title>
  </head>
  <body>
    <form enctype="multipart/form-data" method="post" accept-charset="utf-8">
      <input name="f_name" type="text">
    </form>
  </body>
</html>

This works for me on Firefox 3.6.8 on Mac OS X. What platform are you running on? Do you see this problem in other input boxes, such as on Google?

You might also want to check the encoding that your Content-Type is being sent as. Everything will work best if you use Content-Type: text/html; charset=utf-8. It can also be helpful to add a <meta charset="utf-8"> tag in case you lose the Content-Type header somehow.

Brian Campbell
Thank you for your quick and helpful comment.
safaali
A: 

Is that what appears when you type in a form field, before submitting anything? Because if so, there is no UTF-8 in the problem. Strings at the web browser side are purely Unicode-based; it's only when you're moving them from the browser to the server or back that encoding matters come into play.

My guess would be a simple font problem. Clearly from your screenshot, Firefox is using a different font to IE, and perhaps that font is one without proper support for features necessary to Arabic like the contextual ligatures that take care of choosing the right glyph variant of each character. Check the stylesheets and use Firebug if necessary to find out what font is being applied to that input.

accept-charset="utf-8"

is basically no use, because IE handles it wrong. It uses UTF-8 as a fallback encoding (for characters that don't fit in the page's current charset) instead of the only encoding.

To get a form that submits in UTF-8, you must ensure that the page containing the form is served as text/html;charset=utf-8 using a Content-Type header and/or <meta> tag.

action="print $_SERVER['PHP_SELF'];"

I'm presuming you've mis-pasted that and the value is actually in a <?php ... ?> tag, otherwise the form wouldn't work at all.

This is an HTML-injection hole, potentially leading to cross-site scripting attacks. You should always HTML-encode strings you are injecting into HTML text content or attribute values, using htmlspecialchars().

bobince
you are right about the font. since it is not sent to php, so there only browser problem. and interesting point is , I turned off my PC and restart it. the problem is solved now. but I learned a lot here. Thank you
safaali