misc_bb 7 Posted October 5, 2021 (edited) We are currently dealing with rendering SVG images dynamically and we want to render the SVG using the svg code. Reading the svg code from a text file causing some text to be converted to something. What's the best approach for this one? Convert to UTF-8? Currently trying to create using a TMemoryStream then save the stream to a file via ImageEN but svg text/code gets converted to ascii. Edited October 5, 2021 by misc_bb Share this post Link to post
Alexander Sviridenkov 356 Posted October 5, 2021 When reading text file you should know (or determine) its encoding. Share this post Link to post
David Heffernan 2345 Posted October 5, 2021 Clearly there is a problem but you'd need to provide information on what the data is and precisely how you are processing it before you can get specific help. One thing I can probably say with confidence is that you are falling into the well know Delphi memory stream anti pattern. Share this post Link to post
misc_bb 7 Posted October 5, 2021 Since SVG is composed of XML, I also tried using XMLdocument but loading the content of the file already gave me errors probably because of text layers? (but i still test it again). So basically reading the file or encoding it probably hopefully is the way to go. Share this post Link to post
angusj 126 Posted October 5, 2021 46 minutes ago, misc_bb said: We are currently dealing with rendering SVG images dynamically and we want to render the SVG using the svg code. Reading the svg code from a text file causing some text to be converted to something. What's the best approach for this one? Convert to UTF-8? Currently trying to create using a TMemoryStream then save the stream to a file via ImageEN but svg text/code gets converted to ascii. I'm somewhat confused by your questions. Your first sentence implies you're wanting to bypass the rendering done by ImageEN (mentioned in your fourth sentence). Is that your intention? If so, are you intending to write your own SVG parser and renderer? Share this post Link to post
misc_bb 7 Posted October 5, 2021 (edited) @angusj Not really my intention to bypass. But basically we just want to create the svg file directly using the svg code. In the processing context, I'm not sure exactly if it bypasses the rendering process. I hope I am making sense now 🙂 I was happy working with Image32 but boss wants me to use ImageEN because he purchased it Edited October 5, 2021 by misc_bb Share this post Link to post
angusj 126 Posted October 5, 2021 18 minutes ago, misc_bb said: Not really my intention to bypass. But basically we just want to create the svg file directly using the svg code OK, so if I understand you correctly, you're wanting to create SVG files but use ImageEN to read and render them. My strong recomendation is to create SVGs in UTF-8 format. SVGs were initially designed for web display and it's very rare to find an SVG file that isn't UTF-8 encoded (and just about everything web related is UTF-8). HTHs. Share this post Link to post
misc_bb 7 Posted October 6, 2021 (edited) yes, I think I'm on that direction now as I continue testing and working out a solution. Thanks @angusj Got it figure out now! Thanks everyone! Edited October 6, 2021 by misc_bb Share this post Link to post