INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: The good old decimal point comma conversion problem  (Read 2917 times)

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
The good old decimal point comma conversion problem
« on: June 18, 2011, 06:23:38 am »

Hi,

MC's MCWS sends Volume values using the current culture configured on the PC. This means that for US values the Volume is sent as  '0.2' for 20% and for f.i. Dutch values as '0,2' for 20% (note the decimal point and comma differences).

Since I have no clue what to expect from MC on a Windows Phone I now have the good old decimal point is comma conversion problem again.

This problem also means that date conversions will go wrong (US mm/dd/yyyy, Dutch dd/mm/yyyy).

How do we solve this in a backward compatible way?

Regards
Paul Sinnema
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42007
  • Shoes gone again!
Re: The good old decimal point comma conversion problem
« Reply #1 on: June 18, 2011, 07:19:08 am »

Normally Media Center will accept a dot or comma on input, and use the current locale for output.

Could you just accept either delimiter in your code?  By adding a Replace(',', '.') for example?

It's possible MCWS could be changed to always return using the English locale for internal variables.  Display variables (i.e. "VolumeDisplay") should still honor locale.
Logged
Matt Ashland, JRiver Media Center

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: The good old decimal point comma conversion problem
« Reply #2 on: June 18, 2011, 12:49:41 pm »

Hi Matt,

Yep, that's exactly what I did. I made a dirty hack for the problem. I scan the first inputs I get from MC. If the Volume has a period I use the periode from then on and when it has a comma I use that. It works fine. It does however not solve the date problem. I haven't analysed that indepth so it might be no problem at all. I'll look into that soon.

Regards
Paul
Logged

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: The good old decimal point comma conversion problem
« Reply #3 on: June 19, 2011, 12:45:45 am »

It's possible MCWS could be changed to always return using the English locale for internal variables.  Display variables (i.e. "VolumeDisplay") should still honor locale.

There's also the InvariantCulture. Wouldn't that be the better choice?

Regards
Paul
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: The good old decimal point comma conversion problem
« Reply #4 on: June 19, 2011, 05:20:16 am »

Hi Matt,

Yep, that's exactly what I did. I made a dirty hack for the problem. I scan the first inputs I get from MC. If the Volume has a period I use the periode from then on and when it has a comma I use that. It works fine. It does however not solve the date problem. I haven't analysed that indepth so it might be no problem at all. I'll look into that soon.

Regards
Paul

I'm not sure if it's appropriate here as I don't know what's sending and receiving the dates but presumably you're working with strings, but often it's helpful to send them in the big endian yyyy/mm/dd format.  Many systems dealing with datetime type objects work these out automatically.  May not work this case.

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: The good old decimal point comma conversion problem
« Reply #5 on: June 19, 2011, 05:33:51 am »

Hi Chriz,

It's been a while.

We can stop the discussion right here. I've just checked. MC does not send Dates like that. It uses some kind of independent value. Below is a XML value as returned by MC.

Regards
Paul

<Item>
<Field Name="Key">705</Field>
<Field Name="Filename">D:\MP3\Al Di Meola\Scenario\Al Di Meola - Scenario.mp3</Field>
<Field Name="Name">Scenario</Field>
<Field Name="Artist">Al Di Meola</Field>
<Field Name="Album">Scenario</Field>
<Field Name="Genre">Other</Field>
<Field Name="Date">36526</Field>
<Field Name="Bitrate">192</Field>
<Field Name="Image File">INTERNAL</Field>
<Field Name="Rating">5</Field>
<Field Name="Duration">240,1430000000000007</Field>
<Field Name="Track #">4</Field>
<Field Name="Media Type">Audio</Field>
<Field Name="Date Imported">1303378675</Field>
<Field Name="File Type">mp3</Field>
<Field Name="File Size">5907562</Field>
<Field Name="Date Created">1285176716</Field>
<Field Name="Date Modified">1299855387</Field>
<Field Name="Compression">CBR (MPEG-1 Layer 3)</Field>
<Field Name="Publisher">Columbia</Field>
<Field Name="Replay Gain">-7,4699999999999998</Field>
<Field Name="Peak Level">0,9789699912071228</Field>
<Field Name="Intensity">1</Field>
<Field Name="BPM">84</Field>
<Field Name="Sample Rate">44100</Field>
<Field Name="Channels">2</Field>
<Field Name="Bit Depth">16</Field>
<Field Name="Album Gain">-8,1155557632446289</Field>
<Field Name="Complete Album">1</Field>
</Item>
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: The good old decimal point comma conversion problem
« Reply #6 on: June 19, 2011, 05:56:24 am »

Ah!  I remember...
This may help
http://yabb.jriver.com/interact/index.php?topic=33020.msg280016#msg280016 in particular the two functions at the bottom.
Pages: [1]   Go Up