I have a text like this: "Thuyền Và Biển"
How to convert it to: "Thuyền V* Biển"
Please help! 7 2542
ngocviet wrote: I have a text like this: "Thuyền Và Biển" How to convert it to: "Thuyền V* Biển" Please help!
This is the same question that McHenry asked today.
The answer is simple: use html_entity_dec ode():
<?php
echo html_entity_dec ode('Thuyền Và Biển');
?>
HTH.
Ruben.
It work when out in brower! But when I save to file, nothing change! :)
Ruben van Engelenburg wrote: This is the same question that McHenry asked today. The answer is simple: use html_entity_dec ode():
<?php echo html_entity_dec ode('Thuyền Và Biển'); ?>
HTH. Ruben.
ngocviet wrote: I have a text like this: "Thuyền Và Biển" How to convert it to: "Thuyền V* Biển" Please help!
What text char-set/encoding do you want the text to be?
I want to convert it to UTF-8 encoding
Chung Leong wrote: ngocviet wrote: I have a text like this: "Thuyền Và Biển" How to convert it to: "Thuyền V* Biển" Please help! What text char-set/encoding do you want the text to be?
ngocviet wrote: I want to convert it to UTF-8 encoding
Chung Leong wrote: ngocviet wrote: I have a text like this: "Thuyền Và Biển" How to convert it to: "Thuyền V* Biển" Please help!
What text char-set/encoding do you want the text to be?
You will have to do it manually using preg_replace_ca llback(), as I
don't believe html_entity_dec ode() is capable of decoding such
entities. Here're the basics:
$text = preg_replace_ca llback('/&#(d+);/',
'numeric_html_e ntity_replace', $text);
function numeric_html_en tity_replace($m ) {
$unicode = (int) $m[1];
$utf8 = /* encode the Uncode value */
return $utf8
}
The tricky part is converting the Unicode value to a UTF-8 string.
"Chung Leong" <ch***********@ hotmail.com> wrote in message
news:11******** **************@ y41g2000cwy.goo glegroups.com.. . You will have to do it manually using preg_replace_ca llback(), as I don't believe html_entity_dec ode() is capable of decoding such entities. Here're the basics:
$text = preg_replace_ca llback('/&#(d+);/', 'numeric_html_e ntity_replace', $text);
function numeric_html_en tity_replace($m ) { $unicode = (int) $m[1]; $utf8 = /* encode the Uncode value */ return $utf8 }
The tricky part is converting the Unicode value to a UTF-8 string.
There's a solution for that at php.net http://fi.php.net/manual/en/function.chr.php#55978
chr seems to be ASCII-only (which is kinda stupid if you think about it,
plenty of utf implementations these days) but "grey" had written a
workaround for it.
--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk sp**@outolempi. net | Gedoon-S @ IRCnet | rot13(xv***@bhg byrzcv.arg)
Thanks Kimmo Laine!
It solves my problem!
Code:
function unichr($dec)
{
if ($dec < 128) {
$utf = chr($dec);
} else if ($dec < 2048) {
$utf = chr(192 + (($dec - ($dec % 64)) / 64));
$utf .= chr(128 + ($dec % 64));
} else {
$utf = chr(224 + (($dec - ($dec % 4096)) / 4096));
$utf .= chr(128 + ((($dec % 4096) - ($dec % 64)) / 64));
$utf .= chr(128 + ($dec % 64));
}
return $utf;
}
$str = "Thuyền Và Biển";
$str = preg_replace("/&#(\d{2,5});/e", "unichr($1) ;", $str);
echo $str;
Kimmo Laine wrote:
There's a solution for that at php.net
http://fi.php.net/manual/en/function.chr.php#55978
chr seems to be ASCII-only (which is kinda stupid if you think about it,
plenty of utf implementations these days) but "grey" had written a
workaround for it.
--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk sp**@outolempi. net | Gedoon-S @ IRCnet | rot13(xv***@bhg byrzcv.arg)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: hunterb |
last post by:
I have a file which has no BOM and contains mostly single byte chars. There
are numerous double byte chars (Japanese) which appear throughout. I need to
take the resulting Unicode and store it in a DB and display it onscreen. No
matter which way I open the file, convert it to Unicode/leave it as is or
what ever, I see all single bytes ok, but double bytes become 2 seperate
single bytes. Surely there is an easy way to convert these mixed...
|
by: Convert TextBox.Text to Int32 Problem |
last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function and there you have it. So I enquired and found the Convert class with it's promising ToInt32 method, great... but it doesn't work. The thing keeps throwing Format Exceptions all over the place. What is the "C#" way to do this??? code
int wmin,...
|
by: Serge Klokov |
last post by:
Hello!
I have a Oracle table with a BLOB field.
Each field is actually a simple text file of several lines.
How to get this BLOB fields in readable format?
I tryied something like
row.ToString()
But it give result "System.Byte" instead of actual text...
|
by: Jan Eliasen |
last post by:
Hi
I have a string, which I must convert into another string and have it
utf-8 encoded.
My current code looks like this;
Both vDataIn and vDataOut are Objects (parameters to a function-call),
and vDataIn contains a string, and that is also what vDataOut must
contain when I am done.
|
by: Nikolay Petrov |
last post by:
How can I convert DOS cyrillic text to Unicode
| |
by: Socrates |
last post by:
I am interested in developing an online utility that will enable users
to
copy and past any image (or upload any image on the internet) to the
online utility, which will then convert the image to text.
The user may "convert image to text" and copy and paste the text
displayed into any word document, or send the text displayed to the
recipient's email address or can download the text file as a zipped
text file that will be presented to...
|
by: Edwin Knoppert |
last post by:
In my code i use the text from a textbox and convert it to a double value.
I was using Convert.ToDouble() but i'm used to convert comma to dot.
This way i can assure the text is correct.
However it seems this convert is determined by the local settings and comma
is indeed used as decimal separator.
Is there another way to convert a dotted value to a double variable?
Like 1234.5 and not 1234,5
|
by: comp.lang.tcl |
last post by:
My TCL proc, XML_GET_ALL_ELEMENT_ATTRS, is supposed to convert an XML
file into a TCL list as follows:
attr1 {val1} attr2 {val2} ... attrN {valN}
This is the TCL code that does this:
set contents ]; close $fileID
|
by: mrajanikrishna |
last post by:
Hi Friends,
I am accepting a number from the user entered in a textbox.
I want to assign to a variable in my code and assignt this to that
variable.
double num1 = (double)txtNum1.text;
this produced an error
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
|
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |