/* * <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> * </DOC_AMD_STD> */ #include <stdio.h> #include <stdlib.h> int main() { FILE *fp,*outfp; unsigned char character,match1,match2,match3; unsigned char utf8=128; unsigned char dbtable[100]; unsigned char entryname[1000]; char replace[256][100]; int section_start=0; int temp_start=0; int step=0; //Fill an array with replace text while(step <= 255) { sprintf(replace[step],"<UTF8_FIND_%i>",step); step++; } if((fp=fopen("checkpoint.dat","rt"))==NULL) { printf("File not found: checkpoint.dat\n"); return(1); } if((outfp=fopen("utfcheckpoint.dat","wt"))==NULL) { printf("Cannot open utfcheckpoint.dat for writing\n"); return(1); } while(!feof(fp)) { character=getc(fp); if(character == '@') { temp_start = ftell(fp); match1=getc(fp); match2=getc(fp); match3=getc(fp); if(match1 == 'd' && match2 == 'b' && match3 == '.') { //printf("section_start=%i\n",temp_start); dbtable[0] = match1; dbtable[1] = match2; dbtable[2] = match3; match1 = getc(fp); step = 3; while(match1 != '@') { dbtable[step] = match1; step++; match1 = getc(fp); } dbtable[step] = 0; match1 = getc(fp); match1 = getc(fp); if(match1 == '@') { //db.desc name is not between @ characters match1 = getc(fp); } step = 0; while(match1 != '@') { entryname[step] = match1; step++; match1 = getc(fp); } entryname[step] = 0; section_start = temp_start-8; if(section_start <= 0) { section_start = 0; } } fseek(fp,temp_start,SEEK_SET); } if(character & utf8 && character <= 254 ) { //255 is EOF printf("*********************\n"); temp_start = ftell(fp) - 1; printf("Character: %i\nLocation: %i\n",character, temp_start); printf("Table: %s\nName: %s\n",dbtable,entryname); printf("Dump (%i-%i):\n\n",section_start, temp_start); fseek(fp,section_start,SEEK_SET); step=section_start; while(step <= temp_start ) { character = getc(fp); printf("%c", character); step++; } printf("\n\n"); //You would think we were at the correct location //But Windows does CRLF which is really two characters //So under Windows we likely went too far fseek(fp,temp_start ,SEEK_SET); character = getc(fp); fputs(replace[character], outfp); } else { if(character != 255) { fputc(character, 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. |