Tag Archives: gotcha

ms windows 7 and ms windows 10 system repair discs, system image backups and media ids #gotcha

It would seem that ms windows 7 and ms windows 10 backup writes a media id to the System Repair Disc CD/DVD it creates and puts the same media id in the system image subdirectory in WindowsImageBackup\MACHINENAME\ to LOCK the windows System Repair Disc CD/DVD with the USB disk System Image backup/restore disk you are creating.

ie if you lose the original System Repair Disc CD/DVD you CANNOT restore from your USB System Image with a different/new System Repair Disc CD/DVD

Possible workarounds:

  • Always keep MATCHING CD/DVD disc and USB disk drive backups together

or

  • Install a clean Windows 7 or 10 on target machine
  • Create a NEW System Repair Disc CD/DVD
  • Create a NEW USB System Image
  • Copy MediaId file from NEW USB System Image to OLD USB System Image
  • Boot from new System Repair Disc CD/DVD with OLD USB System Image

#python uses #ascii instead of #unicode by default #gotcha

by default python seems to run in ascii which means if you try and process a string with a utf-8 unicode character in it you will get the error

UnicodeEncodeError: 'ascii' codec can't encode character 
u'\xXX' in position YYYYY: ordinal not in range(128)

so to force your script to use utf-8 unicode instead you need to

see http://nedbatchelder.com/text/unipain.html and

import sys
reload(sys)
sys.setdefaultencoding('utf8')
print sys.getdefaultencoding()

php unicode utf-16 bom processing with iconv and mb_convert

basically php iconv doesnt handle FEFF BOMs while mb_convert does !

        $fh = fopen($s, "r");
        
        // watch out for notepad unicode FEFF BOM
        
        $utf16 = fgets($fh, 1024);

        $utf8 = mb_convert_encoding($utf16,'UTF-8','UTF-16');
        var_export($utf8);
        echo PHP_EOL;

        $utf8 = mb_convert_encoding($utf16,'UTF-8','UTF-16LE');
        var_export($utf8);
        echo PHP_EOL;

        $utf8 = iconv('UTF-16LE','UTF-8',mb_substr($utf16,1,null,'UTF-16LE'));
        var_export($utf8);
        echo PHP_EOL;