Missing currency symbol

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

Missing currency symbol

Postby pk_fox » Thu Jun 26, 2014 7:04 am

Hi all, I'm using postgres as my database server and have come across a weird problem, in my postgres stored procedure I cast a numeric field to a formatted string which includes the currency symbol, e.g. 123.76 comes out as "£123.76", viewing the output in postgres shows the output of type text which is as expected, but when I get the result of my sp into a ADO.NET dataset/datatable it comes through as a string OK but the currency symbol is missing and a leading blank is shown in its place - any ideas ?
We can't stop here, this is bat country. Hunter S Thompson RIP.
User avatar
pk_fox
LXF regular
 
Posts: 292
Joined: Wed Apr 13, 2005 1:38 pm
Location: Surrey, UK

Postby Dutch_Master » Thu Jun 26, 2014 10:19 am

Re-install the affected font? That is, if you're sure that font should have the missing symbol in the first place, if the symbol wasn't defined in the font I'm not surprised it doesn't show up ;) Change to a different font to see where the issue actually is: if the missing symbol turns up, there's a problem with the original font.
Dutch_Master
LXF regular
 
Posts: 2440
Joined: Tue Mar 27, 2007 1:49 am

Postby pk_fox » Thu Jun 26, 2014 10:23 am

Dutch_Master wrote:Re-install the affected font? That is, if you're sure that font should have the missing symbol in the first place, if the symbol wasn't defined in the font I'm not surprised it doesn't show up ;) Change to a different font to see where the issue actually is: if the missing symbol turns up, there's a problem with the original font.


Hi there, it's not a font problem, the symbol ("£" in this case ) is not being inserted into the dataset
We can't stop here, this is bat country. Hunter S Thompson RIP.
User avatar
pk_fox
LXF regular
 
Posts: 292
Joined: Wed Apr 13, 2005 1:38 pm
Location: Surrey, UK

Postby johnhudson » Thu Jun 26, 2014 8:51 pm

This is guesswork but the question is: what does postgres actually do?

AFAIK currency formats are not part of SQL; so, even if you CAST() a number as a currency and postgres displays it correctly, it may, for compatibility reasons, not be exported as such.

Alternatively, you may need to investigate the import options of the program that receives the data and match the postgres output to that - for example, currency symbols may not be accepted as part of numeric data.
johnhudson
LXF regular
 
Posts: 873
Joined: Wed Aug 03, 2005 1:37 pm

Postby pk_fox » Thu Jun 26, 2014 9:08 pm

johnhudson wrote:This is guesswork but the question is: what does postgres actually do?

AFAIK currency formats are not part of SQL; so, even if you CAST() a number as a currency and postgres displays it correctly, it may, for compatibility reasons, not be exported as such.

Alternatively, you may need to investigate the import options of the program that receives the data and match the postgres output to that - for example, currency symbols may not be accepted as part of numeric data.


Hi John, its not numeric data it's cast as text and as I stated earlier it comes through as such in the dataset and data table , something unbeknown to me is obviously happening on the journey from postgres to my programme, one thing I've tried ( among many ) is to remove the formatting in postgres I.e don't include the symbol and it still comes through with a leading blank space.
We can't stop here, this is bat country. Hunter S Thompson RIP.
User avatar
pk_fox
LXF regular
 
Posts: 292
Joined: Wed Apr 13, 2005 1:38 pm
Location: Surrey, UK

Postby johnhudson » Fri Jun 27, 2014 8:48 pm

Then is there an encoding problem, e.g. utf8 to unicode 16 or something like that?
johnhudson
LXF regular
 
Posts: 873
Joined: Wed Aug 03, 2005 1:37 pm

Postby pk_fox » Fri Jun 27, 2014 9:05 pm

johnhudson wrote:Then is there an encoding problem, e.g. utf8 to unicode 16 or something like that?


That's a thought I'll look into it thanks
We can't stop here, this is bat country. Hunter S Thompson RIP.
User avatar
pk_fox
LXF regular
 
Posts: 292
Joined: Wed Apr 13, 2005 1:38 pm
Location: Surrey, UK

Postby pk_fox » Mon Jun 30, 2014 9:03 am

johnhudson wrote:Then is there an encoding problem, e.g. utf8 to unicode 16 or something like that?


Hi John, the encoding on the Postgres database is UTF8 which I'm sure must contain the currency symbol ? any more ideas ?
We can't stop here, this is bat country. Hunter S Thompson RIP.
User avatar
pk_fox
LXF regular
 
Posts: 292
Joined: Wed Apr 13, 2005 1:38 pm
Location: Surrey, UK

Postby johnhudson » Mon Jun 30, 2014 9:13 pm

ADO.NET is a Microsoft product and probably uses Unicode 16. That is why I wondered whether the problem is UTF8 to Unicode 16. But it may use a different encoding which would explain the problem.

Unicode 16 uses 2 bytes for every character whereas UTF8 uses a variable number of bytes depending on position in the sequence.

(I am surprised that you are getting the problem but this is the only explanation I can think of in the light of the information you have shared.)
johnhudson
LXF regular
 
Posts: 873
Joined: Wed Aug 03, 2005 1:37 pm

Postby pk_fox » Tue Jul 01, 2014 5:18 am

johnhudson wrote:ADO.NET is a Microsoft product and probably uses Unicode 16. That is why I wondered whether the problem is UTF8 to Unicode 16. But it may use a different encoding which would explain the problem.

Unicode 16 uses 2 bytes for every character whereas UTF8 uses a variable number of bytes depending on position in the sequence.

(I am surprised that you are getting the problem but this is the only explanation I can think of in the light of the information you have shared.)


Thanks John, what more information could I give to help nail this down, the system I'm writing is currently for my own use but with a view to offering it to others so I need to resolve this.

Edit
Just tried using the postgres Unicode ODBC driver and it worked perfectly so it must be an issue with the Npgsql driver that I'm using ( which is recommended for ADO.NET and indeed written in c# ) I'm on to the Npgsql( Mono project ) guys now as this is not good which is a shame as the performance and other functionality is very good
We can't stop here, this is bat country. Hunter S Thompson RIP.
User avatar
pk_fox
LXF regular
 
Posts: 292
Joined: Wed Apr 13, 2005 1:38 pm
Location: Surrey, UK


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest