Advertisement

09.10.2007 at 08:51AM PDT, ID: 22818026
[x]
Attachment Details

ASCIIEncoding Class (saving a string to a stream)

Asked by steve-west in Delphi.net Programming, C# Programming Language

Tags: delphi, stream, string, asciiencoding

I'm trying to save a string to a filestream.

The documentation says that I should use an encoder class, for example ASCIIEncoding, to implement this. (i.e. use the GetBytes method to create ByteArray and then write this to the stream).

OK, fair enough, BUT

When I try to use the exact code that is demonstrated, I get "unknown identifier" when I reference the ASCIIEncoding class, for example see below:

This is the c# Code, I'm trying to convert to Delphi.Net:

using System;
using System.Text;

class ASCIIEncodingExample {
    public static void Main() {
        // The encoding.
        ASCIIEncoding ascii = new ASCIIEncoding();

// ---------------------------------------------------------------------------

Now I've tried the following in delphi:

Uses
  System,
  System.Text // This doesn't compile
  System.Object;


var
  Ascii : ASCIIEncoding;                                       // This doesn't compile
  Ascii : System.Text.ASCIIEncoding;                  // This doesn't compile

Nothing works - the system doesn't know anything about the " ASCIIEncoding" class.

Can anyone please show me how to reference and use the ASCIIEncoding class (the GetBytes method) in Delphi 2006?

Thanks

Steve




Start Free Trial
 
Keywords: ASCIIEncoding Class (saving a string t…
 
Loading Advertisement...
 
[+][-]09.10.2007 at 09:00AM PDT, ID: 19861891

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.10.2007 at 09:06AM PDT, ID: 19861938

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.10.2007 at 10:53AM PDT, ID: 19862777

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Delphi.net Programming, C# Programming Language
Tags: delphi, stream, string, asciiencoding
Sign Up Now!
Solution Provided By: TheLearnedOne
Participating Experts: 2
Solution Grade: B
 
 
[+][-]09.11.2007 at 01:09AM PDT, ID: 19866788

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628