Ascii and Glulx - a match made in ... hell?

Yes. What is your terminal encoding? CheapGlk does all input and output in Latin-1, unless you pass the -u argument, in which case it uses UTF-8.

You can, but I don’t like the tradeoff. You’d have to distribute the game as multiple files, and you may run into issues with getting the data files into the right place on the user’s machine. (How would it work with iOS Frotz, for example? I really don’t know; I haven’t tried running a game on iOS that uses external files.)

Converting your ASCII file into a run-on print statement is ugly, but it takes just a minute to do with a text editor (or a Perl/Python script if you lean that way) and then you paste it into your source code and it works. Leave it alone thereafter.

1 Like

Does Inform have a raw string literal or character data – something like CDATA?

Ah, I think I figured it out. A column of leading [line break]s will preserve any leading whitespace – that makes the ASCII line easily visible (or easily editable) in the source without needing to collapse them into one data line.

"ASCII Art Views" by Jeremy Douglass
[based on "ASCII Art Test Case" by Andrew Plotkin.]

The Kitchen is a room. "Examine one of the things here for ASCII art."

The moonliteral is in the Kitchen. Understand "moonlit" as the moonliteral.

Instead of examining the moonliteral:
	say fixed letter spacing;
	say "
[line break]              .----------.              
[line break]          .--'   o    .   `--.          
[line break]       .-'@  @@@@@@ O   .   . `-.       
[line break]     .' @@  @@@@@@@@   @@@@   .  `.     
[line break]    /     . @@@@@@@@  @@@@@@     . \    
[line break]   /@@  o    @@@@@@.   @@@@    O   @\   
[line break]  /@@@@                @@@@@@     @@@\  
[line break] . @@@@@   `.-./    . @@@@@@@@  .  @@ . 
[line break] | @@@@   --`-'  .      @@@@@@@       | 
[line break] |@ @@        `      o  @@@@@@ @@@@   | 
[line break] |      @@        o      @@   @@@@@@  | 
[line break] ` .  @       @@     ()   @@@  @@@@   ' 
[line break]  \     @@   @@@@        . @@   .  o /  
[line break]   \   @@@@  @@\  .           o     /   
[line break]    \ . @@     _\ /    .      .-.  /    
[line break]     `.    .    ()---        `-' .'     
[line break]       `-.    ./ |  .   o     .-'       
[line break]          `--./   .       .--'          
[line break]              `----------'              
[line break]
";
	say variable letter spacing;
	say "(Image from the Phoon utility, originally by Jef Poskanzer.)";

test me with "x moonlit";	

Edit: One caveat: Inform is replacing all of the ' characters with " in the displayed output in every in-code string example above.

The only method above that is actually showing the ASCII data correctly is the file load method.

As the docs explain in chapter 5.2. You can use “[apostrophe]”, “[quotation mark]” as needed. Also maybe “[bracket]”, “[close bracket]”.

Again, the converted source is ugly, but I’d rather pay a one-time effort cost now rather than complicating things for users later on.

1 Like

Here’s what I use for this, in case it helps anyone else. Give it ASCII art (either passing file names on the command line, or via stdin) and it’ll turn it into a string suitable for embedding into I7 source.

#!/usr/bin/env python3

substitutions = (
	('[' , '\udc00'), # Surrogate character guaranteed not to appear in input
	(']' , '\udc01'), # Same
	('\udc00' , '[bracket]'),
	('\udc01' , '[close bracket]'),
	("'" , '[apostrophe]'),
	('"' , '[quotation mark]'),
	('\n' , '[line break]'),
)

def informify(s):
	for src, dst in substitutions:
		s = s.replace(src, dst)
	return f'"[fixed letter spacing][line break]{s}[variable letter spacing]"'

if __name__ == '__main__':
	import fileinput
	print(informify('\n'.join(fileinput.input())))

This turns the moon image into the illegible but Inform-correct:

"[fixed letter spacing][line break]              .----------.             [line break][line break]          .--[apostrophe]   o    .   `--.         [line break][line break]       .-[apostrophe]@  @@@@@@ O   .   . `-.      [line break][line break]     .[apostrophe] @@  @@@@@@@@   @@@@   .  `.    [line break][line break]    /     . @@@@@@@@  @@@@@@     . \   [line break][line break]   /@@  o    @@@@@@.   @@@@    O   @\  [line break][line break]  /@@@@                @@@@@@     @@@\ [line break][line break] . @@@@@   `.-./    . @@@@@@@@  .  @@ .[line break][line break] | @@@@   --`-[apostrophe]  .      @@@@@@@       |[line break][line break] |@ @@        `      o  @@@@@@ @@@@   |[line break][line break] |      @@        o      @@   @@@@@@  |[line break][line break] ` .  @       @@     ()   @@@  @@@@   [apostrophe][line break][line break]  \     @@   @@@@        . @@   .  o / [line break][line break]   \   @@@@  @@\  .           o     /  [line break][line break]    \ . @@     _\ /    .      .-.  /    [line break][line break]     `.    .    ()---        `-[apostrophe] .[apostrophe]     [line break][line break]       `-.    ./ |  .   o     .-[apostrophe]       [line break][line break]          `--./   .       .--[apostrophe]          [line break][line break]              `----------[apostrophe]              [line break][variable letter spacing]"

The only complicated part is handling brackets right: we want to replace [ and ] with [bracket] and [close bracket], but without affecting the brackets in our replacement expressions themselves.

This code handles that by first replacing all brackets with characters that are guaranteed never to appear on their own (lone surrogates), then replacing those characters with the Inform substitutions.

3 Likes

:smile: The -u parameter did the trick. THANKS! :star_struck:

image

My terminal indicates it is set to Unicode UTF-8.

2 Likes