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! :cry:
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?
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
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.
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
:)
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
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
Re: RIchTextBox How To Eliminate All Non_ascii chars
ok guys..will try it today...