Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113691 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 97576 invoked from network); 22 Mar 2021 17:29:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Mar 2021 17:29:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AECFC180539 for ; Mon, 22 Mar 2021 10:24:54 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 22 Mar 2021 10:24:54 -0700 (PDT) Received: by mail-ej1-f43.google.com with SMTP id e14so4388342ejz.11 for ; Mon, 22 Mar 2021 10:24:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JJccNdLiJiTFDsQhnhek8KXrFMWx61w7VXJ2bq+9FPI=; b=HK7ujuJphd9aUjzB83cK+zH8u51KgoQ/MjBylXMsTKufR9UES/5MDv4MGKYzJ1itqt SN33Qrov8wb7k/TW5+J1Rn05LXEbEy6V9LBRejNG6PNvtV29t/4wgTOCt53zBY1tXaz5 0OQ9GjdzLomCPqaLtD+A48c948FQ5L3nLKBU44Njt3iT5COKnBH5nN6aBTohhW//oy5j MtGxhJZSyKiYrl5OCZ1DYu7AuXZCE7CRG6lDhEFxpu7W1QNPC7Zko8wU3DiDsvoCTq52 7wOB2LVQvTG1K6/5SCh2280zza/QuE3Pq4POPwMwoNVGOPqZ+K/SLC7eVG8A5Fru1HbT 7ExQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JJccNdLiJiTFDsQhnhek8KXrFMWx61w7VXJ2bq+9FPI=; b=qExiOiEZAuhyPiCLbQwQyvIBSXhgctqSpwN3L7DVvzFXcOnk1z3jqOre8C3gXiAazY HhF/3YEXRHXkngV89Vk7xCrQZIWoreKo8Y55VUC31LRoIAzp0chy0Pbz2gg7tjzqpXPj KLqL8gd5tWI/dbU1pSaY3xibYVjBjqyYkowbsVSDTvOBUt5e4SLY8dp4sW1lF+DrtCcZ Ntx+v0CPEdRL01+2fwRPDDYeBZesmZAFtlfIi0gy8l+eRESwgOSqyFdx9XGBGyWGSs91 5NwdzOctxXSFQHtueJTYoiCKkWdLW3jUH2EFKFN/E3iBMBgjfEy2Q5ra7NYBoHPNV0mV qrJg== X-Gm-Message-State: AOAM531kY6eyVGlAN6cSkCCczKJYKb8/Qv2trRro2iYXb2enBQBfWDY5 t8mlKquDZ2rfUh334a7l6reYHm71weuMKpm0IPs= X-Google-Smtp-Source: ABdhPJwDsqsKa3vuGV7oezb6PcSYxnUpdfndRLbGF1BDIlHi+epqLmu5/o8nd3dZ7rszTZsPQgvaag8Mrhw2kSw1jqs= X-Received: by 2002:a17:907:1614:: with SMTP id hb20mr881120ejc.77.1616433892199; Mon, 22 Mar 2021 10:24:52 -0700 (PDT) MIME-Version: 1.0 References: <693767b5-a25b-b4d9-f535-6b985bf26d67@gmail.com> <29d5329c-bea2-7944-4820-515d4a10ae86@alec.pl> <16ecfc31-33aa-4223-fb67-b5a4b5895f05@gmail.com> <11e9a312-ed10-412e-506d-ccf9f24457f8@alec.pl> In-Reply-To: <11e9a312-ed10-412e-506d-ccf9f24457f8@alec.pl> Date: Mon, 22 Mar 2021 19:24:34 +0200 Message-ID: To: Aleksander Machniak Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000f28e7a05be2357c7" Subject: Re: [PHP-DEV] What should we do with utf8_encode and utf8_decode? From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000f28e7a05be2357c7 Content-Type: text/plain; charset="UTF-8" On Mon, Mar 22, 2021 at 6:52 PM Aleksander Machniak wrote: > On 22.03.2021 16:41, Rowan Tommins wrote: > > That code will never do anything useful. > > I already proved it is useful, regardless of it's name/intention. > > This is old code, not even mine, so maybe when it's been written the PHP > documentation wasn't that clear about the function(s) intention. Or the > intention was different. > > ps. to Kamil, > > We use utf8_encode() to make the string safe to be put in utf-8 database > column/table. We use utf8_decode() to convert that back to what it was > before. > I just searched and found a hotfix I did a few years ago (when I was also dumber) and the fix was just adding a utf8_encode to some data received in $_POST before being sent to a logging service. And a utf8_decode after reading it for further parsing. The logging service storage was using a mysql database and the specific column was declared `TEXT` instead of `BLOB`. Apparently the fix is still in place. > > The tests prove that the conversion is lossless. > There could have been better ways to fix it. json_encode / json_decode would have worked just the same. The problem was that the quickly identified cause was a non-utf8 string trying to be stored in an utf8 text column and the solution was implemented based on the fact that utf8_decode/encode sounded like a good idea when time is limited; and also knowledge in my case. I think it would be great to deprecate them somehow. Regards, Alex --000000000000f28e7a05be2357c7--