snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

Problem with import - encoding

Open 3Georgerr opened this issue 10 years ago • 3 comments

Expected Behavior (or desired behavior if a feature request)

Importing this: Name,Email,Username,Item Name,Category,Model Name,Manufacturer,Model Number,Serial Number,Asset Tag,Location,Notes,Purchase Date,Purchase Cost,Company,Status,Warranty Months,Supplier,Order Number

,,,,"kancelářský nábytek - ostatní","kanál kabelový","TEST, a.s.",,,"WMC01100","TestCompany",,,"220","TEST Group, a.s., Praha","Ready to Deploy",24,"TEST, a.s.",24220227

Actual Behavior

Imported as ,,,,"kancelá**?**ský nábytek - ostatní","kanál kabelový","TEST, a.s.",,,"WMC01100","TestCompany",,,"220","TEST Group, a.s., Praha","Ready to Deploy",24,"TEST, a.s.",24220227

letters like čšěřžň is imported like ? or ø ( UTF-8 od ANSI)

Please confirm you have done the following before posting your bug report:


Please provide answers to these questions before posting your bug report:

  • Version of Snipe-IT you're running: v3.4.0-9-g67315d8
  • What OS and web server you're running Snipe-IT on: centos6 + apache
  • What method you used to install Snipe-IT (install.sh, manual installation, docker, etc): manual installation

3Georgerr avatar Oct 05 '16 11:10 3Georgerr

I had the same problem with polish latin characters: ąćęńł and did a temp fix in:

app/Console/Commands/ObjectImportCommand.php

function:

 public function array_smart_fetch(array $array, $key, $default = '')
    {
        //return array_key_exists(trim($key), $array) ? e(Encoding::fixUTF8(trim($array[ $key ]))) : $default;
        return array_key_exists(trim($key), $array) ? e(trim($array[ $key ])) : $default;
   }

So the Encoding::fixUTF8 was causing problem in my scenario, as it was damaging proper UTF-8 sequence. Also trim for $key on the left side seams strange, as this should be done on right side as well.

PiotrSikora-DECERTO avatar Nov 18 '16 15:11 PiotrSikora-DECERTO

@PiotrSikora-DECERTO Your fix help me out too. Thanks alot, mate!

snefedoff avatar Nov 21 '16 07:11 snefedoff

FixUTF was necessary to prevent the importer from skipping characters with non-standard characters, like curly quotes or invisible characters. :-/

snipe avatar Nov 22 '16 02:11 snipe