MightyPirates / OpenComputers

Home of the OpenComputers mod for Minecraft.
https://oc.cil.li
Other
1.59k stars 430 forks source link

Stock Editor Breaks With � #2454

Closed J0SLAN closed 7 years ago

J0SLAN commented 7 years ago

� in the stock editor of OpenOS causes weird errors* and effects** of weird proportions.

payonel commented 7 years ago

screen shots and a better description would be helpful.

  1. what version of openos
  2. what � value are you dealing with, i.e., what is the result of the following where v is your � value =unicode.wlen(v) =unicode.len(v) =#v for i=1,#v do io.write(string.byte(v[i]), ' ') end
J0SLAN commented 7 years ago

OpenOS 1.6.2. I mean the actual � character. The one in the bug report. I think it's 0xFFFD. Pasting it works. And it's not just errors. Changing my report to say errors doesn't help anything; at best it makes it incomplete. Screenshotting the effects won't help much, but here's an error that can happen when pasting it around: image And here's one for putting the cursor in some places when the file already has the character: image To see the visual effects you just have to mess around with it. Inconsistency is the main thing.

payonel commented 7 years ago

Thanks for the screen shot, it was quite helpful. It told me immediately what the problem is, and I tested it to confirm:

This is a problem with unicode 0xFFFD is that the utf8 engine OC is using cannot correctly truncate this string. This isn't a problem with /bin/edit specifically, but with our unicode library and its wtrunc function.

This is actually the same problem faced by #2384 In fact, if you fill a file large enough with 0xFFFD, and then cat it to the screen, you'd hit the same error.