473,657 Members | 2,481 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

c# - Encoding in 8 bits!!

Hi all,

I have seen a similar post to this in the past but no resolution. I
will explain fully my problem:

I am writing a text editor that will be used in several regions around
the world but my testing will be done in Turkey (I am in GB). The
output of this editor will be used in a DOS enviroment so any hint of
it outputting unicode is out of the question.

Before writing the application I requested a file from a turkish
client to be generated in notepad with all the letters of the alphabet
and any special Turkish characters. I then generated a screen font for
the DOS enviroment which mapped the special characters values (all
above 128) to their graphical representations . So far good.

I then moved on the create the application. Origonally for IO I used a
pair of StreamReaders / Writers with encoding set to Encoding.ASCII.
Obviously this scheme only appreciates ASCII values within the 7 bit
range - noo good as 129+ spilled over into 2 bytes.

I next tried Encoding.Defaul t, this behaves very strangley – it saves
single byte values on my machine and 2 byte values on the Turkish
machine. Still not good enough then.

I am desperate to find a solution to this, I would simply like to
output all charcters in the 8 bit character mapping scheme that is
used by NOTEPAD!! Surely this is easy. I know I can get to the ANSI
codepage as follows:

TextInfo ti = CultureInfo.Cur rentCulture.Tex tInfo;
ti.ANSICodePage ;

But what now!!!

I would appreciate any advice anybody can give me.
Jul 21 '05 #1
6 3582
Cor
Hi Duncan,

You can prevent a lot of work.

dotNet programs are not running on DOS.

Cor
Jul 21 '05 #2
Duncan M <du*******@hotm ail.com> wrote:
I have seen a similar post to this in the past but no resolution. I
will explain fully my problem:

I am writing a text editor that will be used in several regions around
the world but my testing will be done in Turkey (I am in GB). The
output of this editor will be used in a DOS enviroment so any hint of
it outputting unicode is out of the question.

Before writing the application I requested a file from a turkish
client to be generated in notepad with all the letters of the alphabet
and any special Turkish characters. I then generated a screen font for
the DOS enviroment which mapped the special characters values (all
above 128) to their graphical representations . So far good.

I then moved on the create the application. Origonally for IO I used a
pair of StreamReaders / Writers with encoding set to Encoding.ASCII.
Obviously this scheme only appreciates ASCII values within the 7 bit
range - noo good as 129+ spilled over into 2 bytes.
I would expect Unicode 128+ to come out as rubbish using an ASCII
encoding, but still a single byte - probably (unicodeValue & 0x7f).
I next tried Encoding.Defaul t, this behaves very strangley =3F it saves
single byte values on my machine and 2 byte values on the Turkish
machine. Still not good enough then.
Encoding.Defaul t uses whatever the system default encoding is - I
suspect the Turkish machine has a different default encoding,
presumably a multibyte one.
I am desperate to find a solution to this, I would simply like to
output all charcters in the 8 bit character mapping scheme that is
used by NOTEPAD!!
Used by Notepad on which machine though? It will vary...
Surely this is easy. I know I can get to the ANSI
codepage as follows:

TextInfo ti = CultureInfo.Cur rentCulture.Tex tInfo;
ti.ANSICodePage ;

But what now!!!

I would appreciate any advice anybody can give me.


I would suggest finding out *exactly* what encoding you're really after
(not just using Encoding.Defaul t) and specify that for your
StreamWriter.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3
Cor <no*@non.com> wrote:
You can prevent a lot of work.

dotNet programs are not running on DOS.


The OP never suggested they would be - just that the *output* of the
..NET program would be used in DOS.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4
Cor
Hi Jon,

Thanks, I tried to correct my message.

Cor
Jul 21 '05 #5
Cor
Hi Duncan,

Jon pointed me that I understand your question wrong, and I think he can be
right.

But to mix up for your both ASCII is a 7 bit value. That is not used on a
Dos computer.

On a Dos computer is it as far as I know UTF8

http://msdn.microsoft.com/library/de...classtopic.asp

I think that you need for that the right code scheme for codes above 127,
(mostly used in Europe en US are as far as I remember me 850 and 437).

