How I send urdu text message using mscom in VB6 - unicode

I am trying to send the message through com port using MScom in VB6. although simple message in english is sending is ok. But when I send the urdu language test then it send? marks. my port setting
With MSComm1
.CommPort = port
.Settings = "9600,N,8,1"
.Handshaking = comRTS
.RTSEnable = True
.DTREnable = True
.RThreshold = 1
.SThreshold = 1
.InputMode = comInputModeBinary 'comInputModeText
.InputLen = 0
.PortOpen = True 'must be the last
End With
I use urdutextbox for writing message

Basically, I underwent through the same processes below in trying to develop a multilingual VB6 app in Chinese, German, Japanese and Dutch and was successful so I'll share it with you except it will be for Urdu language.
Firstly, you will need to install the Hindi/Urdu Language Pack for Microsoft Windows to add that language to your Windows OS. Test that this is successfully installed by changing the Language settings so that you can see some Urdu text displayed in your system screens and that you can cut and paste Urdu in VB6 instead of it showing the question marks.
Make sure you are using Unicode type strings.
If you are using Access, make sure you can successfully store Urdu text in the database tables which should be showing Urdu text instead of the ??? (I did also get the ??? until I installed the Windows Language Packs for the languages concerned and used Unicode).
If you are using VB6 textboxes, make sure that Fonts are Unicode. Test that it can display the Urdu text.

Related

Outlook removes line breaks UTF-8 and Plain Text mails, regardless of the configuration

Outlook 2013 up to the latest Office 365 build seem to remove line breaks in Plain Text mails.
Outlook Options:
E-mail->"Additional line breaks in plain text messages..." = unchecked
E-mail->"Reduce the size of the message..." = unchecked
Advanced->International Options = UTF-8
Let outlook choose codepage is disabled for testing purposes.
If I open a new E-mail, set it to Plain Text and enter:
> Foo
> Bar
> Baz
the e-mail will still be formatted to:
> Foo > Bar > Baz
Chaning the international options to Western European ISO will fix this and send the e-mail as intended. System locale is de_DE.
Is there a way to maintain line breaks + UTF-8? Its realy annoying when answering mails.
Finally found the solution, leaving it here:
Non-english Windows 10:
Windows Settings App (New Version)
Date & Region
Language
Administrative Language Options
Language for Unicode incompatible Apps: Change Regional Scheme Button
Make sure the Country matches.
Disable "Beta: Unicode UTF-8 support for worldwide languages"
Thats requirement #1.
Full reboot is now needed and cannot be avoided.
Outlook 365:
File
Settings
Advanced
[x] Automatic encoding for Outgoing e-mails
Prefered encoding for Outgoing e-mails: Unicode (UTF-8)
Thats requirement #2
Same for vCards.
It seems plaintext messages in de_DE win-10, de_DE outlook 365 + exchange server only work reliable in this combination.
Otherwise any \r\n is removed by Outlook, regardless of the "Remove unneccessary whitespace" setting.

Issue in displaying Unicoded native language characters through MFC in Windows XP

I'm trying to display Unicode Bengali, a native language of India through a MFC application as below:
CFont *m_pFontSmallBN = new CFont();
m_pFontSmallBN->CreateFont(34,0,0,0,600,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,
_T("Ekushey Lalsalu")); //"Ekushey Lalsalu" is the Bengali Font name here.
CStatic m_msg_bn;
m_msg_bn.SetFont(m_pFontSmallBN,TRUE);
m_msg_bn.SetWindowText(_T("TEXT IN NATIVE LANGUAGE")); //TEXT is typed with the Font
While I'm running the app in Windows vista it can display the text perfectly; but in Windows XP it cannot display unicode characters properly. Compound alphabets (framed with multiple unicode characters) of the bengali language are being displayed as separate characters. I ensured that both Windows Vista and XP have the Font installed and character set of my MFC project setting is Unicode.
Could anybody please help me to find out the issue in Windows XP environment ?
Choosing a font in Windows is tricky. You'd expect the font name to take precedence over all other font characteristics, but that's not always the case. To be sure you're getting the proper font you should make sure all the parameters to CreateFont match the font you want. This article, though old, details the font mapping process: Windows Font Mapping.
Here's a small program that puts up a font selection dialog and dumps the parameters that you can pass to CreateFont to guarantee that you're getting the font you want.
#include <Windows.h>
#include <stdio.h>
int wmain(int argc, wchar_t* argv[])
{
LOGFONT lf = {};
CHOOSEFONT cf = {sizeof(CHOOSEFONT)};
cf.lpLogFont = &lf;
cf.Flags = CF_BOTH | CF_FORCEFONTEXIST;
if (ChooseFont(&cf))
{
wprintf(L"%d,%d,%d,%d,%d,", lf.lfHeight, lf.lfWidth, lf.lfEscapement, lf.lfOrientation, lf.lfWeight);
wprintf(L"%d,%d,%d,%d,%d,", lf.lfItalic, lf.lfUnderline, lf.lfStrikeOut, lf.lfCharSet, lf.lfOutPrecision);
wprintf(L"%d,%d,%d,", lf.lfClipPrecision, lf.lfQuality, lf.lfPitchAndFamily);
wprintf(L"_T(\"%s\")\n", lf.lfFaceName);
}
return 0;
}
#Mark I could not add my comment using "add a comment" link; therefore, I'm adding it here. Even in XP environment the program displays same values for the Font properties. Another thing is that using notepad of the same system, I see the same improper display. It can display bengali font but display is improper for compound alphabet (consonant conjunct or consonant attached with a diacritic form of a vowel) of bengali language. This is probably due to XP doesn't have in-built support for complex text for native scripts like bengali by default. Windows from Vista and onward have this complex text support enabled by default; therefore just installing a native unicode font enables us to view native script properly.

