Acknowledged

debugger in vsCode incorrectly prints escape character for double quotation mark

This bug concerns a problem that exists on the debugger output only.  I do not know if it exists yet, when ConnectIQ apps output debug messages inside the debug .TXT file that users have access to.

Previously this code would print out properly in the debugger:

       System.println ("test double quotation here -> ' \" ' "));
       // output:--------------------------------------------------------
       test double quotation here -> ' " '

Also, this code would print out properly:

       System.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
       System.println("<kml xmlns=\"htp://www.opengis.net/kml/2.2\">");
       // output:--------------------------------------------------------
       <?xml version="1.0" encoding="UTF-8"?>
       <kml xmlns="htp://www.opengis.net/kml/2.2">
       // htp text used to prevent automatic link from being created in forum

But today 2023.09.30 it prints out incorrectly:

       //output1:

       test double quotation here -> ' \" '

       //output2:

       <?xml version=\"1.0\" encoding=\"UTF-8\"?>
       <kml xmlns=\"htp://www.opengis.net/kml/2.2\">

This is perhaps a unimportant error, but it is frustrating, and poses problems for developers who rely upon the debugger and common functions to work as expected.  Programmers expect their debugger and print functions to work as they are meant to, not cough out extra characters from time to time.  This function was working a handful of months ago, not sure what or how it became broken.

See this forum link for more information:

https://forums.garmin.com/developer/connect-iq/f/discussion/347734/how-to-println-double-quotation-mark-using-println

Please fix it!

  • Still a problem with SDK 7.4.3

  • this still happens in SDK 6.4.2

  • Java:

    public class HelloWorld {
         public static void main(String[] args) {
            System.out.println("\"");
         }
    }

    Output:

    "
  • Just to complete the python example:

    >>> logging.warning("\"")
    WARNING:root:"
  • I agree that this is extremely odd and misleading behavior.

    As noted in the linked thread, there are other ways to pass a " character to System.println() besides passing a string literal containing \", so the argument put forth in that thread that System.println() simply prints the "string without modification" is invalid. (Of course any sane implementation of string literals would result in System.println() not even seeing the \ escape character in the first place.)

    e.g.

    - user input

    - code such as:

    System.println('"'.toString());

    It's also worth noting that \, which also requires escaping when it appears in a string literal, does NOT receive the same treatment, which makes that argument doubly invalid.

    System.println("quote = \"");
    System.println("backslash = \"");
    System.println("backslash + quote = \\\"");
    Output:
    quote = \"
    backslash = \
    backslash + quote = \\"

    Unsurprisingly, other languages don't have the same behavior:

    >node
    Welcome to Node.js v14.16.1.
    Type ".help" for more information.
    > console.log("\"");
    "
    undefined

    >python3
    Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import logging
    >>> logging.warning('"')
    WARNING:root:"