I do not know how you can use that but maybe you can see it in the class
information for which I have given a link above.

Cor
Jul 21 '05 #6
Cor <no*@non.com> wrote:
Jon pointed me that I understand your question wrong, and I think he can be
right.

But to mix up for your both ASCII is a 7 bit value. That is not used on a
Dos computer.
Well, all the encodings I've seen used in DOS as ASCII-*compatible*,
i.e. they're "extensions " of ASCII. Given the encodings problem, it's
also often safest just to restrict yourself to ASCII if you can :)
On a Dos computer is it as far as I know UTF8


Nope, it's an individual code page, usually (as you say) 850 and 437.
Usually single byte encodings though, as far as I've seen.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #7

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

Similar topics

6
1906
by: lkrubner | last post by:
Last year I asked a bunch of questions about character encoding on this newsgroup. All the answers came down to using ord() in creative ways to try to make guesses about multi-byte characters. I was a little amazed at this and wondered if I'd somehow misunderstood the situation. I'm pleased to find that Joel Spolsky shared my amazement and offered some criticism of PHP on these grounds: "When I discovered that the popular web development...
3
5390
by: wenmang | last post by:
Hi, I ma thinking whether to use Base64 encoding to encode the binary content in the XML file. I have done some simple calculations, it seems to me that the size for encoded content increases by ~30%, is this the drawback for using the encoding scheme? Thanks.
48
4619
by: Zenobia | last post by:
Recently I was editing a document in GoLive 6. I like GoLive because it has some nice features such as: * rewrite source code * check syntax * global search & replace (through several files at once) * regular expression search & replace. Normally my documents are encoded with the ISO setting. Recently I was writing an XHTML document. After changing the encoding to UTF-8 I used the
4
1260
by: Amir | last post by:
Hello. Can someone help me with the diff between UTF8 and Unicode encoding ? I know both use 8 bits, both can use more then 2 Bytes (?) Thanks.
4
1609
by: Mark | last post by:
Hi... Just noticed something odd... In old ASP if you had query parameters that were invalid for their encoding (broken utf-8, say), ASP would give you back chars representing the 8-bit byte value of the broken encoding, so you still got something for every input byte. This appears to have changed radically in ASP.Net, going down to the base System.Text.Encoding object. Now, it appears to simply vaporize bytes that don't fit in the...
5
6487
by: Licheng Fang | last post by:
I want to store Chinese in Unicode internally in my program, and give output in UTF-8 or GBK format. After two days of searching and reading, I still cannot find a simple and straightforward way to do the code conversions. In particular, I want portability of the code across platfroms (Windows and Linux), and I don't like having to refer the user of my code to some third party libraries for compiling. Some STL references point to the...
23
439
by: Umesh | last post by:
This is a basic thing. Say A=0100 0001 in ASCII which deals with 256 characters(you know better than me!) But we deal with only four characters and 2 bits are enough to encode them. I want to confirm if we can encode A in 2bits(say 00), B in 2 bits (01), C in 2 bits(10) and D in 2 bits by some program. I only use this four alphabet in my work. Can u pl write a sample program to reach my goal?
5
1621
by: Bartholomew Simpson | last post by:
Slightly OT, but someone may know an algorithm to help me do this .... I have six numbers that I want to encode into one single larger number. The 6 numbers may be presented as ff: number Range num1 num2
1
2732
by: Alexander Adam | last post by:
Hi, I am a bit list in encoding related stuff. Let me explain what I am doing (yes it's C++ :)): I am getting some input content due Expat Xml Parser. I've setup Expat to use wchar_t. First question is this -- what is the difference of unsigned short, wchar_t and char? Okay, wchar_t is an built-in type of C++ and its two bytes of size whereas char is always one byte.
6
2827
by: John Messenger | last post by:
I notice that the C standard allows padding bits in both unsigned and signed integer types. Does anyone know of any real-world examples of compilers that use padding bits? -- John
0
8306
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
8732
jinu1996
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...
0
7327
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
6164
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
5632
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();...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
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.