473,657 Members | 2,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can recode_string auto-convert to UTF-8?




When I discovered this page:

http://us2.php.net/recode_string

I thought this function might solve my problems.

This page says recode_string understands the UTF-8 charset:

http://www.delorie.com/gnu/docs/recode/recode_30.html

I came up with a little test, you can see the code below, and I put it
up on my server:

http://www.publicdomainsoftware.org/testRecode.php

Sadly, my server doesn't seem to have the function recode_string
built-in with PHP. We are leasing a server from Rackspace. I could ask
them to rebuild PHP with that function in it, at a cost of like $120,
but I'd like to know if it would work first.

I wanted to write some very strange characters in a Microsoft Word
document, using every rare and bizzare character I could find, then I'd
copy and paste that to the textarea in the form below, and then I'd see
if it could be output without garbage characters as UTF-8.

But, sadly, I can't run the test on my server. So does anyone know if
this would work?

<?php
$textToTest = $_POST["textToTest "];
$formSubmitted = $_POST["formSubmit ted"];

if ($formSubmitted ) {
if ($textToTest) {
if (function_exist s("headers_sent ")) {
$sent = headers_sent();
if (!$sent) header("Content-type:text/html;charset=UT F-8");
}
if (function_exist s("recode_strin g")) {
$result = recode_string(" UTF-8", $textToTest);
} else {
echo "<p>functio n doesn't exist ";
}
echo "<p>here is the resulting text:</p> <p>$result</p> ";
} else {
echo "couldn't find the text ";
}

}
?>


<form method="post" action="testRec ode.php">
<p>type words here:</p>
<textarea name="textToTes t"> Type something here </textarea>

<br><br>
<input type="hidden" name="formSubmi tted" value="true">

<input type="submit">
</form>

Jul 17 '05 #1
2 2883
On 27 May 2005 13:08:32 -0700, lk******@geocit ies.com wrote:
When I discovered this page:

http://us2.php.net/recode_string

I thought this function might solve my problems.
Which problem?
This page says recode_string understands the UTF-8 charset:

http://www.delorie.com/gnu/docs/recode/recode_30.html

I came up with a little test, you can see the code below, and I put it
up on my server:

http://www.publicdomainsoftware.org/testRecode.php

Sadly, my server doesn't seem to have the function recode_string
built-in with PHP. We are leasing a server from Rackspace. I could ask
them to rebuild PHP with that function in it, at a cost of like $120,
but I'd like to know if it would work first.

I wanted to write some very strange characters in a Microsoft Word
document, using every rare and bizzare character I could find, then I'd
copy and paste that to the textarea in the form below, and then I'd see
if it could be output without garbage characters as UTF-8.
Remember the Joel article you posted? It's all down to the key sentence in
there; if you don't know the original encoding of your data you are stuffed.
But, sadly, I can't run the test on my server. So does anyone know if
this would work?

if (function_exist s("recode_strin g")) {
$result = recode_string(" UTF-8", $textToTest);


recode_string converts from one encoding to another.

You've specified just one encoding. What's it supposed to do? From a brief
read of the manual it seems to default to Latin-1 a.k.a ISO-8859-1 if you don't
specify one of the encodings.

If it's not in ISO-8859-1 in the first place, the results won't be "correct".

This function doesn't seem any different, as far as I can see, to
http://uk.php.net/manual/en/function...t-encoding.php except it's more
obscure.

--
Andy Hassall / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
My apologies. I didn't read it well enough. As you say, "if you don't
know the original encoding of your data you are stuffed"

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2599
by: Manlio Perillo | last post by:
Hi. This post follows "does python have useless destructors". I'm not an expert, so I hope what I will write is meaningfull and clear. Actually in Python there is no possibility to write code that follows C++ RAII pattern. Of course Python objects are not statics like in C++, but in C++ the auto_ptr class is used for enforcing this pattern for dynamical
1
13953
by: Glabbeek | last post by:
I'm changing the layout of my site. Instead of using tables, I will use DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not the correct width. Mozilla and Opera are showing the page the way I want. Does anybody know a solution for this? First of all, the code I am using: CSS ------- body {
5
6100
by: Robert Downes | last post by:
I'm using the following in a page that I'm testing in Mozilla: p.actionLinkBlock {border: 1px #000000 dashed; padding: 0.2cm; width: auto} But the dashed border is extending to the right-edge of the screen. I want it to only extend as far as it needs to to nicely contain the content within (a couple of links). Is width: auto the wrong property to do this? Is Mozilla rendering the style wrong?
20
2855
by: Vijay Kumar R. Zanvar | last post by:
Hello, Unlike register, auto keyword can not be used to declare formal parameter(s). Is there any specific reason for this? Kind regards, Vijay Kumar R. Zanvar
6
5062
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I do with the 1st column ? (Below I have a "1" in place for now). Also, Does the datase.AcceptChanges(); updates the changes to the database? Which command do I use to update the changes in dataset back to the Access database table? Thanks, Alpha...
5
5037
by: Samuel | last post by:
Hi, I am running into a problem of mixing UICulture = auto and allowing users to select culture using a dropdown list. I am detecting a querystring, "setlang", and when found, setting the CurrentUICulture to what's specified in the querystring. Since I want to allow UICulture auto detecting, I add UICulture = "auto" to page directive on each page.
5
3263
by: maya | last post by:
at work they decided to center divs thus: body {text-align:center} #content {width: 612px; text-align:left; margin: 0 auto 0 auto; } this works fine in IE & FF, EXCEPT in FF it doesn't work if I change 'auto' to 0 for left and right margin values; I have to leave those at 'auto'.. so I would like to know what exactly means 'auto' -- what value it represents exactly (and does it apply for all elements/values you might apply 'auto' to?)
22
3062
by: nospam_news | last post by:
I currently get asked about my usage of "auto". What is it for? The keyword is clearly superflous here. In contrast to the huge majority of C/C++ developers I write definitions very explicitly like that: int main(char argc, char *argv, char *env) { try { auto Exception mainException(1); mainException.setErrNo(42);
2
3064
by: Piotr K | last post by:
Hi, I've encountered a strange problem with Firefox which I don't have any idea how to resolve. To the point: I've <divelement with a style "height: auto" and I want to retrieve this value ("auto") in JavaScript - however instead of getting "auto" value, I get calculated height. In IE and Opera it simply returns "auto". Any ideas how to check in Firefox if element height was set to "auto" ? I'll be grateful for any help.
21
6331
by: JOYCE | last post by:
Look the subject,that's my problem! I hope someone can help me, thanks
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.