Path: chuka.playstation.co.uk!news From: Developer Support Newsgroups: scee.yaroze.programming.libraries Subject: Re: Shift JIS inof Date: Thu, 29 May 1997 11:23:07 +0100 Organization: Sony Computer Entertainment Europe Lines: 86 Message-ID: <338D590B.3EF5@interactive.sony.com> References: <338CB6CF.4EE6@compuserve.com> Reply-To: N/A-Use-Newsgroup NNTP-Posting-Host: 194.203.13.10 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.01 (Win95; I) Ken Lam wrote: > > I've been experimenting with writing files to the memory card and it > turns out > that the textual name of a file in the OSD needs to be in Shift Jis, not > plain > ASCII. > > I created the routine below by examining the file created by SIOCONS, but > can > anyone do better? > > Specifically I will eventually need to use punctuation and special > characters > such as accented letters -- where can I find more info on Shift Jis? > > Ken Lam > ESP Software > > PS Please note that on the Yaroze PC CD-ROM will cause an error > in > linking (_ctype_ undefined reference), the fix is on the Web site. > > #include > //----------------------------------------------------------------------------- > int ConvertAsciiToShiftJis(const char* asc, char* sjs) > { > > // (hex numbers) > // ASCII 'A' = 41, 'a' = 61 > // '0' = 30, ' ' = 20 > // Shift JIS 'A' = 82 60, 'a' = 82 81 > // '0' = 81 4f, ' ' = 81 40 > > char* AsciiPos = (char *) asc; > char* ShiftJisPos = sjs; > > do > { > if( isupper(*AsciiPos) ) > { > *ShiftJisPos++ = 0x82; > *ShiftJisPos++ = (*AsciiPos) + 0x1f; > } > else if( islower(*AsciiPos) ) > { > *ShiftJisPos++ = 0x82; > *ShiftJisPos++ = (*AsciiPos) + 0x20; > } > else if( isdigit(*AsciiPos) ) > { > *ShiftJisPos++ = 0x82; > *ShiftJisPos++ = (*AsciiPos) - '0' + 0x4f; > } > else if( isspace(*AsciiPos) ) > { > *ShiftJisPos++ = 0x81; > *ShiftJisPos++ = 0x40; > } > else if( *AsciiPos == '\0' ) > { > // first char might '\0' (string length == 0) > break; > } > else > { > // unknown character or character currently not > handled > // just ignore the character > } // end if > > } while( *AsciiPos++ != '\0'); > > // terminate string > *ShiftJisPos++ = 0x00; > *ShiftJisPos++ = 0x00; > } > > //----------------------------------------------------------------------------- See the new demo in the new download area. While not complete, it's largely there. Lewis