¹®ÀÚ¿­À» _T() ÇüÀ¸·Î ¹Ù²ãÁÖ´Â ¸ÅÅ©·Î


1.¿ä¾à

°£´ÜÇÑ ¸ÅÅ©·Î¸¦ »ç¿ëÇÏ¿© "" ·Î ¹­ÀÎ ¹®ÀÚ¿­À» _T("") À¸·Î ¼Õ½±°Ô ¹Ù²Ù¾î º¸ÀÚ.


2.º»¹®

¹®ÀÚ¿­ÀÌ ANSI ¿Í UNICODE ¸¦ ´Éµ¿ÀûÀ¸·Î Àû¿ëÇϱâ À§Çؼ­´Â _T() ¸ÅÅ©·Î¸¦ »ç¿ëÇÕ´Ï´Ù. ¹°·Ð ÄÄÆÄÀÏ ½Ã°£¿¡ _UNICODE °¡ define µÇ¾î ÀÖ´À³ÄÀÇ Â÷À̰¡ À§ÀÇ ¸ÅÅ©·Î¿¡ ¿µÇâÀ» ¹ÌÄ¡ÁÒ. ÇÏÁö¸¸, UNICODE ÇÁ·Î±×·¥À» ¸¹ÀÌ ÇØº¸Áö ¾ÊÀºÇÑ, ±×¸®°í Àü¿¡ ÇÁ·Î±×·¥À» UNICODE ¸¦ Áö¿øÇϱâ À§Çؼ­ ¸¸µéÁö ¾Ê¾Ò´Ù¸é, ¸Å¹ø _T() ¸¦ ºÙÀ̱â¶õ °áÄÚ ½¬¿îÀÛ¾÷ÀÌ ¾Æ´Õ´Ï´Ù. µû¶ó¼­ ÷ºÎÇÑ ¸ÅÅ©·Î ÆÄÀÏÀ» »ç¿ëÇÏ¸é ½±°Ô _T()¸¦ ¹®ÀÚ¿­¿¡ ºÙÀÏ ¼ö ÀÖ½À´Ï´Ù.

÷ºÎÇÑ ÆÄÀÏÀº ..\Microsoft Visual Studio\Common\MSDev98\Macros Æú´õ¿¡ ³Ö¾î¼­ »ç¿ëÇϽñ⠹ٶø´Ï´Ù.


3.¿¹Á¦


// ÀÌ·¸°Ô µÇ¾î ÀÖÀ¸¸é ÀÌ ¶óÀο¡ Cursor¸¦ ³õ°í 

// ¸ÅÅ©·Î¸¦ ½ÇÇàÇÏ½Ã¸é µË´Ï´Ù. 

char szText[] = "Test Text"; 



// Â¥ÀÜ.. char szText[] = _T("Test Test"); 


* ¸ÅÅ©·Î ¼Ò½º - ´Ù¿î·Îµå


Sub UnderscoreT()

'DESCRIPTION: This macro will automatically put "_T( )" around 

'             your strings, Author: Orin Walker, 1999, Version 1.1

    Dim win

    set win = ActiveWindow

    if win.type <> "Text" Then

      MsgBox "This macro can only be run when a text editor" + _

        " window is active."

    else



        iCount = 0

        bFoundAQuote = false



        ActiveDocument.Selection.SelectLine

        strTemp = ActiveDocument.Selection.Text

        

        strStuffAtEnd = ""



        while bDone <> true



            str = ParseString(strTemp, bFoundAQuote, strStuffAtEnd)

            

            strBuildString = strBuildString + str

            

            if bFoundAQuote = true then

                strTemp = strStuffAtEnd

            else

                bDone = true

                ActiveDocument.Selection.Delete     

                ActiveDocument.Selection = strBuildString 

            end if



            iCount = iCount + 1

            if iCount > 100 then    ' safety valve

                bDone = true

            end if



        Wend

    end if  

End Sub



Function ParseString(strTemp, byRef bFoundAQuote, _

                     byRef strStuffAtEnd)

'DESCRIPTION: This is a helper function for the UnderscoreT macro,

'             Author: Orin Walker, 1999, Version 1.1

    

    ' Comment in/out whatever style you prefer       

    strSpace = ""   ' NO space before or after "_T("

    'strSpace = " " ' Add a space before and after "_T("



    iLen = len(strTemp)

    bFoundAQuote = false



    ' Get the position of the first quote on the line

    iPos = instr(strTemp, chr(34))



    if iPos > 0 Then    'a quote was found

        ' Go back and see if we have an existing 

        ' _T( defined for this quote

        x = iPos-5          ' Go back up to 5 characters

        if x <= 0 then      ' If we have reached the 

                            ' beginning of our string

            x = 1           ' Set x to start at the first character

        end if

        strCheck = mid(strTemp, x, iPos)

    

        iUnderscoreTPos = instr(strCheck, "_T(")

        

        ' If we found one grab everything before the first quote

        strBeforeFirstQuote = mid(strTemp, 1, iPos-1)



        if iUnderscoreTPos > 0 then     ' we found an "_T("

            ' Do NOT add the "_T(" to our temporary string

            strNewTempStr = strBeforeFirstQuote

        else

            ' Now create our new temporary string and append "_T("

            strNewTempStr = strBeforeFirstQuote + "_T(" + strSpace

        end if



        ' Get the remaining string

        strRemaining = mid(strTemp, iPos+1, iLen)

        

        iLen = len(strRemaining)



        ' Now find the second quote

        iPos = instr(strRemaining, chr(34))

        

        if iPos > 0 Then

            ' If we found one save the stuff in quotes

            strStuffInQuotes = chr(34) + mid(strRemaining,1,iPos)

            

            ' And grab the stuff after the quotes

            strStuffAtEnd = mid(strRemaining, iPos+1, iLen)

            

            if iUnderscoreTPos > 0 then     ' we found an _T(

                ' Do NOT add the final ")" to our parsed string, 

                ' because it alreasy exists

                ParseString = strNewTempStr + strStuffInQuotes 

            else

                ' Create our parsed string

                ParseString = strNewTempStr + strStuffInQuotes + _

                    strSpace + ")" 

            end if

            

            bFoundAQuote = true

                        

        else

            ' No SECOND quote was found so just return 

            ' what was passed in

            ParseString = strTemp

        End if

    else

        ' No quote was found so just return what was passed in

        ParseString = strTemp

    end if 



End Function



- 2001.08.13 Smile Seo -