472,791 Members | 1,331 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 software developers and data experts.

convert html entities into real chars


Hi,

I would like to have a function that can convert '>' into '>',
'&' into '&' etc. I could not find how to do it easily (I have a
code snippet for the opposite).
Thanks,

Laszlo

Apr 10 '07 #1
2 1864
Laszlo Nagy wrote:
>
Hi,

I would like to have a function that can convert '>' into '>',
'&' into '&' etc. I could not find how to do it easily (I have a
code snippet for the opposite).
Thanks,

Laszlo
You can use htmlentitydefs module to help with this.

import htmlentitydefs

chr(htmlentitydefs.name2codepoint['gt'])

and (to go the other way)

htmlentitydefs.codepoint2name[ord('>')]

-Larry
Apr 10 '07 #2
Laszlo Nagy wrote:
>
Hi,

I would like to have a function that can convert '>' into '>',
'&' into '&' etc. I could not find how to do it easily (I have a
code snippet for the opposite).
Thanks,

Laszlo
You can use htmlentitydefs module to help with this.

import htmlentitydefs

chr(htmlentitydefs.name2codepoint['gt'])

and (to go the other way)

htmlentitydefs.codepoint2name[ord('>')]

-Larry
Apr 10 '07 #3

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

Similar topics

2
by: micha | last post by:
my php script gets delivered text that contains special chars (like german umlauts), and these chars may, may partially or may not be coverted into html entities already. i don't know beforhand. ...
6
by: Horst Gutmann | last post by:
Hi :-) I currently have quite a big problem with minidom and special chars (for example ü) in HTML. Let's say I have following input file:...
3
by: Himanshu Garg | last post by:
Hello, I am trying to pinpoint an apparent bug in HTML::Parser. The encoding of the text seems to change incorrectly if the locale isn't set properly. However Parser.pm in the directory...
2
by: Christian Reuter | last post by:
Hallo, ich have a big problem. I have a Text which contains some characters like  But my Browser doesnt display it. Does anyone know the reason and how i can fix it? Thanks Jan
3
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...
2
by: Joergen Bech | last post by:
Is there a function in the .Net 1.1 framework that will take, say, a string containing Scandinavian characters and output the corret HTML entities, such as æ ø å etc.
2
by: Albert | last post by:
How can I convert some html entities (polish) to a character which I can use in a javascript alert? The entities are: ń ę ń ą ż ś ć
1
by: Robert Dodier | last post by:
Hello, Sorry for asking what must be a FAQ, but I wasn't able to find the answer. I have an XML document fragment which I want to store as a text string. I want a function to convert any XML...
8
by: Steven D'Aprano | last post by:
I have a string containing Latin-1 characters: s = u" and many more..." I want to convert it to HTML entities: result => "© and many more..." Decimal/hex escapes would be...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.