~ubuntu-branches/ubuntu/saucy/sflphone/saucy

« back to all changes in this revision

Viewing changes to sflphone-common/libs/pjproject/pjlib/src/pj/unicode_symbian.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2010-12-24 16:33:55 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101224163355-tkvvikqxbrbav6up
Tags: 0.9.11-1
* New upstream release
* Add new build dependencies on libwebkit-dev and libyaml-dev

* Bump Standards-Version up to 3.9.1
* Bump debhelper compatibility to 8
* Patch another typo in the upstream code (lintian notice)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* $Id: unicode_symbian.cpp 3047 2010-01-06 14:35:13Z bennylp $ */
2
 
/* 
 
2
/*
3
3
 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
4
4
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5
5
 *
15
15
 *
16
16
 * You should have received a copy of the GNU General Public License
17
17
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
19
 *
20
20
 *  Additional permission under GNU GPL version 3 section 7:
21
21
 *
36
36
/*
37
37
 * Convert ANSI strings to Unicode strings.
38
38
 */
39
 
PJ_DEF(wchar_t*) pj_ansi_to_unicode( const char *str, pj_size_t len,
40
 
                                     wchar_t *wbuf, pj_size_t wbuf_count)
 
39
PJ_DEF (wchar_t*) pj_ansi_to_unicode (const char *str, pj_size_t len,
 
40
                                      wchar_t *wbuf, pj_size_t wbuf_count)
41
41
{
42
 
    TPtrC8 aForeign((const TUint8*)str, (TInt)len);
43
 
    TPtr16 aUnicode((TUint16*)wbuf, (TInt)(wbuf_count-1));
 
42
    TPtrC8 aForeign ( (const TUint8*) str, (TInt) len);
 
43
    TPtr16 aUnicode ( (TUint16*) wbuf, (TInt) (wbuf_count-1));
44
44
    TInt left;
45
45
 
46
 
    left = PjSymbianOS::Instance()->ConvertToUnicode(aUnicode, aForeign);
 
46
    left = PjSymbianOS::Instance()->ConvertToUnicode (aUnicode, aForeign);
47
47
 
48
48
    if (left != 0) {
49
 
        // Error, or there are unconvertable characters
50
 
        *wbuf = 0;
 
49
        // Error, or there are unconvertable characters
 
50
        *wbuf = 0;
51
51
    } else {
52
 
        if (len < wbuf_count)
53
 
            wbuf[len] = 0;
54
 
        else
55
 
            wbuf[len-1] = 0;
 
52
        if (len < wbuf_count)
 
53
            wbuf[len] = 0;
 
54
        else
 
55
            wbuf[len-1] = 0;
56
56
    }
57
57
 
58
58
    return wbuf;
62
62
/*
63
63
 * Convert Unicode string to ANSI string.
64
64
 */
65
 
PJ_DEF(char*) pj_unicode_to_ansi( const wchar_t *wstr, pj_size_t len,
66
 
                                  char *buf, pj_size_t buf_size)
 
65
PJ_DEF (char*) pj_unicode_to_ansi (const wchar_t *wstr, pj_size_t len,
 
66
                                   char *buf, pj_size_t buf_size)
67
67
{
68
 
    TPtrC16 aUnicode((const TUint16*)wstr, (TInt)len);
69
 
    TPtr8 aForeign((TUint8*)buf, (TInt)(buf_size-1));
 
68
    TPtrC16 aUnicode ( (const TUint16*) wstr, (TInt) len);
 
69
    TPtr8 aForeign ( (TUint8*) buf, (TInt) (buf_size-1));
70
70
    TInt left;
71
71
 
72
 
    left = PjSymbianOS::Instance()->ConvertFromUnicode(aForeign, aUnicode);
 
72
    left = PjSymbianOS::Instance()->ConvertFromUnicode (aForeign, aUnicode);
73
73
 
74
74
    if (left != 0) {
75
 
        // Error, or there are unconvertable characters
76
 
        buf[0] = '\0';
 
75
        // Error, or there are unconvertable characters
 
76
        buf[0] = '\0';
77
77
    } else {
78
 
        if (len < buf_size)
79
 
            buf[len] = '\0';
80
 
        else
81
 
            buf[len-1] = '\0';
 
78
        if (len < buf_size)
 
79
            buf[len] = '\0';
 
80
        else
 
81
            buf[len-1] = '\0';
82
82
    }
83
83
 
84
84
    return buf;