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

Sublime Text 3 output blank(should be Chinese characters) in console. #1951

Closed
NewUserHa opened this issue Sep 25, 2017 · 8 comments
Closed

Comments

@NewUserHa
Copy link

NewUserHa commented Sep 25, 2017

windows
sublime text 3 build 3143 and build 3126
python3.5.1

--code

a=[]
for _ in range(5000):
a.append('你好你好')
print('\n'.join(a))

--
it works fine with English and numbers, but not any Chinese characters.
the codes works in CMD.
please fix it.

@evandrocoan
Copy link

evandrocoan commented Sep 25, 2017

Seems to be working here. Notice, when you are using unicode characters, you need to add # -*- coding: UTF-8 -*- to your file first line:

#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

a=[]

for _ in range(5):
    a.append('你好你好')
    print('\n'.join(a))

image

@NewUserHa
Copy link
Author

NewUserHa commented Sep 25, 2017

thanks for your reply.
but, sorry, the point is 5000 times and move 'print' out from 'for'. (and the first two lines in your code are meanless in python 3 IMO)

so please fix.

@NewUserHa NewUserHa changed the title Sublime Text 3 output blank in console. Sublime Text 3 output blank(should be Chinese characters) in console. Sep 25, 2017
@titoBouzout
Copy link
Collaborator

titoBouzout commented Sep 25, 2017

Maybe you need add "directwrite" to your font options. Preferences -> Settings - User

https://i.imgur.com/lZEmHAg.png

@NewUserHa
Copy link
Author

Thanks for your reply.
tried but still failed.
sublime console always shows:
"

[Finished in 0.3s]
"

@keith-hall
Copy link
Collaborator

Interestingly, changing the 5000 to 2340 works for me, but any higher values and the print isn't reflected in the build output, nor any prints after it. Python version 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] sys.version_info(major=3, minor=6, micro=1, releaselevel='final', serial=0), Windows 7 x64.

image
image

@wbond
Copy link
Member

wbond commented Oct 20, 2017

The Sublime Text build system expects UTF-8 from the running program – this can be seen in the file Packages/Default/exec.py using https://packagecontrol.io/packages/PackageResourceViewer.

The os.read() call reads up to 32,768 bytes at a time from the program. The string 你好你好 is 12 bytes long in UTF-8, implying 3 bytes per char. 5000 * 12 = 60,000 bytes. 32,768 is not divisible by 3, so the read ends up reading a partial UTF-8 byte sequence. A decode error occurs, which leads to a bug in exec.py causing the error to not be printed.

The fix for this is to:

  1. Keep reading data if the read results in 32,768 bytes – this should help prevent reading a partial byte sequence
  2. Ensure that the decoding error message makes it to the output, but not resetting the proc var

@NewUserHa
Copy link
Author

so is this bug going to be fixed in next release? thanks

@NewUserHa NewUserHa reopened this Oct 21, 2017
@keith-hall keith-hall added this to the Build 3153 milestone Nov 1, 2017
@keith-hall
Copy link
Collaborator

This has been fixed in build 3153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants