• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1383
  • Last Modified:

japanese code conversion problem

Hello ,
          i have a module which displays a dialog box similar to a the groups dialog in windows XP.

Name                       Description
Administrators          Administrators have complete........
....

like the above.the module was tested in japan and they have come up with a bug that the description
side of the strings is getting transformed to japanese code conversion
like this:

Name                     Description
Administrators        ..#frfd~*76%er


.now i know this is the unicode issue,but can some one please give suggestions on how to solve my component is in visual basic 6.0.

0
software_elico
Asked:
software_elico
  • 7
  • 5
1 Solution
 
jimbobmcgeeCommented:
What are you using to show your data?  You might want to consider one of the controls in the MS-Forms 2.0 Object Library -- it comes with Office and the ActiveX Control Pad (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaxctrl/html/cpad.asp).  It is a DLL (fm20.dll) that contains some Unicode versions of some controls.

Otherwise, try the Unicode controls at http://www.cyberactivex.com/

HTH

J.
0
 
software_elicoAuthor Commented:
here objGrp is an object of IADsGroup.

Dim objGrp As IADsGroup
    Dim lstItem As ListItem
    'Reset the list boxex
    lstGroups.ListItems.Clear
    mobjCont.Filter = Array("Group")
    Screen.MousePointer = vbHourglass
    For Each objGrp In mobjCont
        Set lstItem = lstGroups.ListItems.Add(, , objGrp.name)
        lstItem.ListSubItems.Add , , objGrp.Description
    Next

what i dont understand is the name and Description properties are both BSTR ,then how can the name be displayed correctly and the description have japanese characters.
0
 
jimbobmcgeeCommented:
So the name is displaying as you would expect it to but the description is displaying as a jumble of garbage characters?

Are there Japanese characters in the name field (check in AD).  If not, that's why your name is displayed correctly.  As far as I know, the controls supplied with VB6 do not support Unicode (although VB6 strings are Unicode -- go figure!!)  

If there is even the slightest chance that you will need to display foreign characters, you will have to use the Unicode-capable controls I linked to above...

J.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
software_elicoAuthor Commented:
*the controls supplied with VB6 do not support Unicode (although VB6 strings are Unicode -- go figure!!)*

Can i get some more information on the VB6.0 unicode support.

thanks  
0
 
software_elicoAuthor Commented:
Okay,
        If i download the fm20jpn.dll will it support my application which is in VB 6.0 ,to run in a japanese Windows XP operating system.i will clarify the question...

I have an application in visual basic ,say a simple application like a dialog box with a text box to display my name,the problem is when i enter a few characters in japanese ,they all become question mark characters.so if i can download the above mentioned dll or use strconv function,will it work?
0
 
jimbobmcgeeCommented:
Getting fm20.dll, referencing it in VB6, adding its controls to your VB toolbox and using its text box should work.  Replacing all your existing controls with their Forms 2.0 equivalent should do the trick, yes.  Be aware that some of the properties of the Forms 2.0 controls differ from the existing VB6 ones...

J.
0
 
software_elicoAuthor Commented:
ok,
    i think i got a unitoolbox and started running my applications.it works fine but now i cannot login to the japanese version of windows xp.
0
 
jimbobmcgeeCommented:
You can't log in to the Japanese version of XP since installing, or despite installing, UniToolbox?

Does the username/password for the Japanese XP contain Japanese symbols?  You may have trouble typing the characters, because of a cope page, or something...?

Just a thought,

J.
0
 
software_elicoAuthor Commented:
No japanese symbols.but i think they(japs) found a work around to that.
anyway i just have one last query and then i will PAQ the points to you.I have a string variable
to store  the directory path,i am sending this string to a list box list which is a unicode component.but when i read the directory path into the String variable,which does not support unicode,my characters are garbled.so basically my question is ,how can i read this dir path into a unicode string.thanks

If (lpIDList <> 0) Then
    sBuffer = Space(MAX_PATH)  //sBuffer is a String
    SHGetPathFromIDList lpIDList, sBuffer
    sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
  Else
    Exit Sub
  End If

  For l = 0 To lstSelectedFolder.ListCount - 1

    If (sBuffer = lstSelectedFolder.List(l)) Then
        blnFound = True
        Exit For
    End If

  Next l
    If (blnFound = False) Then
        lstSelectedFolder.AddItem (sBuffer)
   
0
 
jimbobmcgeeCommented:
Firstly, the string variable _does_ support Unicode (all VB6 strings are stored as 2-bytes-per-character).

Why do you use SHGetPathFromIDList?  What kind of list are you taking the directory path from?

If you are using an API call to get the directory path, chances are that you are not trimming the API-received string of Null characters or spaces, etc.  When the API reads into a string buffer, it keeps all the spaces that were there before and just overwrites the characters it needs to (followed by a Null char).  I imagine you are testing for equality without accounting for this:

     sBuffer  = Space(MAX_PATH)          ->       sBuffer = "                    "
     SHGetPath...                                  ->       sBuffer = "c:\                 "
     
I also imagine that SHGetPath... would return the length of the received text (if it's like most other string-based API calls).  Therefore, I would read in with a byte array:

     ReDim byBuffer(MAX_PATH * 2) As Byte
     nLength = SHGetPathFromIDList lpIDList, byBuffer(0)
     ReDim Preserve byBuffer(nLength - 1)
     sOutput = StrConv(byBuffer(), vbUnicode)

You'll have to play around with it but it _should_ give you some idea...

J.
0
 
jimbobmcgeeCommented:
If it doesn't return the length, you'll have to poll the bytes looking for (two adjacent) null byte(s)...

J.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now