arabic url in codeigniter at internet explorer - codeigniter

I'm using codeigniter 2.1.1
when i run any url like :
www.mysite.com/search/عربي
$key = "عربي";
it worked with all browsers except internet explorer
and IE say: Undefined variable key

According to the standards (RFC1738), URLs can only contain ASCII characters. Non-ASCII characters must be encoded. This is a rare case of IE being more standards compliant than other browsers.
I believe you'll find if you use something like HTTP Watch that the other browsers are encoding them to send to the server anyway, just displaying the Unicode characters in the address bar...

Related

Encoding issue with PHPMailer 5.2.1

I am trying to include words containing a diaresis (particularly "ë" in messages through PHPMailer, but am getting "ë" in the emails.
I have included the following right after instantiating my class:
$mail->Encoding= 'base64';
$mail->CharSet = 'UTF-8';
The character encoding appears correct when I preview it in a browser:
But when I view it in gmail, I get junk:
I have also tried running the content of the message through iconv, mb_convert_encoding, and even str_replace, all to no avail.
What can I do to make sure that characters like this show up correctly in emails sent via PHPMailer?
Why on earth are you using such an ancient (from 2012!), buggy & vulnerable version of PHPMailer? Update now. Also your images are broken.
Aside from that, $mail->CharSet = 'UTF-8'; should be all you need, though you do also need to be sure that you are actually feeding UTF-8 content into it, so check your sources. You don't need to set the encoding at all - in fact you're more likely to get marked as spam if you base64-encode message bodies.

UTF-8 encoding Google Apps Email Settings API

I've been using Google Apps Email Settings API for a while but I came to a problem when I tried to insert aliases, signatures or any information with "ñ" or "Ñ". It adds garbage instead of those characters and it doesn't seem to respect the charset specified (utf-8) in the HTTP header nor the XML character encoding.
I have tried via my own python code and also using OAuth Playground[1] but it's been impossible to properly add the mentioned characters.
¿Any idea/suggestion?
Thanks in advance.
EDIT: It seems that the problem is not in the request but in the response. I have encoded it successfully in my code but it should be also fixed in OAuth Playground.
[1] https://developers.google.com/oauthplayground/
I have succesfully called Google API client methods using UTF8-encoded strings, so it is definitely an issue with your Python setup.
I would workaround this issue sending Unicode strings instead of UTF-8 encoded:
u'literal string' # This is unicode
'encoded utf-8 string'.decode('utf-8') # This is unicode
EDIT: Re-reading your answer it seems that you are making raw HTTP calls with hand-made XML documents. I can't understand why. If it's the way you want to go, take a look into Emails Settings API client code to learn how to build the XML documents.

Some problem with encoding $_GET variable from address bar

My project is based on CodeIgniter, but I guess this question isn't about it at all.
First, I have enabled query strings and a search function. Search string passes to the “searchterm” variable and when I pass it through the form, it works fine and looks like:
http:// local/home/search/?searchterm=testtesttest
Okay, now when I input some cyrillic string in a search form, it works fine as well, the URI would be for example:
http:// local/home/search/?searchterm=привет (in chrome) or
http:// local/home/search/?searchterm=������ (in IE, Opera etc.)
Two above cases work fine, BUT WHEN I enter the CYRILLIC search string directly from the address bar (for example, in Opera or IE) it doesn’t wanna search anything. $_GET[‘searchterm’] is empty, and as for QUERY_STRING, it is something like searchterm=������ (all data from profiler).
I urldecode my string from the controller, but it somehow doesn’t work. I also tried some iconv() cases, from what I’ve googled, but they also didn’t work.
So the question is why all other browsers except chrome doesn’t retrieve CYRILLIC $_GET variable from the address bar if it was entered from there? Passing through the form everything works fine.
Thanks in advance, guys. Hope for your help.
P.S.
I've also found:
%D0%BD%D0%BE%D1%87%D0%B0%D0%BB%D0%BE
this is passed from the form, accept-charset is set to UTF-8. In that case, as I said, everything works fine. And:
%ED%E0%F7%E0%EB%EE
this comes in the address bar when typing the string directly inside the address bar. So I guess every browser changes my cyrillic symbols into something strange... I don't know :(
Don't forget that with Chrome everything works fine! Maybe it's because by default this browser doesn't encode cyrillic symbols in wrong way like other browsers.
I'm guessing part of the issue here is that you are using UTF-8 characters in the URL ... You can setup PHP to use UTF-8 by default from within the php.ini file or by adding ini_set('default_charset', 'UTF-8'); somewhere in your application, (I add it to the root index.php file within CodeIgniter if I can't modify the .ini file).
I tested both Japanese and your example in Firefox and Safari quickly and they both displayed the correct strings. More information about setting up Apache/PHP for UTF-8 can be found in this excellent guide.

