Complete

WERETECH-10739

Fixed

Bug in compilator , with String.equals and utf8 symbol

Function Always show false, but symbol the same. 

var dTExt = "";  

Toybox.System.println( ((dTExt.equals("") ))  );  


Parents
  • I've tested the following code with several SDKs (3.1.8, 3.2.5, and 4.0.0.preview1) and it reports true for all four cases.

    var dTExt = "";
    System.println(dTExt.equals(dTExt));
    System.println(dTExt.equals(""));
    System.println("".equals(dTExt));
    System.println("".equals(""));

    I also tested with the the multi-byte utf-8 string "aфᐃ" and got the expected results there as well. Here is information on those code points.

    | Glyph     | Escape   |   Code Point | Unicode Name                       |
    |:----------|:---------|-------------:|:-----------------------------------|
    | a  | \u0061   |           97 | LATIN SMALL LETTER A               |
    | ф  | \u0444   |         1092 | CYRILLIC SMALL LETTER EF           |
    | ᐃ  | \u1403   |         5123 | CANADIAN SYLLABICS I               |

    I'm not 100% sure that I can trust that the glyph that appears in your original message is what you intended to type. Can you tell me what character you are testing, or what the utf8 bytes for it are so that I can be sure I'm testing the same thing you are reporting?

Comment
  • I've tested the following code with several SDKs (3.1.8, 3.2.5, and 4.0.0.preview1) and it reports true for all four cases.

    var dTExt = "";
    System.println(dTExt.equals(dTExt));
    System.println(dTExt.equals(""));
    System.println("".equals(dTExt));
    System.println("".equals(""));

    I also tested with the the multi-byte utf-8 string "aфᐃ" and got the expected results there as well. Here is information on those code points.

    | Glyph     | Escape   |   Code Point | Unicode Name                       |
    |:----------|:---------|-------------:|:-----------------------------------|
    | a  | \u0061   |           97 | LATIN SMALL LETTER A               |
    | ф  | \u0444   |         1092 | CYRILLIC SMALL LETTER EF           |
    | ᐃ  | \u1403   |         5123 | CANADIAN SYLLABICS I               |

    I'm not 100% sure that I can trust that the glyph that appears in your original message is what you intended to type. Can you tell me what character you are testing, or what the utf8 bytes for it are so that I can be sure I'm testing the same thing you are reporting?

Children
  • You equal  only 1 symbol 
    try diferent:
    1:  

    2: 

    code of symbols  and 

    This bug  i was get when redraw new icon from font, and check new with old text  

  • I can't reproduce. Here is the source for my test app.

    using Toybox.Application;
    using Toybox.WatchUi;
    using Toybox.System;
    
    function as_hex_bytes(s) {
    	var r = [];
    	
    	var a = s.toUtf8Array();
    	for (var i = 0; i < a.size(); ++i) {
    		r.add("\\x" + a[i].format("%X"));
    	}
    	
    	return r;
    }
    
    function as_code_points(s) {
    	var r = [];
    	
    	var a = s.toCharArray();
    	for (var i = 0; i < a.size(); ++i) {
    		r.add(a[i].toNumber());
    	}
    	
    	return r;
    }
    
    function as_unicode_escapes(s) {
    	var r = [];
    	
    	var a = s.toCharArray();
    	for (var i = 0; i < a.size(); ++i) {
    		r.add("\\u" + a[i].toNumber().format("%X"));
    	}
    	
    	return r;
    }
    
    class ForumTestApp extends Application.AppBase {
    
        function initialize() {
            AppBase.initialize();
            
    		var s = "";
    		// var s = "\uEACA";
    		System.println(s);
    		
    		System.println(as_hex_bytes(s));
    		System.println(as_code_points(s));
    		System.println(as_unicode_escapes(s));
    	
    		System.println(s.equals(s));
    		System.println(s.equals(""));
    		System.println("".equals(s));
    		System.println(s.equals("\uEACA"));
    		System.println("\uEACA".equals(s));
        }
    
        function getInitialView() {
            return [ new WatchUi.View() ];
        }
    
    }
    

    The output in the eclipse console is:

    
    [\xEE, \xAB, \x8A]
    [60106]
    [\uEACA]
    true
    true
    true
    true
    true
    

  • Sorry i give you wrong start data 
    Its old bug, foget how it work

    //code 60106  ,  code60107  - 0ff

    allways show true, but symbol not equal , tested now on 3.2.5 


    var dTExt = "";
    Toybox.System.println( ((dTExt.equals("") )) );

    if i add "1" to both text - function show false 

    //60106  - on 60107  - 0ff
    var dTExt = "1";
    Toybox.System.println( ((dTExt.equals("1") )) );

    thats how i fix this isue