[notabug] "invalid string value (was your string larger than 2000 characters?)"
A user of my addon Notebook 2018 just commented that she saved a page, and after checking the SavedVars file for it she saw:
Quote:
Will the game not save any one string at over 2,000 chars? Without error? Why 2,000? Seems arbitrary. I couldn't find info on this issue anywhere. Is this new? Thanks for helping out. I'd appreciate a game dev' that can post an official response about this, to avoid rumors. EDIT: Also brought up was the issue of counting characters when using unicodes wider than 1 char, and how they count towards this. I'd love a response to that, too. |
Any string over 2k is automatically changed to that warning in the saved vars. So if you want to save larger than that you need to split it and save it as a table of strings.
|
Quote:
Quote:
Quote:
|
I would expect an error in-game, or at least a warning, saying that "a string currently has over 2,000 characters and will note save in savedvars!" sorta thing.
And a notice about this in the wiki would have been nice, too. Still waiting on official game dev' to put down the gavel on this one. For example, will this change? No guesses please. |
Quote:
Quote:
|
Yes that limit is set by us, no the limit is not new, and no the limit is not likely to change. We need to define the limit of the buffer somewhere, and as was already mentioned if you need more characters you can make a table.
|
Quote:
How do you do the character count? Referring to unicode wide-characters. Do they count as 1 character or as many bytes as they take? If you can point me to the actual function you use in-game that'd work, too. |
From my tests (about a year ago), ZOS appears to do it by character count, not byte count.
|
Librarian stores book contents in this manner. It has some code you may find useful, maybe.
|
Quote:
|
Quote:
|
Thinking it over, I do use SetMaxInputChars(1984) which is a game function, so it's probably okay. (Untested.)
Notices topic changed. This may not be a bug then, but it's definitely not good. Just letting people save and lose their data. Great info out here guys. Thanks for the #length tip, very useful. Code:
a = "∀∁∂∃∄" |
Just tested it thoroughly.
Apparently SetMaxInputChars() does NOT work with counting unicode wide characters, as #string does. I propose that this is a bug that should be fixed in the game. :) I implemented my own counter and tested it. Everything seems okay. 2,000 characters does NOT save, but 1,999 does. I limited to 1,900 just in case. Code:
local textLen = #text |
I just did my own tests and the string functions don't count unicode characters as others have suggested.
I tested it with the string "これは日本語の文字列です" with string.len, the # operator, two methods proposed on the lua-users wiki and the utf8len function in this gist. Lua Code:
As for your original problem, you can always use a function that manages saving and reading the saved string and split it up dynamically. Here is an example that I just slapped together: Lua Code:
|
Your MAX_SAVE_DATA_LENGTH should be = 1999, as I mentioned above at 2000 it will not save.
I don't think this should be an addon-side issue. Silent save-fail is terrible. The game length functions don't work with unicode correctly. This is a bug in the sense of unexpected arbitrary behavior. |
It was explained why it happens, that is expected behavior and that there are ways to easily work around this necessary technical limitation -> not a bug. That you cannot use string functions in Lua to count multi-byte characters is also common knowledge and not a bug (google lua + unicode or just search the esoui forum).
The save also doesn't fail silently. It prints a comment into the save data why it failed. This is actually just a corner case that you as a developer should have tested when you set the limit for the input field and saved it to disk. If you want to insist on them changing the buffer limit to something higher (which won't resolve anything), or have some error message ingame (which you can easily implement yourself) or want functions to count unicode characters (which you can get from the link I posted), please create an appropriate request on the wish list. Closing this thread now. |
All times are GMT -6. The time now is 01:09 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI