Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » From std::string to String
Re: From std::string to String [message #49463 is a reply to message #49460] Thu, 15 February 2018 09:47 Go to previous messageGo to previous message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Klugier wrote on Wed, 14 February 2018 21:20
Hello,

Try to create Upp::String basing on std::string like this:
String(fields[0]);



Actually, I tried that already: it compiles, but I still have gibberish in the db instead of the correct characters


Klugier wrote on Wed, 14 February 2018 21:20

IMO, you should use Core library to deal with text files. The easiest way is to use LoadFile(path):
Upp::String fileContent = Upp::LoadFile("PathToTextFile.txt");

// now you could use some powerfull functions from Core like Split;
Upp::Vector<String> fileContentLines = Upp::Split(fileContent, "\n");
for (const String& line : fileContentLines) {
    // Loop over the line...
}


I will start from rewriting you code from standard library into Upp approch. This could save you problems with file encoding conversion.



Do you mean Upp can read data from an Ansi encoded file and convert it to utf-8 automatically? Currently I use stream from standard c++ library to read data from file.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Filtering CR from an EditString
Next Topic: MSSQL and codepage
Goto Forum:
  


Current Time: Tue Jul 08 14:39:07 CEST 2025

Total time taken to generate the page: 0.05822 seconds