/* * <LIC_AMD_STD> * Copyright (c) 2004 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. * * Neither the name of the Advanced Micro Devices, Inc. nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * </LIC_AMD_STD> * <CTL_AMD_STD> * </CTL_AMD_STD> * <DOC_AMD_STD> * Reverse the <UTF8_FIND_xxx> metatags to UTF8 * </DOC_AMD_STD> */ #include <stdio.h> #include <stdlib.h> #include <locale.h> int main() { char meta[256][4]; FILE *fp,*outfp; char *buffer; char *line; char *buffer2; int step,x,len; line = malloc(1<<15); buffer = malloc(1<<7); buffer2 = malloc(1<<7); if(!setlocale(LC_CTYPE, "")) { fprintf(stderr, "Can't set the specified locale!" "Check LANG, LC_CTYPE, LC_ALL.\n"); return(1); } step = 0; while(step <= 255) { strcpy(meta[step],"UDF"); step++; } //Check the failures.txt or report.txt file to get a list of //definitions that should be created here. strcpy(meta[133], "…"); // ellipsis strcpy(meta[145], "‘"); // open single quote strcpy(meta[146], "”"); //close double quote strcpy(meta[147], "“"); //open double quote strcpy(meta[148], "”"); //close double quote strcpy(meta[150], "–"); //en dash strcpy(meta[160], " "); // non-breaking space strcpy(meta[166], "Ä"); // A diaeresis strcpy(meta[177], "+"); // This was a +- combo character. strcpy(meta[183], "·"); // bullet (small) strcpy(meta[191], "¿"); // Spanish inverted ? //The metadata containing these characters was actually created from DOS //Not WinANSI. Use the DOS characters instead //strcpy(meta[180], "´"); // acute //strcpy(meta[192], "À"); // A grave //strcpy(meta[195], "Ã"); // A tilde //strcpy(meta[196], "Ä"); // A diaeresis //strcpy(meta[217], "Ù"); // U grave strcpy(meta[180], "┤"); strcpy(meta[192], "└"); strcpy(meta[195], "├"); strcpy(meta[196], "─"); strcpy(meta[217], "┘"); strcpy(meta[237], "í"); // i acute strcpy(meta[241], "ñ"); // n tilde strcpy(meta[243], "ó"); // o acute strcpy(meta[250], "ú"); // u acut if((fp=fopen("checkpoint.utf","rt"))==NULL) { printf("File not found: checkpoint.utf\n"); return(1); } if((outfp=fopen("utfcheckpoint.utf","wt"))==NULL) { printf("Cannot open utfcheckpoint.utf for writing\n"); return(1); } x = 0; while(!feof(fp)) { strcpy(line,""); fgets(line,65535,fp); if(strstr(line, "<UTF8_FIND_")) { step = 0; printf("Modifying: %s",line); while(step <= 255) { if(strcmp(meta[step],"UDF") != 0 ) { sprintf(buffer,"<UTF8_FIND_%i>",step); while(buffer2 = strstr(line,buffer) ) { strcpy(buffer2,meta[step]); strcat(buffer2,buffer2 + 15); printf("%s",line); } } step++; } } if(strstr(line, "<UTF8_FIND_") ) { printf("Error: Could not replace all <UTF8_FIND_xxx> instances. Please update meta array\n"); return(1); } x++; if(strcmp(line,"") != 0 ) { fputs(line,outfp); } } fclose(fp); fclose(outfp); return(0); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 4673 | Raymond Danks |
UTF8Conv_1.00.00: This tool originates in the AMD PCS LDC Perforce Server //admin/utf8 as of changelist 53132. Please review the README and unit_test.txt documentation for usage and purpose. |