Cookie encoding

I have a problem with cookie encoding. The cookies have some French character inside them. Firefox sends them back correctly, but it seems Chrome has problem with sending them.
Any idea why it happens?
It seems Chrome doesn't support Unicode in its cookies :-/
The correct solution is to
convert the french string to UTF-8 and then
do percent encoding (also known as URL encoding) See http://en.wikipedia.org/wiki/Percent-encoding
This way you can submit any Unicode string via Cookie.
In C# there is a function that does exactly these both things: System.Uri.EscapeDataString()

How to get firefox language setting? (REALLY)

I know this question has been answered before, but the answer given is not the complete story:
I went into Firefox's Options->Content and removed all languages except German/Germany, and navigator.language hasn't changed - it's still en-GB (I'm in the UK).
I'm told if I get the German Firefox INSTALL it will work, but I shouldn't need to do that, right?
The useragent string still contains en-GB, too; but the accept-language on HTTP headers IS set correctly. So this seems to be a bug in Firefox, I spent a bit of time wading through their bugzilla, but I can't see this exact bug logged, though to me it seems a pretty huge oversight?
Both navigator.language and the HTTP User-Agent header use the value of the preference "general.useragent.locale", which is hard-coded in intl.properties to the locale of the Firefox build you downloaded:
http://mxr.mozilla.org/mozilla-central/source/toolkit/locales/en-US/chrome/global/intl.properties#8
Or for your en-GB build:
http://hg.mozilla.org/l10n-central/en-GB/file/88dd673c01f1/toolkit/chrome/global/intl.properties#l8
If you'd like to change it for your build, just load about:config, find general.useragent.locale, double-click it, and change the value.
I would recommend to use a Firefox Add-on for this task. Simple Locale Switcher, Locale Switcher or Quick Locale Switcher etc. (* Caution some of this Add-ons may contain ad ware or may not work if you've just updated firefox).
*Another solution is to download a different old firefox version using the language/locale. (Caution) You need and install it in a different folder so you won't overwrite your existing version. Download here I'm using firefox 28 in Spanish. I disabled updates and I rejected using it as my default browser. Only one firefox version should be running at the same time if you do this.
I would assume that navigator.language returns it's interface language (I assume is GB English), not one that it wants documents in. User-agent string too report which version of firefox was downloaded.
Accept-language is what destination server should check.
I consider this behavior of his quite correct (assuming that it's interface (menus and such) are really in GB english).
in firefore, about:config, modify the value of "intl.accept_languages", to your required locale, let's say de-DE will do.
If you want the Accept-Language value, you can't retrieve if using client-side JavaScript. You'll have to get it from your server.
If you really want this value in client-side JavaScript, then read it on the server and write it back to the client:
<script type="text/javascript">
// setting the accept language HTTP header value
// in client-side JavaScript from PHP
var acceptLanguage = '<?php echo $_SERVER["HTTP_ACCEPT_LANGUAGE"]; ?>';
</script>

Resources