Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJuPL-0004gM-CG for pgsql-general@arkaria.postgresql.org; Wed, 10 Mar 2021 08:41:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lJuPK-0003IE-94 for pgsql-general@arkaria.postgresql.org; Wed, 10 Mar 2021 08:41:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJuPK-0003I6-0v for pgsql-general@lists.postgresql.org; Wed, 10 Mar 2021 08:41:30 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lJuPC-00011G-VD for pgsql-general@postgresql.org; Wed, 10 Mar 2021 08:41:28 +0000 Received: by mail-ed1-x52e.google.com with SMTP id b13so26817337edx.1 for ; Wed, 10 Mar 2021 00:41:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=9Rpfi0lgMxbcWYqDfDmWXOQ6zMNgqBi2ORBqF7RzlDw=; b=Ug/AbarTGuEGG/tp2qEuUzyWlhpZe4+86wevuN6gm8LHLc+JR/8IdLXvegwhd8CiH1 3E3hjcFL6FBDoYXzxSmccHSiLURYtmWBbPTanGy00jrzfebK6CoWUQZrU1CEEMZQ8ZFD 8b9768vOUQDLd2sbRIzZbGi1TMuvYqElknSmhL2galEEvWHnCLwvK+V+QfMFBINLK23f XidzL3Ls7e+YUHjdHE/ebioCeai1nBFkeMPbwoyOAuzzxSRYdK79eGfDMhdMatAMjwXg yZMU5HBdZtIiBy9IaUR/C+9ZslsA+ul3XYrBVNXMZ3lw5VssFvbpQmQi4t0MQ4ayBP8X Hi4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=9Rpfi0lgMxbcWYqDfDmWXOQ6zMNgqBi2ORBqF7RzlDw=; b=YDshRoXhrfn/pMjScbMJfqm9wRdbNi5nE0osFgjN5vaDsim6y3imChomC7T1dPPznJ qUDsk9xVsF5Orin1VM08a8aUO1nwB1EMD64xCzm9WC7VmFFBPepj7gQBq/7rj4InuLt0 2aVfKeYxZJqwBWjmTEpfb1oGNL1ut5t77tt/0FkwZYh/ByyXmYzbDYUKg4z/jFj0+RxW 9HgGsHKdoU/X1OWVyFKrdp7hWwtfuhF7Q/uCPnJGGIiMS07a/0R2PkeAKj6vf9nzKhUX iBcGVB4XIMEkxVVuPZy9NRCVvOy0+rrtQ2wCv2eZNaG0tY5w8LszPyBqVvjpAj4KKlyo 7z+w== X-Gm-Message-State: AOAM53377itUyu1n7XN8lKTqk+KTalk+xwCrquC22XZnzS1Y3eXhMazx S8GO/remKHTCFpb/sdnntiFKRA== X-Google-Smtp-Source: ABdhPJxd6465cXwyzFIWKs29+oPqmLuenEDr8nvxH5TYIfwZrX3dv6tgfsRXE7KGuuFNAVv5P7+VNA== X-Received: by 2002:a05:6402:2215:: with SMTP id cq21mr2039253edb.281.1615365680896; Wed, 10 Mar 2021 00:41:20 -0800 (PST) Received: from localhost.localdomain (217-149-172-42.nat.highway.telekom.at. [217.149.172.42]) by smtp.gmail.com with ESMTPSA id si7sm9444515ejb.84.2021.03.10.00.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 00:41:20 -0800 (PST) Message-ID: <194db61d0b7d306e4416626a7d8205bc74c059ab.camel@cybertec.at> Subject: Re: unexpected character used as group separator by to_char From: Laurenz Albe To: Vincent Veyron , pgsql-general@postgresql.org Date: Wed, 10 Mar 2021 09:41:19 +0100 In-Reply-To: <20210309212821.437795da590228b5c552eead@wanadoo.fr> References: <20210309212821.437795da590228b5c552eead@wanadoo.fr> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2021-03-09 at 21:28 +0100, Vincent Veyron wrote: > I'm having a problem with to_char() inserting unexpected characters as group separator. > > For the record below, I wish to display 'credit' properly formated in an html form, using to_char(credit, 'FM999G990D00') > > SELECT *, to_char(credit, 'FM999G990D00') as yo from tblprospect_balance where id_item = 33; > > id_prospect | id_item | date_item | libelle | debit | credit | lettrage | id_facture | yo > -------------+---------+------------+---------+-------+---------+----------+------------+---------- > 385 | 33 | 2021-03-09 | yo man | 0.00 | 2345.10 | | 8 | 2 345,10 > > The numbers are properly displayed in the html form. However, updating the record requires > the user to manually delete the space in '2 345,10', otherwise the last digit is lost. > Typing numbers including a group separator using the space bar works fine. > > I exported the record to a text file and inspected it with emacs in hexadecimal mode : > > 3338 3509 3333 0932 3032 312d 3033 2d30 385.33.2021-03-0 > 00000010: 3909 796f 206d 616e 0930 2e30 3009 3233 9.yo man.0.00.23 > 00000020: 3435 2e31 3009 0938 0932 e280 af33 3435 45.10..8.2...345 > 00000030: 2c31 300a ,10. > > As you can see, the space in field 'libelle' (yo man) is different from the one in field 'yo' (2...345,10) > > What can I do to get a standard space as group separator for my numbers? > > #### system information ######## > I use postgresql 11.9 on Debian buster > > My settings are : > > show lc_numeric; > lc_numeric > ------------- > fr_FR.UTF-8 That "space" is UNICODE U+202F ("Narrow No-Break Space"), and that's what your C library thinks to be the correct group separator for the French language. You can either replace the character: SELECT replace(to_char(2345.10, 'FM999G990D00'), E'\u202F', ' '); or you can choose a different locale that uses a different group separator (not sure if that exists). Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com