For Programmers: Free Programming Magazines  


Home > Archive > Smartphone Developer Forum > October 2005 > How can I send Chinese SMS?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How can I send Chinese SMS?
Jeffrey Hua

2005-10-24, 7:57 am

The following is my source code.
I can send English SMS correctly.But when I tried to send Chinese SMS,I got
unrecognized SMS which displayed "??" in handset.
Anybody knows why?


-------------------------------------------------------------------------------------
BOOL SendSMS(TCHAR *tszPhoneNumber, TCHAR *tszMessage)
{
SMS_HANDLE smshHandle;
SMS_ADDRESS smsaDestination;
TEXT_PROVIDER_SPECIFIC_DATA tpsd;
SMS_MESSAGE_ID smsmidMessageID = 0;

// try to open an SMS Handle
HRESULT hr = SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle, NULL);
if (hr != ERROR_SUCCESS) {
return FALSE;
}

// Create the destination address
memset (&smsaDestination, 0, sizeof (smsaDestination));
smsaDestination.smsatAddressType = SMSAT_NATIONAL;
lstrcpy(smsaDestination.ptsAddress, tszPhoneNumber);

// Set up provider specific data
tpsd.dwMessageOptions = PS_MESSAGE_OPTION_NONE;
tpsd.psMessageClass = PS_MESSAGE_CLASS1;
tpsd.psReplaceOption = PSRO_NONE;


// Send the message, indicating success or failure
hr = SmsSendMessage(smshHandle, NULL, &smsaDestination, NULL,
(PBYTE) tszMessage, wcslen(tszMessage)*sizeof(TCHAR),
(PBYTE) &tpsd, 12, SMSDE_GSM,
SMS_OPTION_DELIVERY_NONE, &smsmidMessageID);

SmsClose (smshHandle);
if (hr != ERROR_SUCCESS)
return FALSE;

return TRUE;

}


Madhuri Gummalla [MSFT]

2005-10-25, 7:58 am

Hi Jeffrey,

What is the OS langauage on your device; is it chinese? Please check if the
required chinese font is installed on your device. If not you can copy the
font file from desktop to \Windows\Fonts directory.

If you still see the '?' characters, you might want to explicitly convert
the message to a byte pointer using WideCharToMultiByte(). Please refer to
the documentation at
http://msdn.microsoft.com/library/d...tomultibyte.asp

Something like -
pszMessage = new char[wcslen(tszMessage)+1];

::WideCharToMultiByte(CP_UTF8, 0, tszMessage, -1, pszMessage ,
wcslen(pszMessage)+1, NULL, NULL);

and then pass pszMessage to SmsSendMessage()

--
Thanks,
Madhuri
(Software Design Engineer/Test, Microsoft)

This posting is provided "AS IS" with no warranties, and confers no rights.

"Jeffrey Hua" <jeffrey_hua@neomtel.com> wrote in message
news:%23gd3IAI2FHA.1132@TK2MSFTNGP10.phx.gbl...
> The following is my source code.
> I can send English SMS correctly.But when I tried to send Chinese SMS,I
> got unrecognized SMS which displayed "??" in handset.
> Anybody knows why?
>
>
> -------------------------------------------------------------------------------------
> BOOL SendSMS(TCHAR *tszPhoneNumber, TCHAR *tszMessage)
> {
> SMS_HANDLE smshHandle;
> SMS_ADDRESS smsaDestination;
> TEXT_PROVIDER_SPECIFIC_DATA tpsd;
> SMS_MESSAGE_ID smsmidMessageID = 0;
>
> // try to open an SMS Handle
> HRESULT hr = SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle, NULL);
> if (hr != ERROR_SUCCESS) {
> return FALSE;
> }
>
> // Create the destination address
> memset (&smsaDestination, 0, sizeof (smsaDestination));
> smsaDestination.smsatAddressType = SMSAT_NATIONAL;
> lstrcpy(smsaDestination.ptsAddress, tszPhoneNumber);
>
> // Set up provider specific data
> tpsd.dwMessageOptions = PS_MESSAGE_OPTION_NONE;
> tpsd.psMessageClass = PS_MESSAGE_CLASS1;
> tpsd.psReplaceOption = PSRO_NONE;
>
>
> // Send the message, indicating success or failure
> hr = SmsSendMessage(smshHandle, NULL, &smsaDestination, NULL,
> (PBYTE) tszMessage, wcslen(tszMessage)*sizeof(TCHAR),
> (PBYTE) &tpsd, 12, SMSDE_GSM,
> SMS_OPTION_DELIVERY_NONE, &smsmidMessageID);
>
> SmsClose (smshHandle);
> if (hr != ERROR_SUCCESS)
> return FALSE;
>
> return TRUE;
>
> }
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com