Hi,
I have an ASP.Net website, which allows users to upload a file which is
then inserted into a database.
This is all fine until it reads a line with the string +Anu in it.
It transforms this to this char É» (which, if Googled for, is
described as Unicode Character 'LATIN SMALL LETTER TURNED R WITH HOOK'
(U+027B) or, in Phonetics, as a 'Retroflex approximant'.)
Has anyone seen this behaviour before, and know how to stop it?
The code's simple - here's an example. The É» appears in the output
where the input is +Anu - it's transformed before I can touch it!
using (StreamReader sr = new StreamReader(st rFile,
System.Text.Enc oding.UTF7)) {
// Read and display lines from the file until the end of the file is
reached.
while ((line = sr.ReadLine()) != null) {
Response.Write( line);
}
}
Regards
Adam 6 1746
And is this file actually UTF7? Perhaps you should be doing raw binary
transfers?
Also - you are doing ReadLine and Write, so you may already be losing some
end-of-line characters... not 100% sure...
Marc
Graven,
I'm not sure how a 4 letter string like this could be seen as an
encoding issue, but I will certainly give it a go. Thanks for the
suggestion.
Adam
Graven wrote:
Try to use plain latin-1 encoding. I think it's an unicode
normalization issue, but don't know if StreamReader performs it by
default. Cy**********@gm ail.com wrote:
Hi,
I have an ASP.Net website, which allows users to upload a file which is
then inserted into a database.
This is all fine until it reads a line with the string +Anu in it.
It transforms this to this char É» (which, if Googled for, is
described as Unicode Character 'LATIN SMALL LETTER TURNED R WITH HOOK'
(U+027B) or, in Phonetics, as a 'Retroflex approximant'.)
Has anyone seen this behaviour before, and know how to stop it?
The code's simple - here's an example. The É» appears in the output
where the input is +Anu - it's transformed before I can touch it!
using (StreamReader sr = new StreamReader(st rFile,
System.Text.Enc oding.UTF7)) {
// Read and display lines from the file until the end of the file is
reached.
while ((line = sr.ReadLine()) != null) {
Response.Write( line);
}
}
Regards
Adam
Larry,
You were spot on - changing to UTF8 stopped this transformation. Thanks
It's not quite solved my problem though.
The file is a Text file, each line being a series of files delimited by
the ¦ character, as this was unliekley to ever appear in the actual
data.
Unfortunately, UTF8 encoding strips these characters completely. ASCII
encoding, on the other hand, replaces them with ?
Oh the joy of character encoding.
Regards
Adam
Larry Lard wrote:
This is why you are seeing what you are seeing. UTF7 encodes characters
outside the printable 7 bit range using UTF16 then modified base64, with
+ as the indicator mark for this encoding. I haven't checked, but I
imagine +Anu is the UTF7 encoding of that character. You shouldn't use a
UTF7 reader to read a file that you don't know for sure was produced by
a UTF7 writer.
The correct way to read the file depends on what kind of file it is. If
it is text of an unknown encoding, there is no way to be absolutely
sure, but UTF8 is a good starting point. If it's binary data, you
shouldn't be using a TextReader class at all.
The reader should have no problem with this character - are you sure this is
the issue? And are you sure of the contents of the file? (perhaps read it in
a hex editor to see what is actually there).
If we are talking about the same "pipe" character, then both the ASCII and
UFT8 representation is hex 7C (single byte); UFT7 has this as hex 2B 41 48
77 2D; Unicode has 7C 00 or 00 7C (depending on endian-ness), and UTF32 has
7C 00 00 00
So what is actually there?
Marc
Damnit; too many pipes! Is this "broken bar" ([Alt]+0166 on numeric)?
In which case yes, every encoding disagrees:
ASCII: 3F
UTF7: 2B 41 4B 59 2D
UTF8: C2 A6
Unicode: A6 00
UTF32: A6 00 00 00
Actually quite handy, as you can look at the file in hex and figure out
encoding the file was written in!
Marc
Marc Gravell wrote:
Damnit; too many pipes! Is this "broken bar" ([Alt]+0166 on numeric)?
In which case yes, every encoding disagrees:
ASCII: 3F
UTF7: 2B 41 4B 59 2D
UTF8: C2 A6
Unicode: A6 00
UTF32: A6 00 00 00
Actually quite handy, as you can look at the file in hex and figure out
encoding the file was written in!
There's one more encoding which should be considered: Encoding.Defaul t.
My guess is that that's the one it was *actually* saved in - if it's a
single byte, it can't be any of the UTF encodings, and it can't be
ASCII, so Encoding.Defaul t is a likely culprit.
Jon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Eps |
last post by:
My program has an ini file which i read in the settings for the program.
The main setting is the path where files are to be saved. At the
moment it doesn't work, but if I hardcode the path it does (even though
the hardcoded path is the same as the one in the ini file).
I looked at the path in a text box after it had been read in and it had
a strange character on the end, it was a slim upright rectangle, i
assume this is the source of my...
|
by: USCG |
last post by:
My mini-application pings various machines and writes the
result to a text file.
There is a cosmetic quirk I am troubled with though.
When I look at the text file output, at the end of each
line there is a strange character that looks like a
musical note. Should I be concerned about this? Here is
my code for reference.
Imports System.IO
|
by: Kenneth McDonald |
last post by:
I am going to demonstrate my complete lack of understanding as to
going back and forth between
character encodings, so I hope someone out there can shed some light
on this. I have always
depended on the kindness of strangers... :-)
I'm playing around with some very simplistic french to english
translation. As some text to
work with, I copied the following from a french news site:
|
by: Amil |
last post by:
I am screen scraping a web page via GetResponseStream and can't resave a
certain character in the stream:
Stream respStream = wResp.GetResponseStream();
StreamReader reader = new StreamReader(respStream, Encoding.ASCII); // have
also used other UTFx modes
String respHTML = reader.ReadToEnd();
There is a strange character on the web page; it is a extra long
hypen...like the one in MS Word that is used if you type in two normal
|
by: jacksuyu |
last post by:
We were trying to save https://oururl in mysql database.
But got https: / /oururl
We don't know why "/" be changed to " /", any suggestion?
Thanks
| |
by: CyberSpyders |
last post by:
Hi,
I have an ASP.Net website, which allows users to upload a file which is
then inserted into a database.
This is all fine until it reads a line with the string +Anu in it.
It transforms this to this char É» (which, if Googled for, is
described as Unicode Character 'LATIN SMALL LETTER TURNED R WITH HOOK'
(U+027B) or, in Phonetics, as a 'Retroflex approximant'.)
|
by: Willem Bogaerts |
last post by:
Dear all,
I develop web applications on a Windows machine and upload the files to
a Linux server. When I look at any output (on the site, in a console
window, etc.), it appears in a different character set. Not very
surprising, but not pleasant either. My problem is that I do not know
where it goes wrong.
I upload the files with WinSCP(SFTP). My guess is that that is one of
the steps where it goes wrong. I cannot upload to another...
|
by: Danny |
last post by:
I saw the strangest thing when I imported some data into a column
today. One column contained musical notes instead of data. Has anyone
ever seen anything like this? I have no idea where this came from.
Thanks in advance.
|
by: blumen |
last post by:
Hi all,
I'm a newbie in VB.Net Programming..
Hope that some of you can help me to solve this..
I'm working out to read,parse and save textfile into SQL Server.
The textfile contains thousands of rows with about 50 coloums every row..
Everythings goes well until I found one textfile with some strange character...seems to be Japanese character(because it's a Japanese company who owns this textfile)
|
by: djpaul |
last post by:
Hello,
I run a script to get some info from another site.
But on that page some 'strange' character like é.
When i grab them an display it on my site i see strange characters like Beyoncé will be Beyoncé.
I tried different functions of php but nothing seems the help.
Tried: rawurlencode, htmlspecialchars and then htmlspecialchars_encode or hetmlentities and html_entity_encode.
But the text will always be the same, any ideas?
Top 40...
|
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: 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: 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: 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...
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |