Results 1 to 10 of 10

Thread: ascii code

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    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

  2. #2
    Addicted Member pcuser's Avatar
    Join Date
    Jun 2008
    Posts
    219

  3. #3
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    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.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    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.

  5. #5
    Hyperactive Member Hassan Basri's Avatar
    Join Date
    Sep 2006
    Posts
    324

    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

  6. #6
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    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.

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    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.

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: ascii code

    Quote Originally Posted by rpool View Post
    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?

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    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
  •  



Click Here to Expand Forum to Full Width