Date time showing   instead of space

CSV opened in Excel is…

Login

Blog History

CSV opened in Excel is showing   instead of a space between the DateTime and the period (am / pm)

That is because it is being opened in Excel using CP-1252 instead of UTF-8 and thus rendering the NARROW NO-BREAK SPACE incorrectly

https://www.fileformat.info/info/unicode/char/202f/index.htm

In Excel using Get Data => From Text/CSV and then choosing a file origin of CP-1252 Western European (Windows) you can see it renders it as  

How to open a CSV file with the correct encoding so 'NARROW NO-BREAK SPACE' is displayed correctly

In Excel using Get Data => From Text/CSV and then choosing a file origin of CP-65001 Unicode (UTF-8)

Using PHP to peak into the 'NARROW NO-BREAK SPACE' between the `11:45' and `am'

<?php 

$str = "12/5/22, 11:45?am";

var_dump(mb_substr($str,14,1));

var_dump(mb_ord(mb_substr($str,14,1), 'UTF-8'));

# output
string(3) "?"
int(8239)

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.