7-bit related text error? (primarily windows)

nummish <[email protected]> Thu, 4 Nov 2004 18:39:56 -0500
Newsgroups gmane.comp.lib.wxwindows.wxnet
Message-ID <[email protected]>
Hi, I've just recently started using wx.Net, and I'm not sure if this
is a genuine bug, or related to my current (ab)use of the TextCtrl
object.

Basically, if I take a byte with a value of > 127 and convert it to a
Char (then in a string) and assign that value to a TextCtrl.Value
property, it stores it ok. (Rendering it as a placeholder works fine
too).

The problem appears when I try to read that same value out of the
TextCtrl object.

In Windows it generates:
System.OverflowException: Value was either too large or too small for
a character.
    at System.Convert.ToChar(Int32 value)
    at wx.wxString.op_Implicit(wxString str)
    at wx.TextCtrl.get_Value()
    at TestCrash..ctor() in C:\blah\blah\TestCrash.cs

I also tested it with mono, for most values over 127 it seems to
render the placeholders alright which allows me to pull out the data,
but I didn't see any exceptions or any other output for the byte
values 235,205,214   (note, 207 works fine so I'm unable to make any
blanket generalizations)

Here's some code to generate the windows condition:
--- Sample code to generate the error ---
using System;
using System.Drawing;
using System.IO;
using wx;
 

public class TestCrashWrapper
{

	
	[STAThread]
	public static void Main(string[] args)
	{
		TestApp ts = new TestApp();
		ts.Run();

	}

	public class TestApp : App
	{
		public override bool OnInit()
		{
			TestCrash tc = new TestCrash();
			tc.Show(true);
			return true;
		}
	}

	public class TestCrash : Frame
	{
		public TestCrash()
		: base("Blah", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
		{

		TextCtrl	txtSource;
		TextCtrl	txtTarget;
		Frame Dummy = new Frame("Blah");
		
		txtSource = new TextCtrl(Dummy, 1, "", Frame.wxDefaultPosition, new
Size(0,0), wx.TextCtrl.wxTE_MULTILINE );
		txtTarget = new TextCtrl(Dummy, 1, "", Frame.wxDefaultPosition, new
Size(0,0), wx.TextCtrl.wxTE_MULTILINE );

		txtSource.Value = Convert.ToChar(129).ToString();

                //////////////////   This is the crashing portion  
//////////////////////////
		try
		{
			txtTarget.Value = txtSource.Value;
		}
		catch (Exception e)
		{
			System.Console.WriteLine(e);
		}
               
/////////////////////////////////////////////////////////////////////////////////////////
			
		}
	}
}

-nummish


-- 
Bigger 1:23
This address if for mailing list traffic only. 
Please direct non-list correspondence to 0x90.org


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click