Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.1 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM unicode.cmd
  5. REM convert ansi files in the product to unicode
  6. REM
  7. REM Copyright (c) Microsoft Corporation. All rights reserved.
  8. REM
  9. REM ------------------------------------------------------------------
  10. perl -x "%~f0" %*
  11. goto :EOF
  12. #!perl
  13. use strict;
  14. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  15. use lib $ENV{RAZZLETOOLPATH};
  16. use PbuildEnv;
  17. use ParseArgs;
  18. use Logmsg;
  19. use File::Copy;
  20. use ParseTable;
  21. sub Usage { print<<USAGE; exit(1) }
  22. unicode [-l <language>]
  23. Converts ansi files to unicode with unitext. The codepage to use for
  24. the conversion is looked up in tools\\codes.txt. The list of files to
  25. convert is somewhat hardcoded. This script should be modified to use
  26. the data files tools\\postbuildscripts\\a2u*.txt as this is a
  27. replacement for a2u.pm.
  28. USAGE
  29. parseargs('?' => \&Usage);
  30. my %lang_data;
  31. parse_table_file("$ENV{RAZZLETOOLPATH}\\codes.txt", \%lang_data);
  32. if (lc $ENV{LANG} eq 'usa') {
  33. logmsg("skipping unicode conversion for usa");
  34. exit 0;
  35. }
  36. if (!$lang_data{uc $ENV{LANG}}) {
  37. wrnmsg("language information not found for $ENV{LANG}");
  38. exit 0;
  39. }
  40. my $include_re = qr/(tsclient\\ncadmin\.inf|
  41. install.ins|
  42. \.mof|
  43. \.adm|
  44. \.inf)$/ix;
  45. my $exclude_re = qr/(biosinfo\.inf|
  46. layout\.inf|
  47. drvindex\.inf|
  48. inetcorp\.adm|
  49. inetset\.adm|
  50. compatws\.inf|
  51. hisecws\.inf|
  52. hisecdc\.inf|
  53. homepage\.inf|
  54. iefiles5\.inf|
  55. instcm\.inf|
  56. mmdriver\.inf|
  57. pad\.inf|
  58. reminst\.inf|
  59. rootsec\.inf|
  60. securedc\.inf|
  61. securews\.inf|
  62. setup16\.inf|
  63. switch\.inf|
  64. wavemix\.inf|
  65. pvc\.inf|
  66. svc\.inf|
  67. IMKRINST\.INF|
  68. template\.inf|
  69. bfcab\.inf|
  70. update\.inf|
  71. msdtctr\.mof)$/ix;
  72. my @convert;
  73. open FILE, "$ENV{_NTPOSTBLD}\\layout.inf" or die "unable to open layout";
  74. while (<FILE>) {
  75. s/;.*$//;
  76. s/^(\S+)\s*=\s*//;
  77. my $file = lc $1;
  78. next unless $file =~ /$include_re/;
  79. next unless $file !~ /$exclude_re/;
  80. if (-e "$ENV{_NTPOSTBLD}\\$file") { push @convert, "$ENV{_NTPOSTBLD}\\$file" }
  81. if (-e "$ENV{_NTPOSTBLD}\\perinf\\$file") { push @convert, "$ENV{_NTPOSTBLD}\\perinf\\$file" }
  82. }
  83. close FILE;
  84. for (@convert) {
  85. if (-e "$ENV{TEMP}\\unicode.tmp") { unlink "$ENV{TEMP}\\unicode.tmp" }
  86. my $cmd = "unitext -m -$lang_data{uc $ENV{LANG}}->{ACP} -z $_ $ENV{TEMP}\\unicode.tmp";
  87. logmsg("Running $cmd");
  88. system($cmd);
  89. if ($?) {
  90. wrnmsg("unitext conversion failed for $_");
  91. }
  92. else {
  93. if (-e "$ENV{TEMP}\\unicode.tmp") { copy("$ENV{TEMP}\\unicode.tmp", "$_") }
  94. }
  95. }