473,782 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert latin-1 characters to named HTML entities?


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.

I am currently using FreeTextBox, but while it seems to
convert some characters (<, >, ...), others are left alone
and need to be converted separately.

I cannot use Response.Write or similar: I am taking freeform
input from FreeTextBox and normal textboxes and creating
static HTML files for later use, using String.Replace.

Basically, I need something that will convert the first column
to the third in
http://msdn.microsoft.com/workshop/a...s/charset1.asp
but if there is already something in the framework for this purpose
I would feel silly writing my own (probably slower) function.

TIA,

Joergen Bech

Nov 19 '05 #1
2 2669
Joergen Bech wrote:

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

&aelig;
&oslash;
&aring;

etc.

I am currently using FreeTextBox, but while it seems to
convert some characters (<, >, ...), others are left alone
and need to be converted separately.

I cannot use Response.Write or similar: I am taking freeform
input from FreeTextBox and normal textboxes and creating
static HTML files for later use, using String.Replace.

Basically, I need something that will convert the first column
to the third in
http://msdn.microsoft.com/workshop/a...e/charsets/cha
rset1.asp but if there is already something in the framework for this
purpose I would feel silly writing my own (probably slower) function.


Do you really need character references, or will numeric references
work for you as well (they should)?

System.Web.Http Utility.HtmlEnc ode() and
System.Web.Http ServerUtility.H tmlEncode() (which calls the other one)
do that trick. You may find though that the encoded output uses both
character and numeric references (see http://tinyurl.com/9bq6g).

Cheers,
--
http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e
Nov 19 '05 #2
On Mon, 13 Jun 2005 13:25:41 -0700, "Joerg Jooss"
<ne********@joe rgjooss.de> wrote:
Joergen Bech wrote:

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

&aelig;
&oslash;
&aring;

etc.

I am currently using FreeTextBox, but while it seems to
convert some characters (<, >, ...), others are left alone
and need to be converted separately.

I cannot use Response.Write or similar: I am taking freeform
input from FreeTextBox and normal textboxes and creating
static HTML files for later use, using String.Replace.

Basically, I need something that will convert the first column
to the third in
http://msdn.microsoft.com/workshop/a...e/charsets/cha
rset1.asp but if there is already something in the framework for this
purpose I would feel silly writing my own (probably slower) function.


Do you really need character references, or will numeric references
work for you as well (they should)?

System.Web.Htt pUtility.HtmlEn code() and
System.Web.Htt pServerUtility. HtmlEncode() (which calls the other one)
do that trick. You may find though that the encoded output uses both
character and numeric references (see http://tinyurl.com/9bq6g).

Cheers,


Thanks. I'll try. Trouble is, I would like everything to be named
html entities (for other reasons). I'll have to use HTMLEncode if a
few custom string replacements turn out to insufficient.

Sure am surprised, though, that it seems so hard to find a
function for this purpose (in .Net). Something like:
http://maconlinux.net/linux-man-page...ntities.3.html

The Microsoft.Share Point.Utilities .SPEncode class sounds useful,
but not to me, as this is not a SharePoint application.

I'll have to investigate the possibilities later.

Regards,

Joergen Bech

Nov 19 '05 #3

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

Similar topics

23
25950
by: Hallvard B Furuseth | last post by:
Has someone got a Python routine or module which converts Unicode strings to lowercase (or uppercase)? What I actually need to do is to compare a number of strings in a case-insensitive manner, so I assume it's simplest to convert to lower/upper first. Possibly all strings will be from the latin-1 character set, so I could convert to 8-bit latin-1, map to lowercase, and convert back, but that seems rather cumbersome.
4
6314
by: Uwe Mayer | last post by:
Hi, in a PyQt application I'm writing, the user can select a filename with a FileDialog. Then I would like to open this file. This works fine if there are no "special symbols" in the filename, such as the german umlauts: "ÖÄÜ" Currently I convert the returned, of what I'm pretty sure its a utf-8 string object, to a normal string using the str() function. But then my string contains garbage and I cannot find that file on my ext3 fs...
30
8678
by: John Carroll | last post by:
Does anyone have a function or procedure for converting integers to character strings? Thank you, John
4
2602
by: Trond Hoiberg | last post by:
I was wondering if someone in here knows if it is possible to convert a letter (a, b, c....) to the ISO Latin-1 Character Set Decimal code? a= a b=b c=c I know it is possible but i was looking for a way to do it by using the Framework. Some utility that returns the Decimal code from the mentioned Character Set if input is a character like 1, 2..a, b ... and so on. Best regards
7
3146
by: manstey | last post by:
Hi, How do I convert a string like: a="{'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'}" into a dictionary: b={'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'} Thanks, Matthew
10
22832
by: ahoway | last post by:
I am having problems entering a sentence for translating into pig latin. It is set up now to read the entire sentence as one word. I would like to know how to look at each word in the sentence so that each word is translated to Pig latin seperately. Attached is my code: Thank you for your time. the out put for hello world comes out :ello worldhay I want it to say: ellohay orldway // testpig.cpp : Defines the entry point for the...
2
2747
by: tgirard | last post by:
Hello to all Before I pull all my hair out... I have a problem with a text string (actually read in from a cell-phone appointment sent to the computer) which has a 'strange' utf-8 encoding. Let me give an example: CHARSET=UTF-8:Aftenarr.=20med=20Fl.=20Th=C3=B8gersen Now I need to convert this into latin. I tried to replace all the '=' into '\x'. doing this by regex I have to use \\x$1 as a substitute, but then the string is not...
29
5087
by: Harlin Seritt | last post by:
Hi... I would like to take a string like 'supercalifragilisticexpialidocius' and write it to a file in binary forms -- this way a user cannot read the string in case they were try to open in something like ascii text editor. I'd also like to be able to read the binary formed data back into string format so that it shows the original value. Is there any way to do this in Python? Thanks!
15
8348
by: Lyosha | last post by:
Converting binary to base 10 is easy: 255 Converting base 10 number to hex or octal is easy: '0144' '0x64' Is there an *easy* way to convert a number to binary?
1
1688
by: Helmut Jarausch | last post by:
Hi, I'm trying to teach "dugui.py" (a tiny GUI for restructuredtext written in wxPython) to accept files in isolatin-1 encoding. It displays e.g. German umlauts correctly but then I get a popup window saying Python Error Cannot convert from the charset 'latin-1'! How can I find out where this did come from. Running it under pdb isn't helpful either.
0
9479
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,...
0
10311
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...
1
10080
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
9942
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
8967
agi2029
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 project—planning, coding, testing, and deployment—without 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...
1
7492
isladogs
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...
0
5378
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
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2874
bsmnconsultancy
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...

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.