electro-grammar icon indicating copy to clipboard operation
electro-grammar copied to clipboard

Support for comma in decimal point convention

Open kasbah opened this issue 7 years ago • 1 comments

0.1uF versus 0,1uF. I know in Germany people will write 0,1uF

The problem comes down to queries like:

0,1uf 10% 0402 50v x7r

vs

0.01uf, 50v, cog, 5%, 0603

Also, are there any other decimal point or other locale conventions we are not aware of?

kasbah avatar Aug 30 '18 14:08 kasbah

Just a note about it: In KiBot I handle it this way:

  • Check if the locale defines a decimal point that isn't .
  • If this is the case I just replace the decimal point by .

But the 0.01uf, 50v, cog, 5%, 0603 case is tricky, because it isn't using the decimal point of the locale, and uses it as separator. So I changed my code to replace the locale decimal point only when in the middle of a number. In Python is like this:

    if decimal_point:
        component = re.sub(r'(\d)'+decimal_point+r'(\d)', r'\1.\2', component)

This is all outside the parser, as a pre-processor.

set-soft avatar Mar 31 '23 13:03 set-soft