Jump to content

timski72

New Members
  • Posts

    8
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

timski72's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes. I hadn't at the time that I made the screenshot but now the code includes this line mb_internal_encoding("UTF-8"); but still the content is being 'corrupted'. Thanks, Tim.
  2. Hi Guys, I was using mb_ereg_replace in a script. It was using it to convert Greek characters to their latin ahplabet equivalent. That was working fine. Then I moved it to a function in a new script and now it doesn't seem to work. The following lines of code: $input = "η φιλι"; $input = mb_ereg_replace("τζ", "dz", $input); used to leave $input untouched as "τζ" doesn't appear in $input. However when I moved this to a function $input was changed by this line of code. I've pasted some screenshots that I made whilst debugging this in phpDesigner to show what I mean. OK this is a little difficult to show as the Greek characters show as goggledegook in the debugger but the first screenshot shows that I set $input to "η φιλι" which shows as I've highlighted in yellow in the screenshot below in the debugger. If you echo $input it shows as "η φιλι". I'm not sure why it shows as highlighted in yellow below in the debugger but that's not the problem. I presume phpDesigner doesn't display unicode properly. Anyway, once the content of $input has passed through mb_ereg_replace within the same script you can see the content has remained the same (see below). This is as expected as "τζ" isn't present in $input. However, once I moved this code to a new script and put it in a function it behaved differently (see below). As you can see I've set $input to "η φιλι" again and that is the same as above. Now though when it passes into the function it starts out ok, i.e. the content of $input is still the same. However, once I step over that line of code and $input goes through mb_ereg_replace the content is changed as below. As "τζ" doesn't appear in $input I would expect it to remain unchanged as it did when this line of code was in a single script. I don't understand why this has changed by moving it to a new script and function? Any help would be very welcome. Thank you, Tim.
  3. Thank you so much. I wouldn't have spotted it. Sometimes you can't see the wood for the trees :-) Works great now :-)
  4. Thanks for you reply. I modified the code incorporating your suggestions as below. $syllabilized is still blank. Tim. <?php ini_set('default_charset', 'UTF-8'); mb_internal_encoding("UTF-8"); // $input = $_POST['greek']; $input = "η μητερa"; $connection = mysqli_connect($host, $user, $passwd, $dbname) or die(mysqli_error()); mysqli_set_charset($connection, "utf8"); $query = "SELECT syllabilized FROM transliterated WHERE requested = '$input'"; $result = mysqli_query($connection, $query) or die($query); if (!$result) { // NO CODE FOR THIS SECTION YET } else { $row = mysqli_fetch_row($result); $syllablized == $row[0]; echo syllablized; ?>
  5. Hi Guys, I have a test database with a record in it where the field "requested" is set to "η μητερa" (Greek characters, i.e. unicode) If I perform the following query in phpMyAdmin "SELECT syllabilized FROM transliterated WHERE requested = η μητερa" I get the expected result. This query doesn't seem to be working within my php script however. I am not sure if it is due to my php code (which is very newby) or a problem with de/encoding unicode. Here is the my scripts (truncated) with the $input hardcoded for testing. I've tested with $_POST['greek'] posting from the website and hardcoded when debugging in phpDesigner but neither is working. I get a result so it goes into the else statement but the output is blank. <?php ini_set('default_charset', 'UTF-8'); mb_internal_encoding("UTF-8"); // $input = $_POST['greek']; $input = "η μητερa"; $connection = mysqli_connect($host, $user, $passwd, $dbname) or die(mysqli_error()); $query = "SELECT syllabilized FROM transliterated WHERE requested = '$input'"; $result = mysqli_query($connection, $query) or die($query); if (!$result) { // NO CODE FOR THIS SECTION YET } else { $row = mysqli_fetch_row($result); $syllablized == $row[2]; $input == $syllablized; echo $input; } ?> Here is the content and structure of the database. requested generated syllabilized modified create edit η μητερa ee meetehrah ee mee-teh-rah No 18/02/2010 16:45 19/02/2010 16:46 So I'm expecting the user to enter η μητερa and get ee mee-teh-rah back. Any tips would be very welcome. Thanks, Tim.
  6. Some of the suggestions in that article were useful. Also, I realised that I had file encoding set to ANSI in my PHP editor. Set this to UTF-8 and things seem to be working fine now.
  7. I've read that article through and it looks like that could resolve my issue. I'll implement the suggestions and, if successful, mark the post as resolved. Cheers, Tim.
  8. Hello everyone. I want to write a script that will transcribe a Greek word into the Latin alphabet, so users who can't read the Greek alphabet will have some idea of how the word is pronounced. For example, a user might enter the Greek word "Καλημέρα" into a form, click on the "Transcribe" button and it will return "kalee mera". Putting it rather too simply, but so you understand what I'm trying to achieve, most sounds of the Greek alphabet map to a sound of the Latin alphabet. E.g. "β" sounds like "v" so I map accordingly. Π sounds like "p", "ξ" sounds like "kse" etc. I did this before in C# express, but when I tried to reproduce this script in PHP I came across a problem. I noticed that I was getting gibberish from the word entered in the form, i.e. in the $_POST['greek']. Php obviously doesn't like unicode. I had a look on the web and there is a lot of discussion about PHP not fully supporting PHP until version 6. Being a novice, I found some of the discussion a bit overwhelming, so before embarking on what might be an impossible mission, I thought I'd ask some advice first. So, first and foremost, is it possible, or am I wasting my time? Second, is anyone able to give me any pointers? My current host has PHP 5.25 running. I have tried adding the following to the html as one post did suggest this might solve the problem, at least I think that's what they were suggesting ;-) <meta http-equiv=”Content-Language” content=”bn”> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ > Any advice would be much appreciated :-) Cheers, Tim.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.