Hi
I have a string such as
Добро"
that shows the cyrillic word "?????" in the browser. Now I played around
with lots of examples and contributed functions in the manual
(html_entity_de code, strtr, convert_cyr_str ing ...) but was not able to
decode these entities. As browsers displays them correctly on my PC and Mac
I think I am missing something...
Somebody can point me to the right direction?
(The problem is: A user posts russian text in an application. The text
arrives at the server encoded like that. Now for security reasons the output
is converted with htmlentities(). So I have to decode the russian entities
before re-encoding them.)
Thanks
Markus 10 7741
Markus Ernst <derernst@no#sp #amgmx.ch> wrote: I have a string such as
Добро"
that shows the cyrillic word "?????" in the browser. Now I played around with lots of examples and contributed functions in the manual (html_entity_de code, strtr, convert_cyr_str ing ...) but was not able to decode these entities. As browsers displays them correctly on my PC and Mac I think I am missing something...
Decode them into what?
(The problem is: A user posts russian text in an application. The text arrives at the server encoded like that. Now for security reasons the output is converted with htmlentities(). So I have to decode the russian entities before re-encoding them.)
So don't use htmlentities (I can't imagine any use of it anyway), use
htmlspecialchar s instead.
Daniel Tryba wrote: Markus Ernst <derernst@no#sp #amgmx.ch> wrote: I have a string such as
Добро"
that shows the cyrillic word "?????" in the browser. Now I played around with lots of examples and contributed functions in the manual (html_entity_de code, strtr, convert_cyr_str ing ...) but was not able to decode these entities. As browsers displays them correctly on my PC and Mac I think I am missing something...
Decode them into what?
Into anything that does not contain an ampersand or other special character,
and can be properly displayed or decoded for display. (The problem is: A user posts russian text in an application. The text arrives at the server encoded like that. Now for security reasons the output is converted with htmlentities(). So I have to decode the russian entities before re-encoding them.)
So don't use htmlentities (I can't imagine any use of it anyway), use htmlspecialchar s instead.
That does not make any difference, as both convert Д into
&#1044; - which is exactly the problem.
--
Markus
Markus Ernst wrote: I have a string such as
Добро"
that shows the cyrillic word "?????" in the browser. Now I played
around with lots of examples and contributed functions in the manual (html_entity_de code, strtr, convert_cyr_str ing ...) but was not able
to decode these entities. As browsers displays them correctly on my PC
and Mac I think I am missing something...
Somebody can point me to the right direction? http://in2.php.net/utf8_encode#49336
--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/
Markus Ernst <derernst@no#sp #amgmx.ch> wrote: I have a string such as
Добро" Decode them into what?
Into anything that does not contain an ampersand or other special character, and can be properly displayed or decoded for display.
Ahhh, so why have them encoded in the first place, you know that you can
specify in what character encoding browsers are supposed do send the
characters (see w3)!
So attack your problem at the source:
use a decend encoding (either the proper iso8859-x for
cyrillic, or better yet UTF-8 so you can "mix chactersets"). So don't use htmlentities (I can't imagine any use of it anyway), use htmlspecialchar s instead.
That does not make any difference, as both convert Д into &#1044; - which is exactly the problem.
Doh! :)
Daniel Tryba wrote: Ahhh, so why have them encoded in the first place, you know that you can specify in what character encoding browsers are supposed do send the characters (see w3)!
So attack your problem at the source: use a decend encoding (either the proper iso8859-x for cyrillic, or better yet UTF-8 so you can "mix chactersets").
Thank you, this is definitely the way to go. Anyway, <meta
http-equiv="content-type" content="text/html;charset=ut f-8"> does not make
IE use UTF-8. But when manually settin UTF-8, the characters are actually
transferred unencoded.
For a quick and dirty fix, this did the trick for proper display:
$text = preg_replace("/&#([0-9a-fx]+);/mi", "&#\$1;", $text);
But I will definitely try to go the Unicode way.
--
Markus
Markus Ernst <derernst@no#sp #amgmx.ch> wrote: So attack your problem at the source: use a decend encoding (either the proper iso8859-x for cyrillic, or better yet UTF-8 so you can "mix chactersets"). Thank you, this is definitely the way to go. Anyway, <meta http-equiv="content-type" content="text/html;charset=ut f-8"> does not make IE use UTF-8. But when manually settin UTF-8, the characters are actually transferred unencoded.
When using PHP please don't use those silly http-equiv thingies, use the
real headers instead: header('Content-Type: text/html; charset=UTF-8');
You also might want to add the correct attribute to the form element
(IIRC accept-encoding, but see w3c to be sure).
For a quick and dirty fix, this did the trick for proper display: $text = preg_replace("/&#([0-9a-fx]+);/mi", "&#\$1;", $text);
Nice one, I was wondering if using chr() worked, but this is much nicer
(although still a hack :)
But I will definitely try to go the Unicode way.
_The_ way to go. Take a look at the MultiByte String section of the
manual, setting output and internal encoding to UTF-8 works for me (I
never heard any complaints so far).
"Markus Ernst" <derernst@NO#SP #AMgmx.ch> wrote in message
news:42******** **@news.cyberci ty.ch... For a quick and dirty fix, this did the trick for proper display: $text = preg_replace("/&#([0-9a-fx]+);/mi", "&#\$1;", $text);
The &$xxxx; format accepts decimal, so the a-f part is unnecessary :-)
But I will definitely try to go the Unicode way.
Switching from a single byte charset to a multibyte encoding is a fairly big
change. At the least you're looking at transcoding all your existing data.
Chung Leong wrote: "Markus Ernst" <derernst@NO#SP #AMgmx.ch> wrote in message news:42******** **@news.cyberci ty.ch... For a quick and dirty fix, this did the trick for proper display: $text = preg_replace("/&#([0-9a-fx]+);/mi", "&#\$1;", $text);
The &$xxxx; format accepts decimal, so the a-f part is unnecessary :-)
But I will definitely try to go the Unicode way.
Switching from a single byte charset to a multibyte encoding is a fairly big change. At the least you're looking at transcoding all your existing data.
Thank you for this input - I will work on fixing that whole thing before the
application goes productive and the users begin to submit real text.
--
Markus
Daniel Tryba wrote: When using PHP please don't use those silly http-equiv thingies, use the real headers instead: header('Content-Type: text/html; charset=UTF-8');
Oh - I was proud of having created an application where the proper encoding
for the selected language was automatically used in the http-equiv thingy...
But I admit that from the beginning I was afraid of the moment somebody
decided to make an arab or hebrew or thai web site with it :-) I am working
on a CMS system that can handle an unlimited number of language versions for
every page of the site, but did not think of the possibility of mixing up
languages inside of a page. I am actually lucky that a user of a previous
version of the system tried to do exactly this :-)
You also might want to add the correct attribute to the form element (IIRC accept-encoding, but see w3c to be sure).
I thought I knew really a lot about HTML, but there are still lots of things
to learn (it is accept-charset). For a quick and dirty fix, this did the trick for proper display: $text = preg_replace("/&#([0-9a-fx]+);/mi", "&#\$1;", $text);
Nice one, I was wondering if using chr() worked, but this is much nicer (although still a hack :)
I tried all examples with chr() I found in the manual, and it was
interesting how different the results can be with different operations
performed before or after. There must be conflicts between different
encodings of cyrillic and I doubt that a solution found for those characters
I get would reliably work for cyrillic characters sent from any other
system. But I will definitely try to go the Unicode way.
_The_ way to go. Take a look at the MultiByte String section of the manual, setting output and internal encoding to UTF-8 works for me (I never heard any complaints so far).
I will spend more time on learning about that. Thanks a lot for your inputs.
--
Markus This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Avnish |
last post by:
Hi,
I am looking for some form of validation for all the alphanumeric
characters in the entire unicode range e.g. the validation should also
accept japanese characters but should restrict japanese punctuation
marks. I need this validation for atleast for the CJKT range if not
possible for the entire unicode range. I can even make use of regular
expressions.
Also, please note that this validation should be in Javascript
|
by: Dmitry Krivov |
last post by:
Hi,
Sorry for my english, my native is russian
I have an Oracle-nickname in DB2 UDB 7.2 database, but when
i'm trying to select fields an returning result set
contain ???? instead of cyrillic data.
DB2 7.2 database located on mine W2K server.
Code page of database is set to 1251 and territory RU
Oracle 8.1.7.4 database located on other W2K Server and
it's locale is AMERICAN_AMERICA.CL8MSWIN1251.
|
by: Sakcee |
last post by:
Hi
In one of the data files that I have , I am seeing these characters
\xed\xa0\xa0 . They seem to break the xsl.
---------------------------------------------------------------
Extra content at the end of the document
XML/XSL Error: </data><data ><![CDATA[ í Pls advice
----------------------------------------------------------------
|
by: snapcount |
last post by:
When I enter Cyrillic characters into MySQL, it gets converted to ш or
something. How do I disable this and is there any workaround?
Thanks
|
by: Bruce |
last post by:
The ComboBox has a context menu with an option to "Show Unicode
Control Characters". How can I use that context menu in a RichTextBox
or call that functionality from a RichTextBox? Is there a way to do
that. I'd be surprised if that was missing from RichTextBox and only
available from a ComboBox. I could really use that with RTL Arabic
text.
| |
by: phasma |
last post by:
Hi, I'm trying extract all alphabetic characters from string.
reg = re.compile('(?u)(+)', re.UNICODE)
buf = re.match(string)
But it's doesn't work. If string starts from Cyrillic character, all
works fine. But if string starts from Latin character, match returns
only Latin characters.
Please, help.
|
by: KK |
last post by:
Hello all,
There could be flavors of this question discussed in the past, but I
could not really make a head/tail out of it.
I have bunch of unicode values stored in a string array and I want to
see the corresponding characters displayed in an excel file. How could
I go about doing that ?
vector<stringunicodevalues; // has values 0041, 0042, ... 0410 etc.
(hexa decimal values)
|
by: Shiao |
last post by:
Hello,
I'm trying to build a regex in python to identify punctuation
characters in all the languages. Some regex implementations support an
extended syntax \p{P} that does just that. As far as I know, python re
doesn't. Any idea of a possible alternative?
Apart from manually including the punctuation character range for each
and every language, I don't see how this can be done.
Thank in advance for any suggestions.
|
by: Jams Quiden |
last post by:
I have a ESRI personal geodb with Cyrillic, chinese and arabic characters that will not, no matter what client encoding I choose, transfer nicely to PostGIS db. I am using ogr2ogr tools. I am on a windows 7 64 box running 32 bit software (Office 2007, Postgres 1.12.0, with FWtools.) PostGIS db is UTF8 encoding. default for client is the same. I have tried all Cyrillic encodings within FW and PG. I have tried several others as well all to no...
|
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s 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: 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...
|
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: 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: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |