iOS Question StringsUtil LoadCSV issue

iCAB

Well-Known Member
Licensed User
Longtime User
Hi All

The attached file is generating an error with B4I (but not B4A) when loaded using the code below
B4X:
lstLanguageStrings = StringUtils1.LoadCSV(File.DirAssets, "language_strings.csv", ",")

Any feedback is greatly apreciated
 

Attachments

  • SampleFile.zip
    208 bytes · Views: 278

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Erel, here is a little background to help.
The original file contains strings used by the application to display various messages. I was able to narrow down the issue to the line I kept in the attached file. I believe it is related to the 3 dots in "This is a test…", if you remove the dots the file will load

Thank you for the great support

Here is the error message.


B4X:
Error occurred on line: 421 (Lang)
Error reading file. Incorrect encoding
Stack Trace: (
  CoreFoundation       <redacted> + 150
  libobjc.A.dylib      objc_exception_throw + 38
  CoreFoundation       <redacted> + 0
  B4i Example          -[B4IFile ReadString2:::] + 500
  B4i Example          -[B4IFile ReadString::] + 86
  B4i Example          -[iStringUtils LoadCSV2::::] + 206
  B4i Example          -[iStringUtils LoadCSV:::] + 48
  CoreFoundation       <redacted> + 68
  CoreFoundation       <redacted> + 292
  B4i Example          +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1786
B4i Example          -[B4IShell runMethod:] + 574
B4i Example          -[B4IShell raiseEventImpl:method:args::] + 1998
B4i Example          -[B4IShellBI raiseEvent:event:params:] + 1442
B4i Example          +[B4IDebug delegate:::] + 52
B4i Example          -[b4i_lang _getlanguagestringbyid:] + 442
B4i Example          -[b4i_main _pickupanddropoff_callfromresizepage] + 1114
B4i Example          -[b4i_main _page1_resize::] + 796
CoreFoundation       <redacted> + 68
CoreFoundation       <redacted> + 292
B4i Example          +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1786
B4i Example          -[B4IShell runMethod:] + 574
B4i Example          -[B4IShell raiseEventImpl:method:args::] + 2212
B4i Example          -[B4IShellBI raiseEvent:event:params:] + 1442
B4i Example          +[B4IObjectWrapper raiseEvent:::] + 220
B4i Example          __30-[B4IPanelView layoutSubviews]_block_invoke + 1034
libdispatch.dylib    <redacted> + 10
libdispatch.dylib    <redacted> + 22
libdispatch.dylib    _dispatch_main_queue_callback_4CF + 1532
CoreFoundation       <redacted> + 8
CoreFoundation       <redacted> + 1590
CoreFoundation       CFRunLoopRunSpecific + 516
CoreFoundation       CFRunLoopRunInMode + 108
GraphicsServices     GSEventRunModal + 160
UIKit                UIApplicationMain + 144
B4i Example          main + 108
libdyld.dylib        <redacted> + 2
)
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
StringUtils.LoadCSV expects the file to be encoded in UTF8. Your file is encoded in a different encoding so there is an error.

You can use File.ReadString2 to load the file. Try it with "Windows-1250" encoding. Then save it to a temporary file with File.WriteString.

Sure I will do, but can you please tell me how come the same file works with B4A no problem

Thank you
 
Upvote 0
Top