working on it ...

Filters

Explore Public Snippets

Sort by

Found 3 snippets matching: ansistring

    public by MarcoDeMagistris  559030  64  7  0

    Converts Unicode string to Ansi String

    Converts Unicode string to Ansi String
    public static string ConvertUnicodeToAnsi(String s)
            {
                /// <summary>
                /// Description: Converts Unicode string to Ansi String
                ///              
                /// </summary>
                /// <exception cref="ArgumentNullException"></code></exception>
                /// <exception cref="EncoderExceptionFallback"></exception>
                /// <exception cref="DecoderExceptionFallback"></exception>
                /// <exception cref="ArgumentException"></exception>
                try
                {
                    byte[] unicodeBytes = Encoding.Unicode.GetBytes(s);
                    byte[] ansiBytes = Encoding.Convert(Encoding.Unicode, Encoding.Default, unicodeBytes);
                    return Encoding.Default.GetString(ansiBytes).ToString();
                }
                catch {
                    throw;
                }
            }

    external by Ismail Kocacan  22  0  1  0

    Converting AnsiString to WideString

    Converting AnsiString to WideString: ConvertToWideString
    WideString __fastcall ConvertToWideString(char Value[])
    {
      int CodePage=1254;
      int WideCharSize = MultiByteToWideChar( CodePage , 0 , Value , -1, NULL , 0 );
      wchar_t* lpWideCharStr = new wchar_t[WideCharSize];
      MultiByteToWideChar( CodePage , 0 , Value , -1, lpWideCharStr , WideCharSize );
      WideString result = lpWideCharStr;
      delete[] lpWideCharStr;
      return result;
    }
    
    

    external by Haruyuk Mohri  227  0  3  0

    AnsiString to char*

    AnsiString to char*: AnsiStrToPChar.cpp
    //bcc64
    AnsiString s1{"abcdefgh"};
    std::unique_ptr<char> c1{new char[s1.Length()+1]};
    char* c2 = c1.get();
    memcpy(c1.get(), s1.c_str(),s1.Length());//メモリブロックコピー
    
    std::string s2;
    for (int i=0; i < s1.Length(); i++)
    {
    	s2 = s2 + *c2;
    	c2++;
    }
    
    
    
    

    List Complete ( 3 snippets total )

    • Public Snippets
    • Channels Snippets