Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: third_party/WebKit/Source/wtf/text/WTFString.cpp

Issue 1382583002: Add toStdString methods to CString and WTF::String (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Back to String::toUTF8StdString Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007-2009 Torch Mobile, Inc. 4 * Copyright (C) 2007-2009 Torch Mobile, Inc.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 14 matching lines...) Expand all
25 #include "IntegerToStringConversion.h" 25 #include "IntegerToStringConversion.h"
26 #include "wtf/ASCIICType.h" 26 #include "wtf/ASCIICType.h"
27 #include "wtf/DataLog.h" 27 #include "wtf/DataLog.h"
28 #include "wtf/HexNumber.h" 28 #include "wtf/HexNumber.h"
29 #include "wtf/MathExtras.h" 29 #include "wtf/MathExtras.h"
30 #include "wtf/StringExtras.h" 30 #include "wtf/StringExtras.h"
31 #include "wtf/Vector.h" 31 #include "wtf/Vector.h"
32 #include "wtf/dtoa.h" 32 #include "wtf/dtoa.h"
33 #include "wtf/text/CString.h" 33 #include "wtf/text/CString.h"
34 #include "wtf/text/CharacterNames.h" 34 #include "wtf/text/CharacterNames.h"
35 #include "wtf/text/StringUTF8Adaptor.h"
35 #include "wtf/text/UTF8.h" 36 #include "wtf/text/UTF8.h"
36 #include "wtf/text/Unicode.h" 37 #include "wtf/text/Unicode.h"
37 #include <stdarg.h> 38 #include <stdarg.h>
38 39
39 namespace WTF { 40 namespace WTF {
40 41
41 using namespace Unicode; 42 using namespace Unicode;
42 43
43 // Construct a string with UTF-16 data. 44 // Construct a string with UTF-16 data.
44 String::String(const UChar* characters, unsigned length) 45 String::String(const UChar* characters, unsigned length)
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 // converted. 830 // converted.
830 ASSERT((buffer + 3) <= (buffer + bufferVector.size())); 831 ASSERT((buffer + 3) <= (buffer + bufferVector.size()));
831 putUTF8Triple(buffer, *characters); 832 putUTF8Triple(buffer, *characters);
832 } 833 }
833 } 834 }
834 } 835 }
835 836
836 return CString(bufferVector.data(), buffer - bufferVector.data()); 837 return CString(bufferVector.data(), buffer - bufferVector.data());
837 } 838 }
838 839
840 std::string String::toUTF8StdString() const
841 {
842 StringUTF8Adaptor utf8String = StringUTF8Adaptor(*this);
843 return std::string(utf8String.data(), utf8String.length());
844 }
845
839 String String::make8BitFrom16BitSource(const UChar* source, size_t length) 846 String String::make8BitFrom16BitSource(const UChar* source, size_t length)
840 { 847 {
841 if (!length) 848 if (!length)
842 return emptyString(); 849 return emptyString();
843 850
844 LChar* destination; 851 LChar* destination;
845 String result = String::createUninitialized(length, destination); 852 String result = String::createUninitialized(length, destination);
846 853
847 copyLCharsFromUCharSource(destination, source, length); 854 copyLCharsFromUCharSource(destination, source, length);
848 855
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 buffer.append('\0'); 1228 buffer.append('\0');
1222 return buffer; 1229 return buffer;
1223 } 1230 }
1224 1231
1225 Vector<char> asciiDebug(String& string) 1232 Vector<char> asciiDebug(String& string)
1226 { 1233 {
1227 return asciiDebug(string.impl()); 1234 return asciiDebug(string.impl());
1228 } 1235 }
1229 1236
1230 #endif 1237 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/WTFString.h ('k') | third_party/WebKit/Source/wtf/text/WTFStringTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698