File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,16 +34,28 @@ pub fn (mut ctx Context) write(s string) {
3434 unsafe { ctx.print_buf.push_many (s.str, s.len) }
3535}
3636
37+ // write_to_stdout writes a string to stdout.
38+ // On Windows, V's standard output path is used, since it converts UTF-8
39+ // to UTF-16 for consoles, where the code page may not be UTF-8.
40+ @[inline]
41+ fn write_to_stdout (s string ) {
42+ $if windows {
43+ print (s)
44+ return
45+ }
46+ C.write (1 , s.str, s.len)
47+ }
48+
3749// flush displays the accumulated print buffer to the screen.
3850@[inline]
3951pub fn (mut ctx Context) flush () {
4052 // TODO: Diff the previous frame against this one, and only render things that changed?
4153 if ! ctx.enable_su {
42- C. write ( 1 , ctx.print_buf.data, ctx.print_buf.len)
54+ write_to_stdout ( unsafe { tos ( ctx.print_buf.data, ctx.print_buf.len) } )
4355 } else {
44- C. write ( 1 , bsu.str, bsu.len )
45- C. write ( 1 , ctx.print_buf.data, ctx.print_buf.len)
46- C. write ( 1 , esu.str, esu.len )
56+ write_to_stdout ( bsu)
57+ write_to_stdout ( unsafe { tos ( ctx.print_buf.data, ctx.print_buf.len) } )
58+ write_to_stdout ( esu)
4759 }
4860 ctx.print_buf.clear ()
4961}
You can’t perform that action at this time.
0 commit comments