[thelist] asp.net: Unicode Encoding Problem

VOLKAN ÖZÇELİK volkan.ozcelik at gmail.com
Thu Jul 14 08:45:51 CDT 2005


Here is a snippet I use:

Encoding locale = System.Text.Encoding.GetEncoding(1254);//1254 for turkish

StreamReader sr = new StreamReader(sourcePath,locale);
String strCompress = sr.ReadToEnd();
sr.Close();

StreamWriter sw = new StreamWriter(destinationPath, false, locale);
sw.Write(whatever);
sw.Close();

You can observe the working application at:

http://www.codeproject.com/csharp/JSCodeCompressor.asp 
(it is not a web form though - it is a c# form)

Hope this helps.

Cheers,
Volkan.


On 7/14/05, Casey <aspnet at thecrookstons.com> wrote:
> Ok,
> 
> I figured how to use streamwriter by actually creating the object:
> 
> Sub Page_Load(S as Object, E as EventArgs)
>  dim toPath as string =
> "C:/Inetpub/wwwroot/minntronix/content/pages/content_includes/" &
> Request.QueryString("page") & ".ascx"
>  dim myStreamWriter as StreamWriter = New StreamWriter(toPath)
>  myStreamWriter.WriteLine(Session("previewText"))
>  myStreamWriter.Close
> End Sub
> 
> Now, how do I use unicode??????
> 
> For the love of mercy, somone PLEASE help!!!!!!
> 
> Casey
> 
> 
> 
> ----- Original Message -----
> 
> 
> > The File.CreateText method doesn't not have a signature (Path, Encoding)
> > AFAIK:
> >
> ms-help://MS.NETFrameworkSDKv1.1/cpref/html/frlrfSystemIOFileClassCreateText
> T
> > opic.htm
> >
> > If you explicitly create a StreamWriter object, then there is a
> constructor
> > that has that signature.
> >
> > Cheers
> > Ken
> >
> > : -----Original Message-----
> > :
> > : I'm using a simple StreamWriter to over right the contents of a file:
> > :
> > : Sub Page_Load(S as Object, E as EventArgs)
> > :  dim myStreamWriter as StreamWriter
> > :  dim onPage as string = Request.QueryString("page")
> > :  myStreamWriter = File.CreateText(MapPath("../pages/content_includes/" &
> > : onPage & ".ascx"), System.Text.Encoding.UnicodeEncoding )
> > :  myStreamWriter.WriteLine(Session("previewText"))
> > :  myStreamWriter.Close
> > : End Sub
> > :
> > : I added the ", System.Text.Encoding.UnicodeEncoding " because I was
> having
> > : trouble with certain greek charectors being altered when the file was
> > : re-written.  But I now get this error:
> > :
> > : BC30390: 'System.Text.Encoding.unicodeEncoding' is not accessible in
> this
> > : context because it is 'Private'.
> > :
> > : I will confess that all this unicode endcoding is new to me.  What must
> I
> > : do to ensure the stability of the content?
> 
> --
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>


More information about the thelist mailing list