Thanks to forum help last week I thought I was sorted on displaying the UK currency symbol correctly in a string. I decided to update an old program and the wrong output from my ‘new found knowledge’ is shown below;
Do you need to change the encoding at all? Have a look at txtPC1.text and and fldPC1.text in the debugger. Then build your curr value piece by piece while checking the encoding.
I am getting closer. The ‘output’ string looks correct in the debugger. I am using (as its an old project) ‘fpdf’, which is fine. The encoding issue seems to be internal to this so I am just looking trhough the code to see how it defines the encoding it uses.
fpdf does not support UTF8, see fpdf.rbbas (code starting at line 2010):
Sub SetEnconding(enc as textEncoding)
//gdf: set the string encoding used internally by rsFPDF
//note that FPDF does not support UTF, but this method allows
//to convert to other encodings, such as WindowsLatin1
//(Windows 1252, with Euro sign) or
//ISOLatin9 (ISO 8859-15, with Euro sign)
me.InternalEncoding = enc
End Sub
[quote]curr=format(cdbl(txtPC1.text),"\£###,###.00")
[/quote]
Let’s unwrap your code a little. Strings that Xojo creates will be UTF8 by default, so working from the inside out
txtPC1.text // should be UTF8, but it doesn’t matter because you’re just going to convert it to a number
cdbl(txtPC1.text) // produces a number
format(cdbl(txtPC1.text),"\£###,###.00") // this string will be UTF8
So you see that neither DefineEncoding or ConvertEncoding to UTF8 will have any effect on the string, since it is already UTF8 to begin with. However, Eli is correct, you need to ConvertEncoding to the encoding that fpdf expects. Try Encodings.WindowsANSI or Encodings.ISOLatin9.
[quote] output=fldPC1.text+" @ “+format(ratenormal,”\£##.00")+"="+format(cdbl(txtPC1.text),"\£###,###.00")
[/quote]
Again, looking at the pieces
fldPC1.text // UTF8
" @ " // UTF8
format(ratenormal,"\£##.00") // UTF8
“=” // UTF8
format(cdbl(txtPC1.text),"\£###,###.00") // UTF8, as seen above
The combination of these strings will again be UTF8, but must be converted to the encoding used by fpdf.