I've some problems with charset encode/decode probably. Will try to describe as much detailed as I can (btw - there's custom cms with some kind GWC framework - using php), so when user registering in CMS and filling all required fields (like First name, Last name and etc.), he's inserting symbols like "ĄČĘĮŠĘŠŲŽŪĖ", in database inserting value like: "Äesnakas", but that should be inserted like "Česnakas". But that isn't everything - when administrator (on CMS) see values which are got from database - it shows correctly (Česnakas).
Tried to look how it's converting back from wrong charset to right one, didn't found anything (was looking by iconv function and etc.), also, my searching was much more harder because half of cms files was encrypted and unreadable.
In some places was inserted header with charset UTF-8 and Windows-1257, but that didn't helped me a lot.
I tried these ways to convert all characters to correct ones:
Changed in DB row collation (from latin1_swedish.. to utf8_general_ci; utf8_unicode_520 (and _ci)) - didn't helped. Exported from DB and tried to convert with excel all data in UTF-8 charset - still got these wrong characters. (Tried few ways, and few different charsets)
The main question - is it possible (if it is - how?) to convert these characters in DB? Otherwise if it's not, how to recognize how framework decoding all characters and showing right characters in case to build function which one would get all data from database - decode it (to right symbols), store it into database in right charset (like: get -> convert -> send it back where it came from -> save).
Code in registration (with insert into function):
function RegistrationAdd () {
if (($GLOBALS[fmMemberFirstName] != "") && ($GLOBALS[fmMemberLastName] != "") && ($GLOBALS[fmMemberPhone1] != "")) {
if (CheckCaptcha ($GLOBALS[captcha])) {
if (checkemail($GLOBALS[fmMemberMail])) {
mysql_select_db($GLOBALS["DBName"]);
$new_pass = GenerateKey(8);
$strQuery = "INSERT INTO gwc_members VALUES ('','".$GLOBALS[fmMemberLogin]."','".md5($new_pass)."','".$GLOBALS[fmMemberMail]."','".$GLOBALS[fmMemberFirstName]."','".$GLOBALS[fmMemberLastName]."','".$GLOBALS[fmMemberPhone1]."','".$GLOBALS[fmMemberPhone2]."','".$GLOBALS[fmMemberAddress1]."','".$GLOBALS[fmMemberAddress2]."','".$GLOBALS[fmMemberZipCode]."','".$GLOBALS[fmMemberCity]."','".$GLOBALS[fmMemberCountry]."','".$GLOBALS[fmMemberJob]."','".$GLOBALS[fmMemberImone]."','".$GLOBALS[fmMemberKodas]."','".$GLOBALS[fmMemberPvm]."','".$GLOBALS[fmMemberAdresas1]."','".$GLOBALS[fmMemberAdresas2]."','".$GLOBALS[fmMemberTelefonas]."','4', '".$GLOBALS[fmMemberValiuta]."', '".date ('Y-m-d H:i:s')."','1','0')";
mysql_query($strQuery);
echo "<br>
<table border=\"0\" width=\"100%\" align=\"center\" cellspacing=\"1\" cellpadding=\"2\">
<tr>
<td width=\"100%\" valign=\"top\" align=\"center\">Welcome message<br />E-mail $GLOBALS[fmMemberMail]</td>
</tr>
</table>
<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"3;URL=index.php?langid=$GLOBALS[GP_langid]&stepto=memberarea&page=login\">
";
} else {
echo "<br>
<table border=\"0\" width=\"100%\" align=\"center\" cellspacing=\"1\" cellpadding=\"2\">
<tr>
<td width=\"100%\" valign=\"top\" align=\"center\"><font color=\"red\">".lang_2070."</font><br /><br />
<a href=\"javascript:history.back()\">".lang_2071."</a></td>
</tr>
</table>
";
}
} else {
echo "<br>
<table border=\"0\" width=\"100%\" align=\"center\" cellspacing=\"1\" cellpadding=\"2\">
<tr>
<td width=\"100%\" valign=\"top\" align=\"center\"><font color=\"red\">".lang_2080."</font><br>
<a href=\"javascript:history.back()\">".lang_2071."</a>
</td>
</tr>
</table>
";
}
} else {
echo "<br>
<table border=\"0\" width=\"100%\" align=\"center\" cellspacing=\"1\" cellpadding=\"2\">
<tr>
<td width=\"100%\" valign=\"top\" align=\"center\"><font color=\"red\">".lang_2072."</font><br /><br />
<a href=\"javascript:history.back()\">".lang_2071."</a>
</td>
</tr>
</table>
";
}
}
Page where member info can be viewed (and show's characters correctly):
function MemberView ()
{
echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">
<tr>
<td width=\"100%\" valign=\"top\" align=\"center\" class=\"ActionNameTitle\">[ Kliento informacija ]</td>
</tr>
</table>
";
$strQuery = "SELECT * FROM gwc_members where member_id='".$GLOBALS[GP_memberid]."'";
mysql_select_db($GLOBALS["DBName"]);
$result = mysql_query($strQuery);
while ($rs = mysql_fetch_array ($result)) {
$usergroup = $rs["usergroup"];
echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" class=\"RecordListBox\">
<tr>
<td width=\"200\" valign=\"top\">Vardas, pavardė</td>
<td width=\"*\" valign=\"top\">$rs[member_firstname] $rs[member_lastname]</td>
</tr>
</table>
<br>
";
}
mysql_free_result ($result);
}
Some kind name generation:
function GenerateName($count) {
mt_srand((double)microtime()*1000000);
$key = "";
for ($i=0; $i<$count; $i++) {
$c = mt_rand(0,2);
if ($c==0) {
$key .= mt_rand(0,9);
} elseif ($c==1) {
$key .= mt_rand(0,9);
} else {
$key .= mt_rand(0,9);
}
}
return $key;
}
Appreciate for reading (if you read all this long, boring story), and for answers (if somebody bother to answer at least something). Thank you!