|
-
Oct 5th, 2009, 11:24 AM
#1
Thread Starter
Hyperactive Member
ascii code
I have problem,
Do you known it. that non-Ascii chars is between: from... to ?
I simple check, that result is 33 to 126 is I known chars.
(Q1) 33 to 126 is Ascii , correct ?
(Q2) < 33 is what used ?
(Q3) > 126 what is it ?
Please!
Code:
Private Sub Command1_Click()
Dim a As Integer
For a = 0 To 255
List1.AddItem a & ">" & Chr(a)
Next a
End Sub
-
Oct 5th, 2009, 11:32 AM
#2
Addicted Member
-
Oct 5th, 2009, 08:38 PM
#3
Re: ascii code
Originally 128 first characters were defined in a character set known as ASCII. This left one bit unused out of the 8 bits available. Then people made their own extended character sets. In some countries they made character sets that used even more bits on some characters (Japan and China to name the most remarkable, I think).
This was a mess, because characters 128 - 255 could be very different depending on the character set being used. For one example, DOS uses a different character set than what is being used in Windows. Even if the 128 first characters match, the other characters do not.
This problem has been solved these days: we have Unicode that defines code points. These code points can be encoded using UTF-8, UTF-16 and UTF-32. In UTF-32 the code points match perfectly with the value represented in a single 32-bit character code.
UTF-16 matches for the most part in it's range (0 to 65535), but there is a special surrogate range (which I can't remember from the top of my head) that allows for a second 16-bit value to be used so that all the code point values can be achieved.
Then there is UTF-8. It was made for the need of having a backwards compatible 8-bit Unicode set. Like all the old character sets, the 128 first characters are from the ASCII table. However, everything above that is reserved for creating the remaining code points and more bytes are used to get these values.
Now you know.
-
Oct 7th, 2009, 10:48 AM
#4
Thread Starter
Hyperactive Member
Re: ascii code
thanks! Because I need simple check that field string is....
str = "abcd"
str = "japan_font string"
I found "ChrW" , "AscW" can help me ?
Code:
Pseudo Code:
Dim str as string
if str ascii < 128
msgbox "this is english string" & str
else
msgbox "this maybe chinese,japan string" & str
end if
Any simple please!
Last edited by rpool; Oct 7th, 2009 at 10:54 AM.
-
Oct 7th, 2009, 05:53 PM
#5
Hyperactive Member
Re: ascii code
Try doing it with byte arrays like this:
Code:
Dim iCounter As Integer
Dim byt() As Byte
Dim bln As Boolean
byt = "abcd"
For iCounter = 0 To UBound(byt)
If byt(iCounter) > 128 Then
bln = True
Exit For
End If
Next iCounter
If bln Then
MsgBox "Your string has characters above 128.", vbOKOnly + vbInformation
Else
MsgBox "Your string characters are all below 128.", vbOKOnly + vbInformation
End If
-
Oct 7th, 2009, 07:18 PM
#6
Re: ascii code
You can use AscW to check an individual character. To see which language is in question you can take a look at Unicode chart made by someone. It has to be noted, of course, that some characters are very widely used and it is impossible to know the language based on just that latter.
Note that in VB6 you can't easily display Unicode, it will be hard to make VB display Japanese for you. I've made some Unicode controls as have some others (most of them commercially), native controls are unable to do the work for you.
-
Oct 7th, 2009, 07:38 PM
#7
Re: ascii code
Just for information only. Here is a good site I visit quite often for unicode related questions. It doesn't have all the answers, but is worth bookmarking in my opinion.
-
Oct 7th, 2009, 11:03 PM
#8
Thread Starter
Hyperactive Member
Re: ascii code
thanks, I maybe wrong mean "uni-code"
I mean is some Windows Version , can provide "that country language string, AND english string"
because, my windows is "window (japan version",
this version, I can input "japan font" and "english font" both same
in Text1.Text (object is :textbox. NOT richTextbox)
now, because I do not knwon my database that field is what string ? mean "english, or japan"
I try simple use "Ascii < 128" to verify it .
Code:
if "ascii < 128" ,
simple to confirm is ENGLISH
Text1.Font = "Courier New"
else
Text1.Font = "japan font"
end if
now, write this code,
I simple check "each AscW() < Len(str) * 128
but what wrong ?
Please!
Code:
Private Sub Command1_Click()
Dim str As String
Dim result As Boolean
str = "abcd"
'this web can all non-englisg chars "to" str(
'http://www.cyberactivex.com/UnicodeTutorialVb.htm#Fonts
Dim N As Integer
Dim sum As Double
sum = 0
For N = 1 To Len(str)
sum = sum + (AscW(Mid(str, N, 1)))
MsgBox sum
Next N
If Val(Len(str)) * Val(128) < sum Then
result = False
Else
result = True
End If
If bln Then
MsgBox "english string." & str
Else
MsgBox "maybe chinese." & str
End If
End Sub
Last edited by rpool; Oct 7th, 2009 at 11:13 PM.
-
Oct 8th, 2009, 10:37 AM
#9
Re: ascii code
 Originally Posted by rpool
now, write this code,
I simple check "each AscW() < Len(str) * 128
but what wrong ?
We don't know...what is wrong? Do you get errors?
-
Oct 8th, 2009, 10:45 AM
#10
Thread Starter
Hyperactive Member
Re: ascii code
I think that "bln" = boolean is some wrong,
If bln Then , mean = If bln = False Then. ?
And , calc Each is > 128 or < 128 , is simple method ?
please!
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
|