Jump to content




A list of characters, which can be saved into a file


  • You cannot reply to this topic
6 replies to this topic

#1 Luca_S

  • Members
  • 407 posts
  • LocationGermany

Posted 08 February 2015 - 02:46 PM

Hello,

I have a little problem, I need all characters, which can be saved into a file and won't get lost, if i read the file again. I found this already:http://www.computercraft.info/forums2/index.php?/topic/536-box-drawing-characters/
but I dont want the viewable characters. I want the characters which can be saved and read from a File completely correctly, it's not important how you get them, characters got like this:
string.char(17)
are also useable for me. Hope someone can help me,

Luca

#2 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 08 February 2015 - 02:52 PM

If you need to read all characters from a file then there is binary mode for reading files. For instance:

local file = fs.open("out", "wb")
local str = "HELLO WORLD"
for i = 0, #str do
  file.write(string.byte(str:sub(i, i)))
end
file.close

And:
local file = fs.open("out", "rb")
local str = {}
local char
repeat
  char = file.read()
  str[#str + 1] = char
until char == nil
str = table.concat(str)

This reads/writes each byte in turn instead. You could always hex/base64 encode it instead.

Edited by SquidDev, 08 February 2015 - 02:52 PM.


#3 Lignum

  • Members
  • 558 posts

Posted 08 February 2015 - 03:14 PM

I'm not entirely sure but all of these are most definitely writable.

#4 Luca_S

  • Members
  • 407 posts
  • LocationGermany

Posted 14 February 2015 - 09:41 AM

No, I dont need to read all characters on a file, but Lignums characters were enough, thanks :D

#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 14 February 2015 - 11:15 AM

Huh. Looks like some posts were pruned from this thread without explanation. Well that's insulting.

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 14 February 2015 - 09:02 PM

Uh, negative. There are no moderator log entries for actions taken in this topic, so no posts have been removed.

#7 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 14 February 2015 - 10:03 PM

Nevertheless - they're gone!

Maybe it has something to do with the server move.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users