Skip to content

Instantly share code, notes, and snippets.

@kainino0x
Last active February 17, 2022 01:54
Show Gist options
  • Save kainino0x/90b9607ec50beef14fbf592f8887e388 to your computer and use it in GitHub Desktop.
Save kainino0x/90b9607ec50beef14fbf592f8887e388 to your computer and use it in GitHub Desktop.
compiler "column" numbers

Clang - UTF-8 code units (bytes)

int main() {
/*xxx*/int x=xx; // codepoints=11+3=14, utf8units=11+3=14, utf16units=11+3=14, clusters=11+3=14
/*日本語*/int x=xx; // codepoints=11+3=14, utf8units=11+9=20, utf16units=11+3=14, clusters=11+3=14
/*👩‍💻*/int x=xx; // codepoints=11+3=14, utf8units=11+11=22, utf16units=11+5=16, clusters=11+1=12
}
main.c:2:14: error: use of undeclared identifier 'xx'
/*xxx*/int x=xx; // codepoints=11+3=14, utf8units=11+3=14, utf16units=11+3=14, clusters=11+3=14
             ^
main.c:3:20: error: use of undeclared identifier 'xx'
/*日本語*/int x=xx; // codepoints=11+3=14, utf8units=11+9=20, utf16units=11+3=14, clusters=11+3=14
                ^
main.c:4:22: error: use of undeclared identifier 'xx'
/*👩<U+200D>💻*/int x=xx; // codepoints=11+3=14, utf8units=11+11=22, utf16units=11+5=16, clusters=11+1=12
                    ^

Rustc - Codepoints

fn main() {
/*xxx*/let x=xx; // codepoints=11+3=14, utf8units=11+3=14, utf16units=11+3=14, clusters=11+3=14
/*日本語*/let x=xx; // codepoints=11+3=14, utf8units=11+9=20, utf16units=11+3=14, clusters=11+3=14
/*👩‍💻*/let x=xx; // codepoints=11+3=14, utf8units=11+11=22, utf16units=11+5=16, clusters=11+1=12
}
error[E0425]: cannot find value `xx` in this scope
 --> src/main.rs:2:14
  |
2 | /*xxx*/let x=xx; // codepoints=11+3=14, utf8units=11+3=14, utf16units=11+3=14, clusters=11+3=14
  |              ^^ not found in this scope

error[E0425]: cannot find value `xx` in this scope
 --> src/main.rs:3:14
  |
3 | /*日本語*/let x=xx; // codepoints=11+3=14, utf8units=11+9=20, utf16units=11+3=14, clusters=11+3=14
  |                 ^^ help: a local variable with a similar name exists: `x`

error[E0425]: cannot find value `xx` in this scope
 --> src/main.rs:4:14
  |
4 | /*👩💻*/let x=xx; // codepoints=11+3=14, utf8units=11+11=22, utf16units=11+5=16, clusters=11+1=12
  |               ^^ help: a local variable with a similar name exists: `x`

Go - UTF-8 code units (bytes)

package main

var y = 0 // y
/*xxx*/ var x = xx // codepoints=14+3=17, utf8units=14+3=17, utf16units=14+3=17, clusters=14+3=17
/*日本語*/ var x = xx // codepoints=14+3=17, utf8units=14+9=23, utf16units=14+3=17, clusters=14+3=17
/*👩‍💻*/ var x = xx // codepoints=14+3=17, utf8units=14+11=25, utf16units=14+5=19, clusters=14+1=15

func main() {}
./prog.go:6:17: undefined: xx // codepoints=14+3=17, utf8units=14+3=17, utf16units=14+3=14, clusters=14+3=17
./prog.go:7:23: undefined: xx // codepoints=14+3=17, utf8units=14+9=23, utf16units=14+3=14, clusters=14+3=17
./prog.go:8:25: undefined: xx // codepoints=14+3=17, utf8units=14+11=25, utf16units=14+5=19, clusters=14+1=15

JavaScript

/*👩‍💻*/var x=xx; // codepoints=11+3=14, utf8units=11+11=22, utf16units=11+5=16, clusters=11+1=12

JavaScript (Chrome/V8) - UTF-16 code units

  • error on 1:16, dev tools underlines the correct text

JavaScript (Node/V8) - UTF-16 code units

  • error on 1:16, ascii art points to the wrong text (points to column 16)

JavaScript (Firefox) - Codepoints

  • error on 1:14, dev tools underlines the wrong text

JavaScript (Safari) - ???

  • no error line in the exception, but error sidebar shows 1:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment