ConwayLife.com - A community for Conway's Game of Life and related cellular automata
Home  •  LifeWiki  •  Forums  •  Download Golly

Golly 3.1

For general discussion about Conway's Game of Life.

Golly 3.1

Postby Andrew » October 16th, 2017, 7:40 pm

Golly 3.1 is now available from sourceforge:

https://sourceforge.net/projects/golly/ ... golly-3.1/

Changes since 3.0:

- Fixed bugs in the Larger than Life algorithm that caused Golly to crash.

- Scripts can call g.setoption("showprogress",0) to prevent the progress dialog from appearing (useful for scripts that you want to run in the background).

- Updated the Life Lexicon to release 27.
User avatar
Andrew
Moderator
 
Posts: 629
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia

Re: Golly 3.1

Postby wildmyron » November 17th, 2017, 12:27 am

There seem to be several bugs with unicode strings in Golly. I've only tested this with Golly 3.0 (on Win7 x64) but I don't believe any relevant code changed in 3.1. I believe all of the tests I've done have used UTF-8, but I'm not 100% certain of that.

The main issue for me is that g.getclipstr() returns an empty string when the text on the clipboard contains a unicode character. The behaviour is identical using Python and Lua. While investigating the issue I found the same thing happens with g.getstring(). Here's a simple way to reproduce:
-- Test unicode strings

local g = golly()
local ustring = g.getstring("Enter string", "")
g.note(ustring)

Run this script in Golly and paste the following string in (from A for Awesome's signature)
A for Awesome wrote:x₁=ηx

The result is a blank Note window (same thing in Python).

Including unicode characters in a script (run from the clipboard) causes the language detection to fail:
local g = golly()
g.note("x₁=ηx")

Run from the clipboard, this causes a Syntax error in the Python interpreter.

This sort of works when saved as a file:
-- Test unicode strings
local g = golly()
g.note("x"..utf8.char(0x2081).."="..utf8.char(0x3B7).."x")
g.note("x₁=ηx")

both resulting Note windows contain
x₁=ηx


Trying to get at least something with UTF-8 to work in Python I found the following: (all run from clipboard)
import golly as g
g.note(u"x₁=ηx")

gives a syntax error:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ariep\AppData\Roaming\Golly\golly_clip.py", line 2
SyntaxError: Non-ASCII character '\xe2' in file C:\Users\ariep\AppData\Roaming\Golly\golly_clip.py on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
... probably not surprising.

# -*- coding: utf-8 -*-
import golly as g
g.note(u"x₁=ηx")

raises an exception
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ariep\AppData\Roaming\Golly\golly_clip.py", line 3, in <module>
    g.note(u"x₁=ηx")
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2081' in position 1: ordinal not in range(128)


import golly as g
g.note(u"x\u2081=\u03B7x")

raises the same exception:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\ariep\AppData\Roaming\Golly\golly_clip.py", line 2, in <module>
    g.note(u"x\u2081=\u03B7x")
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2081' in position 1: ordinal not in range(128)


import golly as g
g.note(u"x\u2081=\u03B7x".encode('utf-8'))

and
# -*- coding: utf-8 -*-
import golly as g
g.note(u"x₁=ηx".encode('utf-8'))

both give the same result as the corresponding lua script above
x₁=ηx


I readily admit that I have no idea what I'm doing here. To be honest - all I care about is g.getclipstr() giving me something, even if it doesn't preserve the unicode characters. The current behaviour breaks scripts like importRLE.py when there are some unicode characters interspersed amongst the rle patterns to be imported.
wildmyron
 
Posts: 585
Joined: August 9th, 2013, 12:45 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests