Path: chuka.playstation.co.uk!news From: Ken Lam <100411.265@compuserve.com> Newsgroups: scee.yaroze.programming.libraries Subject: Shift JIS inof Date: Wed, 28 May 1997 15:50:55 -0700 Organization: PlayStation Net Yaroze (SCEE) Lines: 77 Message-ID: <338CB6CF.4EE6@compuserve.com> NNTP-Posting-Host: ld28-226.lon.compuserve.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 2.02 (Win16; I) 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; } //-----------------------------------------------------------------------------