Hi,
I have an editor in my application which has a find functionality implemented for it.The user will enter text in the editor and will try the Find option from menu.The problem is when I have n double byte characters(of japanese) in my text and say if I try to find an char or word which after the double byte chars then my search is displaced by n bytes.This issue happens only in japanese and the same application works fine in English.Going through the below blog which has a similar problem as that of mine I noticed that the problem is with the dependancy on ComCtrl 6 dll used in xp manifest theme.
http://www.insidercoding.com/post/2008/08/06/Visual-C2b2b-60-2b-XP-Manifest-3d3d-Problems.aspx
My application is also developed in vc6 and we use a manifest file for XP visual theme as below
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="wm" type="win32"/> <description>Merely an XP test.</description> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> </assembly>
And I also cannot move my application to unicode. There are ASCII functions in my code.MFC by default supports MBCS.Even after placing _MBCS in project settings doesnt solve my problem. When I debug the below code I found the problem with lstrlen which is returning n chars extra for n double byte chars in my text to find.This happens only when I debug the code in japanese OS , the same works fine when I debug the same application in English OS.
static int FindStrPos( LPSTR lpSrc, LPSTR lpFind, BOOL bMatchCase ){ LPSTR p; int pos = -1, len; char szFind[FIND_LEN]; LPSTR lpStr; lstrcpy( szFind, lpFind); if( !bMatchCase ) { len = lstrlen(lpSrc)+1; lpStr = (LPSTR)wwHeap_AllocPtr( hChunkWM, (GMEM_MOVEABLE | GMEM_ZEROINIT), len ); if( lpStr ) { _fmemcpy( lpStr, lpSrc, len ); _fstrupr( lpStr ); _fstrupr( (LPSTR)szFind ); p = _fstrstr( lpStr, (LPSTR)szFind ); if( p ) { pos = p - lpStr; } wwHeap_FreePtr( hChunkWM, lpStr ); return( pos ); } else { debug("Alloc failed compare case-sensitive"); } } p = _fstrstr( lpSrc, lpFind ); if( p ) pos = p - lpSrc; return( pos );}
I also used MBCS functions like _mbslen instead of lstrlen and _mbsstr instead of _fstrstr then _mbslen is returning accurate length in japanese and when while finding the difference between the search position and actual text pos the value of pos is again added with n bytes in japanese version for n double byte chars in Text.
I tried removing the manifest file as the unknown problem is with the dependancy of comcontrl dll version 6 for enabling Xp style but it is giving other problems in japanese.
Any suggestion would be helpful.
Thanks,
Satya
Similar:
- Is Using Romaji in a game for Japanese translation acceptable? I am supporting other languages in my game for its next release and would like to support Japanese. The issue I have is a I...
- Max chars limit I was wondering how to alter a string to remove some chars from it if it exceeds x amount of chars. I can only find...
- pressrec on “Sudden trouble inputting Japanese text” Hello, I have been writing in both Japanese and English for a few years here without a problem. However while writing my latest post I’m...
- .NET Regular expressions on bytes instead of chars Hi, I’m trying to do some parsing that will be easier using regular expressions. The input is an array (or enumeration) of bytes. I don’t...
- ASP .NET Download File with Japanese File Name I am currently using Visual Studio 2008 for my ASP .NET application. I am trying to server an excel file via the Response object. The...
Tags: blog, dependancy, dll, double byte characters, vc6