-
Jan 21st, 2009, 03:26 PM
#1
Thread Starter
Hyperactive Member
RIchTextBox How To Eliminate All Non_ascii chars
hi guys...
i was wodering how to make a button that when clicked would recognize all non ascii chars and if found any non asci to remove them and put "space" instead...
i need that because when i send data to weserver i encode the data and i even if i dont encode it the data gets encoded and sent..but if some strange chars get inside the data im sending my data is not sent!
Thanks for helping me out.
-
Jan 21st, 2009, 04:08 PM
#2
Re: RIchTextBox How To Eliminate All Non_ascii chars
AFAIK, ascii characters can be from 0 to 255, could you cite a non-ascii character?
-
Jan 21st, 2009, 05:01 PM
#3
Thread Starter
Hyperactive Member
Re: RIchTextBox How To Eliminate All Non_ascii chars
sure... sec
I dont k now if this is ascii but :
The char is fro mcharacter map : U+2013 En and it is like a "-"char but double the size...
and when i copy that char into my textfield it's ok..but then when i send it over the net the data does not come... if i remove that the data is sent regularly...hmmm
Thanks for helping me out.
-
Jan 21st, 2009, 05:05 PM
#4
Re: RIchTextBox How To Eliminate All Non_ascii chars
You mean you can copy it to a textbox? If yes then you can get its ascii value using ASC.
-
Jan 22nd, 2009, 02:09 AM
#5
Lively Member
Re: RIchTextBox How To Eliminate All Non_ascii chars
The character you are pertaining is an "En Dash" like this "–"?
or an "Em Dash" which is longer than the "En Dash"?
the Ascii value for an En Dash is 150 while the Em Dash is 151.
Anyways, assuming its an Em Dash, the following code will replace all the Em Dash to Space in the RTB control:
Code:
Private Sub Command1_Click()
RichTextBox1.Text = RemoveEmDash(RichTextBox1.Text)
End Sub
Function RemoveEmDash(str As String) As String
RemoveInvalid = Replace(str, Chr$(151), " ")
End Function
-
Jan 22nd, 2009, 02:19 AM
#6
Lively Member
Re: RIchTextBox How To Eliminate All Non_ascii chars
I have over read the code, my mistake. Function RemoveEmDash should be like this:
Code:
Function RemoveEmDash(str As String) As String
RemoveEmDash = Replace(str, Chr$(151), " ")
End Function
-
Jan 22nd, 2009, 07:03 AM
#7
Re: RIchTextBox How To Eliminate All Non_ascii chars
Try this that I didn't test:
Code:
Dim bt() As Byte, i As Long
bt = RichTextBox1.Text
For i = 1 To UBound(bt) Step 2
If bt(i) > 0 Then
bt(i - 1) = 32
bt(i) = 0
End If
Next
RichTextBox1.Text = bt
-
Jan 25th, 2009, 11:55 AM
#8
Thread Starter
Hyperactive Member
Re: RIchTextBox How To Eliminate All Non_ascii chars
ok guys..will try it today...
Thanks for helping me out.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|