Displaying Chinese characters on a form from an INI File

My plugin reads the control caption text from an INI file (ANSI as UTF-8 encoding) in order to display multiple languages. Key point being it is a plugin, I have no control nor ability to change this INI file format or file type.
They are currently being read into my plugin with TINIFile.ReadString and stored as a string. I can modify this (data type, read method, etc) as needed.
The main application reads from its own application language files that are UCS-2 Little Endian encoded as a TXT file. These display fine when the language is changed, even when the Windows OS is kept in English (in other words no OS locale changes need to be made for the application to switch display languages).
My plugin's form cannot display Asian characters (Chinese, Japanese, Korean, etc). English language is fine.
I have tried various fonts, using various combinations of AnsiString, String, etc. What am I missing to be able to display Asian characters on the form? I have not found a similar question to what I'm trying to do specifically with how my language text is being read into the plugin.
If the .INI file reader does not interpret the contents of the values, and allows all values through transparently, then you need to map the strings into one with the correct locale.
There is a similar question at Delphi 2010: how do I convert a UTF8-encoded PAnsiChar to a UnicodeString? that explains how to do the conversion. You may need to extract the contents into a RawByteString to avoid the implicit conversions.

How can I make support Unicode characters in whole my VB 6.0 application

I am facing a problem in my VB 6.0 application that Unicode characters are not supporting. I need to set Chinese characters in field of a recordset in my application-(size of each field is setting from program itself). If we are setting Chinese char into the field of recordset then getting Multiple-step operation error(because of the holding field size is not enough). This error will not fire, if we are setting language to Chinese from Regional settings from control panel in server (Control Panel > Region and Language setting > Administrative Tab > Change system Locale.. > to Chinese )
if we are setting this then time settings of our application will be change. I need some help with out changing from control panel how can we solve this problem.
please help.
Thanks in advance.
In Windows, you can set your regional settings to Chinese, while keeping the time and date format. http://www.techpavan.com/2009/04/07/change-time-format-windows/
For using Unicode in Visual Basic 6 applications, here is an article with thorough explanations and examples: http://www.example-code.com/vb/vbUnicode1.asp
Quoting this link:
Internally, VB6 stores strings as Unicode. Your VB6 program is capable of manipulating strings in any language containing any character -- whether it's Chinese, Japanese, Icelandic, Arabic, etc. It's fully Unicode capable. A single string may contain characters in multiple languages. You can save these strings to databases, files, etc., and there shouldn't be a problem. Problems arise only when trying to display (i.e. render the glyphs) for foreign characters in the standard VB6 controls.
When displaying a string, the standard VB6 textbox and label controls do an implicit (and internal) conversion from Unicode to ANSI. This is the confounding behavior that causes all the trouble. Internal to VB6, the runtime is converting Unicode to the current Windows ANSI code page identifier for the operating system. There is no way to change this conversion short of changing the ANSI code page for the system.
The standard VB6 textbox and label controls display the ANSI bytes according to a character encoding that you can specify. After the Unicode-to-ANSI conversion, VB6 then attempts to display the character data according to the control's Font.Charset property, which if left unchanged is equal to the ANSI charset. Changing the control's Font.Charset changes the way VB6 interprets the "ANSI" bytes. In other words, you're telling VB6 to treat the bytes as some other character encoding instead of "ANSI". Note: VB6 is capable of displaying characters in all the major languages. It simply needs to be told to do so, and the correct bytes need to be in place internally for it to happen.
Try setting the font on those controls to Lucida Sans Unicode to add Unicode Support in.

Is there a way I can add unicode text to a MBCS MFC menu

I have a MFC application compiled with the MBCS character set. I have a submenu off of my main menu that I would like to add unicode characters to. Can that be done?
You can force the use of Unicode strings even in MBCS apps by explicitely calling the Unicode form of an API and passing it a Unicode string.
In your case, ModifyMenuW() is the API that sets the menu item text (assuming the menu item already exists):
ModifyMenuW(GetMenu()->m_hMenu,ID_APP_ABOUT, MF_BYCOMMAND , 0, L"\u573F");
This code displays a Chinese ideogram (I have no idea of its meaning) instead of the original text
The L in front of the string says it's a Unicode string. \u573F is the way you encode a Unicode char in your C++ ASCII source file. The W at the end of the API name: It stands for Wide and denotes the Unicode form of the API.
Note that if your goal is to translate the full UI of your app, this is a complete other story: The method I showed here is only suitable for one-shot calls. You can't create a full UI that way.
You can translate your MBCS app to Japanese, Russian, whatever,... without switching to Unicode (Although it would be a very good idea to do that switch. But that can be costly for legacy apps).
You have 2 friends to help you out there: appTranslator lets you very easily translate your app (and manage your translations (Disclaimer: This is my own ad ;-) and Microsoft AppLocale helps you test MBCS apps in different codepages without actually changing the codepage of your computer (which requires a reboot).