Giter Club home page Giter Club logo

Comments (4)

andrewbird avatar andrewbird commented on July 20, 2024

Hi there,
Do you have some example Greek text in UTF8 I could test with?

Andrew

from python-messaging.

multijohn avatar multijohn commented on July 20, 2024

Hello and thank u for your response,
I have this code:
#!/usr/bin/env python

-- coding: utf-8 --

import messaging
from messaging import sms
from messaging.sms import SmsSubmit

sms = SmsSubmit('+3069000000', 'ΤΡΑΠΕΖΑ')
pdu = sms.to_pdu()[0]

print pdu.pdu

exit()

which successfully creates PDU but unreadable.

the greek text is "ΤΡΑΠΕΖΑ" and on http://rednaxela.net/pdu.php produce this "ÔÑÁÐÅÆÁ " same on mobile also.

Thank u!

from python-messaging.

andrewbird avatar andrewbird commented on July 20, 2024

Hi,
Okay I see what's happening. The GSM0338 character set doesn't include TAU, RHO, ALPHA, EPSILON, or ZETA, so when SmsSubmit is presented with a UTF-8 string containing any of those characters, the conversion to GSM characters cannot proceed. The fallback for this case, and actually is most common in non latin languages is to transmit the message in UCS-2 format. the downside of this is that the UCS-2 characters are 16 bit wide, not 7bits like GSM, hence the encoded text is much longer and may span multiple SMS. So both the decoder tool and the phone you are looking at the message on probably don't support UCS-2 messages. I expect that if you view the text message on a phone with a good GSM implementation like an Ericsson, you'll see the message you expect.
Looking at the gsm0338 wiki page there have been some additional shift pages added to allow for non-latin1 languages, but unfortunately not for Greek. If you know of some standard way of encoding the Greek characters that will be interpreted correctly, let me know, send me some sample text and encoded PDUs from a device that supports it and I'll look at adding it to SmsSubmit.
There is a facility to relax the text conversion and do character replacements for humans, e.g. TAU gets converted into latin 'T', which is probably acceptable although any unmapped chars end up as '?'.
Here's an example:

# -- coding: utf-8 --

from messaging.sms import gsm0338

print u'ΤΡΑΠΕΖΑ'.encode('gsm0338', 'replace').decode('gsm0338')
ajb@polly:~$ python test656664.py
TPAΠEZA

As you can see, it would probably suffice, as least for this example. Unfortunately as far as I can see there's no current way of asking SmsSubmit to relax the encoding. Certainly it will have to be an option as I want to maintain the current behaviour of falling back to UCS-2 if the conversion to GSM0338 is not exact.

from python-messaging.

multijohn avatar multijohn commented on July 20, 2024

Thank u very much , that i was looking for ! It works!!!

Thank u!

from python-messaging.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.