Hi Monks :)
I have a problems with encoding on my web platform.
This app using flat files for database.
When I started to develop , I used this code to open files:
open FH,">$path";
after few weeks we started to get traffic from other countries and names on other languages.
I get broken chars with existing code , and changed it to this only on inputs(>)
open FH , ">:utf8",$file_path; it worked like that few months
The most traffic we get is from 'facebook login' button that uses perl api to get the data.
I recognized that on post forms, perl gets another data with broken chars
I already spent a few days on reading articles about encodings in perl and I still don't get the point how to work with that in the right way
For now I have changed all the inputs and output filehandles to this,because I read that it's the strict UTF in this article http://perlgeek.de/en/article/encodings-and-unicode
open FH, "<:encoding(UTF-8)", "$dir/private_data";
After that I get problems on posts and data that come from facebook, after many tries I got a code that works well. But the problem , that I doesn't understand why it works .. here is the code
if($params{FORM_POST}){$_=decode 'UTF-8',$_ for(@$ref_userdata);}
if($params{FROM_FACEBOOK}){$_=encode 'UTF-8',$_ for(@$ref_userdata
+);}
open WH,">:encoding(UTF-8)","$dir/private_data" or die $!."$dir/pr
+ivate_data";
print WH "$_|" for(@$ref_userdata);
close WH;
Now I see that old database that writen in regular way and old utf8 get a broken chars.
When I doing
cat private_datawith the new :encoding(UTF-8) in putty i get also not right encoding that looks like that
|||�и�о�лава|Ханева|female|03-08-1982|
I feel that I'm like in circle of searchings that will never end
Don't really know what to ask, just need a help with this.
Thanks a lot !!!