REBOL3 tracker
  0.9.12 beta
Ticket #0001937 User: anonymous


Short URL:
TypeIssue Statusreviewed Date20-Jan-2013 01:22
Version2.101.0 CategoryUnspecified Submitted byPeterWood
PlatformAll Severityminor Prioritynormal

Summary Values cannot be saved to a .txt file without conversion to string! first
Description >> mi: #00000002
== #00000002

>> save %mi.txt mi
** Script error: encode does not allow issue! for its data argument
** Where: if save
** Near: if lib/all [
not header
any [file? where url? where]...
Example code


Assigned ton/a Fixed in- Last Update20-Jan-2013 06:02

20-Jan-2013 06:01

The problem here is that you were trying to use SAVE to save to a .txt file, and .txt files aren't considered to be Rebol data; they're considered to be text, for which we have a codec. When you LOAD from or SAVE to a file type for which we have a codec, the data goes through the codec instead of just being treated like Rebol source. SAVE calls ENCODE and LOAD calls DECODE.

We have a text codec that on decode detects and decodes various Unicode text encodings, converting them to values of the string! type. On encode it converts a string! to one of those Unicode encodings, I think UTF-8 by default. Text doesn't have any fixed syntax, no standard way to format Rebol values, so if you're converting stuff to text you have to decide for yourself how you want them formatted, which means you have to format them yourself using FORM, MOLD, something else, you decide. If you have some non-string value then you haven't decided yet, so it doesn't know how to format it.

Rebol source, on the other hand, is binary. UTF-8 binary, with the body possibly compressed into a compressed binary, and matching a specific syntax. It's a lot more restrictive than regular text, so SAVE doesn't have to make any decisions about how to format it.

So the situation is that this is not actually a bug, it's done on purpose. As an issue: Should it be?

Rebol source is binary, and sometimes it's really binary. When .txt files are transmitted over a network, their line endings may be changed, and this would break checksums at least. And compressed scripts may not even be loadable in a text editor like Notepad, something people tend to do with .txt files. So there would be downsides to removing %.txt from the file types for the text codec.

Date User Field Action Change
20-Jan-2013 06:02 BrianH Summary Modified Most values cannot be saved to a .txt file => Values cannot be saved to a .txt file without conversion to string! first
20-Jan-2013 06:01 BrianH Comment : 0003380 Added -
20-Jan-2013 03:57 BrianH Summary Modified Issue! values cannot be saved => Most values cannot be saved to a .txt file
20-Jan-2013 03:57 BrianH Description Modified -
20-Jan-2013 03:57 BrianH Severity Modified major => minor
20-Jan-2013 03:57 BrianH Status Modified submitted => reviewed
20-Jan-2013 03:57 BrianH Type Modified Bug => Issue
20-Jan-2013 03:57 BrianH Platform Modified Mac OSX => All
20-Jan-2013 01:22 PeterWood Ticket Added -