Hexagora Forum
Hexagora Forum
Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Other hexagora products
 Programs (Programmi)
 [HELP] Utf7 to UTF16
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sfi_dev
Practical

37 Posts

Posted - 12 Jun 2012 :  04:14:27  Show Profile  Visit sfi_dev's Homepage  Reply with Quote
Hello,

I am currently evaluating your product.

I have found that the result when converting a unicode string to utf8 is quite a bit longer than our table columns allow so am looking to see if I can go lower than utf8.

1. I can see that you have a unicode to UTF7 function e.g:
ctlUniRichTextBoxXP1.GetContentsUTF7(ecrtbsc_AnsiText, False)
Is there a way to convert the contents back to UTF16 ?

2. As part of the tool set is there unicode to ansi and vice versa functions to convert text entered in the controls?

Thanks in advance.

Julie

s.dav
Site Admin

Italy
3364 Posts

Posted - 12 Jun 2012 :  09:27:41  Show Profile  Visit s.dav's Homepage  Reply with Quote
Julie,

the GetContentsUTF7 is a specific function given by Microsoft for the RichEdit control. Unfortunately we actually don't provide a UTF7 to XXX conversion function.

There are conversion function in the CommonWrapper Module for transforming UTF8 data to Unicode or ANSI and viceversa.

Regards, Davide
Go to Top of Page

sfi_dev
Practical

37 Posts

Posted - 13 Jun 2012 :  00:07:44  Show Profile  Visit sfi_dev's Homepage  Reply with Quote
Thank-you for the information Davide.

I am now testing with just the plain text box ctlUniTextBoxXP1
To convert from unicode to utf8 I have used -
Dim oWrap As New HexUniControls.clsCommonWrapper
oWrap.StrToUTF8(ctlUniTextBoxXP1.Text)

I have checked through the clsCommonWrapper in VB's object browser and cannot see a utf8 to ansi. Are you able to provide the function name ?

Thank-you

Julie
Go to Top of Page

s.dav
Site Admin

Italy
3364 Posts

Posted - 13 Jun 2012 :  09:04:57  Show Profile  Visit s.dav's Homepage  Reply with Quote
The library provides functions for transforming UTF8 strings to Unicode strings (the internal VB6 format) and vice-versa.
You can transform Unicode (UTF16 strings) to ANSI strings/arrays using the internal VB6 function StrConv, so for converting UTF8 to ANSI you need to convert UTF8 to Unicode then to ANSI


'From Unicode string to Ansi Array
Dim aAnsi() As Byte
aAnsi = StrConv(s, vbFromUnicode)

'An Unicode string (as VB6 is unicode for strings) coded in ansi
Dim sAnsi as string
sAnsi = StrConv(s, vbFromUnicode)

'Vice Versa
sUni = StrConv(sAnsi, vbUnicode)

'Unicode string to Array
Dim aUni() As Byte
aUni = s


'Pass VB6 Ansi string to ANSI Windows API
Declare SomeApi (byval sAnsi as string)
SomeApi sAnsi

'Pass VB6 Unicode string to Unicode Windows API
Declare SomeApi (byval lUnicode as long)
SomeApi StrPtr(sUnicode)


so UTF8 to ANSI should be:

dim sAnsi as string
sAnsi = StrConv(oWrap.UTF8toStr(sUTF8), vbFromUnicode)

Regards, Davide
Go to Top of Page

sfi_dev
Practical

37 Posts

Posted - 13 Jun 2012 :  12:04:54  Show Profile  Visit sfi_dev's Homepage  Reply with Quote
Thanks for the information.

If I have ctlUniTextBoxXP1.Text on screen and type in japanese chars - I then do a basic unicode to ansi convert and display the result in a vb textbox e.g.

text1.text = StrConv(ctlUniTextBoxXP1.Text, vbFromUnicode)

I get ???? marks. Is this expected, I thought ansi is the fundamentals of vb controls without using your unicode controls. Have I got this wrong.

Thanks Davide.
Go to Top of Page

s.dav
Site Admin

Italy
3364 Posts

Posted - 13 Jun 2012 :  21:08:27  Show Profile  Visit s.dav's Homepage  Reply with Quote
> Is this expected, I thought ansi is the fundamentals of vb controls without using your unicode controls.

Yes, VB6 strings management is Unicode but controls are ANSI so they cannot support unicode so you cannot use Japanese in standard VB6 controls.

Regards, Davide
Go to Top of Page

sfi_dev
Practical

37 Posts

Posted - 13 Jun 2012 :  23:23:28  Show Profile  Visit sfi_dev's Homepage  Reply with Quote
isnt doing the below converting the unicode japanese string to ansi so it should then display the ansi representation of the japanese characters instead of the ?????
text1.text = StrConv(ctlUniTextBoxXP1.Text, vbFromUnicode)
Go to Top of Page

s.dav
Site Admin

Italy
3364 Posts

Posted - 14 Jun 2012 :  09:01:36  Show Profile  Visit s.dav's Homepage  Reply with Quote
The ANSI representation of your japanese string is ???? because ANSI cannot contain japanese (extended) characters.

Regards, Davide
Go to Top of Page

sfi_dev
Practical

37 Posts

Posted - 15 Jun 2012 :  06:40:50  Show Profile  Visit sfi_dev's Homepage  Reply with Quote
understand. Thanks Davide :)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Hexagora Forum © s.dav Go To Top Of Page
Snitz Forums 2000