Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

char literals are not transpiled correctly (using charCodeAt instead of charAt) #19

Open
ZaneDubya opened this issue Jun 23, 2015 · 1 comment
Labels

Comments

@ZaneDubya
Copy link
Contributor

C# code:

                char c = line[i];
                if (c == '\"')
                {
                    if (inDoubleQuote)
                    {
                        inDoubleQuote = false;
                        dataFields.Add('\"' + field);
                        field = string.Empty;
                    }
                    else
                    {
                        inDoubleQuote = true;
                    }
                }

Is transpiled to:

                    var c: number = line.charCodeAt(i);
                    if (c === 34/*'"'*/)
                    {
                        if (flag)
                        {
                            flag = false;
                            list.Add(34 + /*'"'*/text);
                            text = NString.Empty;
                        }
                        else
                        {
                            flag = true;
                        }
                    }

Obviously, this breaks string + char addition where the char came from a string (see the 'list.Add' line). Is there a way to prefer using charAt instead of charCodeAt?

@praeclarum
Copy link
Owner

Ouch. I will need to think about this. I did have a reason to prefer charCode, but I don't recall what it was. I'll look into it.

@praeclarum praeclarum added the bug label Nov 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants