Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-5878

Android: Titanium.UI.TextArea does not decode UTF8 character correctly.

    Details

      Description

      TextArea does not decode UTF8 character correctly.

      Repro Steps

      Step 1: Open Kitchen Sink on Android
      Step 2: Go to Platform - XHR - UTF-8 + GET/POST

      Expected result: The string "€漢字" should be shown in the textarea.
      Actual result: Some garbage characters was shown.

      Workaround

      In Javascript code, call the following decode function to decode what returns from HttpClient's responseText.

      var myDecode = function (utftext) {
      		var string = "";
      		var i = 0;
      		var c = c1 = c2 = 0;
       
      		while ( i < utftext.length ) {
       
      			c = utftext.charCodeAt(i);
       
      			if (c < 128) {
      				string += String.fromCharCode(c);
      				i++;
      			}
      			else if((c > 191) && (c < 224)) {
      				c2 = utftext.charCodeAt(i+1);
      				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
      				i += 2;
      			}
      			else {
      				c2 = utftext.charCodeAt(i+1);
      				c3 = utftext.charCodeAt(i+2);
      				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
      				i += 3;
      			}
       
      		}
       
      		return string;
      }
      

      Associated Helpdesk Ticket

      http://appc.me/c/APP-589719

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pwang Ping Wang
                Reporter:
                qgao Qing Gao
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-5001
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code