summaryrefslogtreecommitdiff
path: root/core/fxcrt
AgeCommit message (Collapse)Author
2018-10-10Add Observable::ObservedPtr::HasObservable().Lei Zhang
if (pObserved->HasObservable()) is more readable than if (*pObserved). Change-Id: I61ad3deb8e9f30cdc120a05555c2558f34489681 Reviewed-on: https://pdfium-review.googlesource.com/c/43811 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-10Fix some random nits.Lei Zhang
Change-Id: I735c057d4900bcd58c1041df16b885dc7c9ed27d Reviewed-on: https://pdfium-review.googlesource.com/c/43793 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-09Do IWYU for retain_ptr.h and unowned_ptr.hLei Zhang
Change-Id: I2897feee27f80c85f0328f0b220ae5be93686170 Reviewed-on: https://pdfium-review.googlesource.com/c/43610 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-09Do IWYU for ptr_util.h.Lei Zhang
Change-Id: Ib96a66eb47bea791f061e1d6da8aadad8037a99d Reviewed-on: https://pdfium-review.googlesource.com/c/43609 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-09Kill off some memset()s following FX_Alloc()Tom Sepez
Change-Id: I92aa74c86aef890fcb991f039b9707d680fdb83c Reviewed-on: https://pdfium-review.googlesource.com/c/43652 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-06Simplify CFX_FloatRect::Inflate() and Deflate().Lei Zhang
Make all the other Inflate() methods to call the 4 parameters version. Make all the other Deflate() methods to call the 4 parameters version. Make the 4 parameters version of Deflate() call Inflate(). Change-Id: I1d2702898206bf9845f0bb176c2bf4d5a315cf96 Reviewed-on: https://pdfium-review.googlesource.com/c/43573 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-06Move CFX_FloatRect method impls out of the header.Lei Zhang
Change-Id: Ice814a84f699ea32325e98bbcea1a5b7db065fc6 Reviewed-on: https://pdfium-review.googlesource.com/c/43572 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-06Encapsulate CPDF_PageObject's rect member.Lei Zhang
At the same time, change it from 4 floats to a CFX_FloatRect. Change-Id: I00ded941723d6a264b7a17c73fd337e66b449308 Reviewed-on: https://pdfium-review.googlesource.com/c/43570 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-04Change |virtual ~Foo(){}| to |virtual ~Foo()=default;|chromium/3571Tom Sepez
Otherwise code coverage flags the empty body as unreachable. Change-Id: Iee1d9a876d68276529c70d9b8c7a28276f271767 Reviewed-on: https://pdfium-review.googlesource.com/c/43514 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-04Remove some unused code in fxcrt strings.Tom Sepez
Unused static method in StringDataTemplate<>. Unused WideString::GetFloat(), which in turn allows us to remove another custom string to float parser. Change-Id: If7ae60a0ba90563598232bad229f97cb74d682ba Reviewed-on: https://pdfium-review.googlesource.com/c/43513 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-03Tidy CFX_UTF8Decoder.Tom Sepez
Remove unused method, make ctor/dtor out-of-line. Change-Id: I77bb7c1da8e9d369085072639ca388247f2b9225 Reviewed-on: https://pdfium-review.googlesource.com/c/43455 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-03Add FxFolderHandleCloser for use with std::unique_ptr.Lei Zhang
Use it in a couple of places. Make the similar code in the two places even more so. Change-Id: I3fc6a567088217e24506cdf7ab927b94cb5a4d52 Reviewed-on: https://pdfium-review.googlesource.com/43330 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-01Fix #include ordering / formatting.Lei Zhang
Change-Id: I996c9b32d767960a5388e44e13180e1f6577ce38 Reviewed-on: https://pdfium-review.googlesource.com/43190 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-09-25Add FxAlignToBoundary<>() template helper function.Tom Sepez
Because I nearly botched this trivial calculation in the previous CL. Change-Id: I7438f9d3476d93b7899c2d7d761234769f53f9e3 Reviewed-on: https://pdfium-review.googlesource.com/43010 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-20Change CFX_FixedBufGrow to take a size_t.Lei Zhang
Thanks to Qihoo 360 Vulcan Team for pointing this out. Change-Id: Ib6dd77307b3759e54168127dc0e17aa42698d852 Reviewed-on: https://pdfium-review.googlesource.com/42830 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-09-20Fix misc lint errors and other cleanups.Lei Zhang
Change-Id: I00ce0109251d1231858e87ffc3889abe6937fa26 Reviewed-on: https://pdfium-review.googlesource.com/42811 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-09-20Remove more unneeded STL #includes from headers.Lei Zhang
Remove some variables named "string" to avoid false positives from the linter. Change-Id: I00a53e6970451fd0cea8ab2f8178183650ca00d2 Reviewed-on: https://pdfium-review.googlesource.com/42810 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-09-20Remove many unneeded STL #includes from headers.Lei Zhang
Change-Id: I7010cedee8d17d05b2c37a94d767e6f3a9c48f7d Reviewed-on: https://pdfium-review.googlesource.com/42790 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-09-18Transfer ownership of nodes to top-level XML docRyan Harrison
For XFA, XML nodes are owned by the XML doc that they were created by, but references to them are stored elsewhere. For a PDF document there is one top-level XML document created and retained when the initial XFA XML is parsed. Another can be created if loadXML is called by JS. In the existing code the XML doc that owns the newly created nodes is local to loadXML. So the nodes are destroyed right after putting refernces to them into the main XFA data structures. This CL adds in a method to transfer ownership of the XML nodes from one doc to another, and uses it to correctly retain the newly created nodes, by having them owned by the top-level XML doc. BUG=chromium:884664 Change-Id: Id29b4edbfe44aefb9713328e4e217e830f7e9e14 Reviewed-on: https://pdfium-review.googlesource.com/42690 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-09-17Make fxcrt::Retainable non-copyable.Tom Sepez
Because copying ref-counts from one object to another is a bad idea and sure to leak. Change-Id: I5f2c0891d08c893eb1ac8fb8a5908d975295ae2e Reviewed-on: https://pdfium-review.googlesource.com/42670 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-17Fix final/protected conflicts.Tom Sepez
Classes marked |final| should not have |protected| members. In turn, "private field m_dwEncryptObjNum is not used" warning is produced. Change-Id: I51a96aca5a5f499381a6764d892962f7f2dc0327 Reviewed-on: https://pdfium-review.googlesource.com/42611 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-09-13Use safe math in MatchFloatRange().Tom Sepez
Bug: 882959 Change-Id: I3ce17916da1346158dbf5282be6696879a22567a Reviewed-on: https://pdfium-review.googlesource.com/42355 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-09-13Reland "Introduce FX_Number class as a replacement for FX_atonum()."Tom Sepez
This reverts commit 29e180342e18873babf1c74f7c5c056f90a191b0. Reason for revert: probably harmless Original change's description: > Revert "Introduce FX_Number class as a replacement for FX_atonum()." > > This reverts commit a5d7ad3aa8feb08a14b5cca173d673054c1ade23. > > Reason for revert: Speculative revert to get back before flake. > > Original change's description: > > Introduce FX_Number class as a replacement for FX_atonum(). > > > > The issue with FX_atonum() is that it doesn't return any information > > about whether it range-checked its integer values as a signed or > > unsigned type, even though it knows this as part of its processing. > > > > Rather than adding another out parameter to that function, create > > a class to hold all this information together. > > > > This is the first place things went astray while diagnosing > > bug 882959, in that a large positive value was cast to float as a > > negative value. Unfortunately, this doesn't affect the related bug, > > but is a step in the right direction. > > > > Change-Id: I0977ec8fccf85e2632a962507bdd30a1cbe6d33c > > Reviewed-on: https://pdfium-review.googlesource.com/42353 > > Reviewed-by: Lei Zhang <thestig@chromium.org> > > Commit-Queue: Tom Sepez <tsepez@chromium.org> > > TBR=thestig@chromium.org,tsepez@chromium.org > > Change-Id: Ia56270c3daa80408fc2b23eb4384a77f03f45b82 > Reviewed-on: https://pdfium-review.googlesource.com/42392 > Reviewed-by: Tom Sepez <tsepez@chromium.org> > Commit-Queue: Tom Sepez <tsepez@chromium.org> TBR=thestig@chromium.org,tsepez@chromium.org Change-Id: I83c37aa3040a8890f2117753f19ab1d452d411e7 Reviewed-on: https://pdfium-review.googlesource.com/42410 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-09-13Revert "Introduce FX_Number class as a replacement for FX_atonum()."Tom Sepez
This reverts commit a5d7ad3aa8feb08a14b5cca173d673054c1ade23. Reason for revert: Speculative revert to get back before flake. Original change's description: > Introduce FX_Number class as a replacement for FX_atonum(). > > The issue with FX_atonum() is that it doesn't return any information > about whether it range-checked its integer values as a signed or > unsigned type, even though it knows this as part of its processing. > > Rather than adding another out parameter to that function, create > a class to hold all this information together. > > This is the first place things went astray while diagnosing > bug 882959, in that a large positive value was cast to float as a > negative value. Unfortunately, this doesn't affect the related bug, > but is a step in the right direction. > > Change-Id: I0977ec8fccf85e2632a962507bdd30a1cbe6d33c > Reviewed-on: https://pdfium-review.googlesource.com/42353 > Reviewed-by: Lei Zhang <thestig@chromium.org> > Commit-Queue: Tom Sepez <tsepez@chromium.org> TBR=thestig@chromium.org,tsepez@chromium.org Change-Id: Ia56270c3daa80408fc2b23eb4384a77f03f45b82 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://pdfium-review.googlesource.com/42392 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-09-13Test that FX_TryRealloc failure leaves original contents intactTom Sepez
Change-Id: I2b1e5cc7a9576b5bb3bf3888225d1f6e54e0c95b Reviewed-on: https://pdfium-review.googlesource.com/42051 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-13Introduce FX_Number class as a replacement for FX_atonum().Tom Sepez
The issue with FX_atonum() is that it doesn't return any information about whether it range-checked its integer values as a signed or unsigned type, even though it knows this as part of its processing. Rather than adding another out parameter to that function, create a class to hold all this information together. This is the first place things went astray while diagnosing bug 882959, in that a large positive value was cast to float as a negative value. Unfortunately, this doesn't affect the related bug, but is a step in the right direction. Change-Id: I0977ec8fccf85e2632a962507bdd30a1cbe6d33c Reviewed-on: https://pdfium-review.googlesource.com/42353 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-09-04Fix some more span/memcpy interactions.Tom Sepez
Use the preferred idiom of creating a subspan, which makes the proper checks prior to the copy. Change-Id: Ia7f25b5760dea5707df66cf421195b23a1ce0ad0 Reviewed-on: https://pdfium-review.googlesource.com/41911 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-30Add unit test for AutoRestorer<> on smart pointer types.Tom Sepez
Test UnownedPtr<> and RetainPtr<>. We cannot operate against std::unique_ptr<> because we need a copyable type. Add test for self-reassignment on going out of scope. Move one test helper class to testing/ so it can be shared among unit tests. Allow it to recognize if it ever gets "destroyed", otherwise we can't be sure Retain/Release applied in the correct order. Change-Id: I13056094c70079f7283cbc7600948f81a64874b4 Reviewed-on: https://pdfium-review.googlesource.com/41690 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-27The final game: mark everything final.Tom Sepez
Then revert the ones that break compilation. Fix one IWYU noticed during presubmit. Change-Id: I881a8a72818e55dbc4816247e35ff5e3015194e7 Reviewed-on: https://pdfium-review.googlesource.com/41470 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-23Use pdfium::span<> in CPDF_Stream::SetData().Tom Sepez
Conversion to span makes this more elegant in a number of places, owing to std::vector directly converting to span, and the bytestring's ToRawSpan(). Disambiguate single-argument forms to allow passing {} as an argument. Change-Id: Ibd5eaadca8d8cbbd589338f375c7ee8439fd3eb2 Reviewed-on: https://pdfium-review.googlesource.com/41272 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-23Pass unique_ptr<> to CFX_MemoryStream constructorTom Sepez
Proves we own the memory that the class will eventually free. Change-Id: Ie9523da8db738e7478a1c73e3e1a6b24aed38442 Reviewed-on: https://pdfium-review.googlesource.com/41290 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-23Fix GCC build with V8 disabled.Lei Zhang
- Remove set, but otherwise unused variables. - Mark some pdfium_test code as V8-enabled only. - Do not build one unit test with GCC. Change-Id: I3f04273a7731086e08386478a62769bf06f6d8a4 Reviewed-on: https://pdfium-review.googlesource.com/41271 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-22Mark CFX_XMLNode pointers as const in various places.Lei Zhang
Change-Id: I86c6f7526e2ef4c3e8de30ebaff223095ee70fc4 Reviewed-on: https://pdfium-review.googlesource.com/40811 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-08-22Simplify GetEmbeddedObj() methods.Lei Zhang
Change-Id: I976a8841f1519310cbf934103336dc050a7c293d Reviewed-on: https://pdfium-review.googlesource.com/40773 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-08-21Allow creation of a MaybeOwned<T> from UnownedPtr<T>.Tom Sepez
Small test to show these forms compile and do not transfer ownership. Change-Id: I1787a57d4d0bf70da7b6101c1f958cfe9a8f9dda Reviewed-on: https://pdfium-review.googlesource.com/40830 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-16Remove default arg from CFX_BinaryBuf::EstimateSize().Tom Sepez
Disentangle setting an allocation step from estimating size, these separate concepts can be handled separately. Change-Id: I27bf3e193018a4377ccf266207b889fdb672826c Reviewed-on: https://pdfium-review.googlesource.com/40210 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-15Remove optional prepend argument from matrix transformations.Tom Sepez
Callers always want one form or the other, so split into separate methods. This may save some branching. Remove forms that are not used. Put more helpful helper function in .cpp file. Change-Id: I4e025de7f69ce3f323cd290a5dc8202dd4f8ca07 Reviewed-on: https://pdfium-review.googlesource.com/40270 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-15Make CFX_MemoryStream always consecutive.chromium/3524Lei Zhang
Non-consecutive mode has questionable correctness and is not an obvious performance win. Change-Id: Idaa66e5ee5c4604628a0f55b67d5a04ab47ea5ec Reviewed-on: https://pdfium-review.googlesource.com/40050 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-14Remove CFX_BufferSeekableReadStream.Lei Zhang
Replace it with CFX_ReadOnlyMemoryStream, which does the same thing. Take some checks from CFX_BufferSeekableReadStream and add them CFX_ReadOnlyMemoryStream. Change-Id: I25554c3aec3ec96967f8df16ca68a64dba121b6f Reviewed-on: https://pdfium-review.googlesource.com/40070 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-14Remove |bTakeOver| parameter from CFX_MemoryStream ctor.Lei Zhang
It is always true now. BUG=pdfium:263 Change-Id: I74fd0091f5815701718e8cd5acc6e7a0de772a85 Reviewed-on: https://pdfium-review.googlesource.com/40031 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-13Make CFX_ReadOnlyMemoryStream take a span.Lei Zhang
Change-Id: Id097320ab2d9b5d1579582e5797e29c701499501 Reviewed-on: https://pdfium-review.googlesource.com/39991 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-08-13Implement CFX_CodecMemory.Lei Zhang
This class is much simpler than CFX_MemoryStream and does only what CFX_BmpDecompressor and CFX_GifContext needs. Swap out CFX_MemoryStream and remove CFX_MemoryStream::Seek(). BUG=pdfium:263 Change-Id: Ifd8ce4d2b6c9fedd6ec842d46f54fc8e654fbca7 Reviewed-on: https://pdfium-review.googlesource.com/39880 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-08-13Move CPDFSDK_MemoryAccess to fxcrt.Lei Zhang
Rename it CFX_ReadOnlyMemoryStream and swap out one use of CFX_MemoryStream. BUG=pdfium:263 Change-Id: I15012df156a6a4d7c36f6fd58f32c355eae5fa1a Reviewed-on: https://pdfium-review.googlesource.com/39878 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-13Split CFX_MemoryStream::m_dwFlags into two bools.chromium/3522Lei Zhang
Make them const, and remove m_nGrowSize which is always the same value. Also remove unused method and make GetBuffer() non-const. Change-Id: I272aa4c268c4a887e155800b7c8c10892b343465 Reviewed-on: https://pdfium-review.googlesource.com/39877 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-10Kill some optional parameters that are always supplied.Tom Sepez
No need to even bring any .cpp files in line with these headers. Change-Id: I934169d77ae09adc11f02e5ea92b1f8b078c9477 Reviewed-on: https://pdfium-review.googlesource.com/39876 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-10Add proxy for syscall timeRyan Harrison
This CL adds a proxy, FXSYS_time, for the time syscall, so that a testing mechanism can be implemented. Specically there is now a flag for pdfium_test, --time=, that allows setting the time since the epoch that will be returned. This plumbed all the way down into the proxy and allows for stable results for tests that depend on getting the current time. There are other places in the code base that will need to be patched like this, that will be dealt with in follow on CLs. BUG=pdfium:1104 Change-Id: I2de185f8d47abe46704dd579c13a54948b7f81e0 Reviewed-on: https://pdfium-review.googlesource.com/39750 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-08-09Move all utf8 decoding under fx_string.hTom Sepez
Put encoder in cfx_utf8encoder.{h,cpp} to parallel decoder. Add tests, and fix one corner case involving 0xff. Change-Id: Ib97540afdc708bcc6280a79c76734ec68ea72690 Reviewed-on: https://pdfium-review.googlesource.com/39770 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-08Remove unused codepage from WideString::GetWideString().Tom Sepez
Consolidate code into sole caller, which always retrieves a string from the "default ANSI code page". Add unit test for this code path. Fix sign extension bug giving bogus 0xffffff80 codepoint uncovered by unit test on non-windows. Note windows result is different because the system conversion routine does actually work. Change-Id: I1c1246b203ee66e9ff0b6fccf97594788bcd0fca Reviewed-on: https://pdfium-review.googlesource.com/39730 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-08Move ByteString::FromUnicode() to WideString::ToDefANSI()Tom Sepez
Turns out that "FromUnicode" is misleading in that, on linux, it simply removes any characters beyond 0xFF and passes the rest unchanged, so no unicode decoding actually takes place. On Windows, it passes it into the system function specifying FX_CODEPAGE_DefANSI, converting it into the so-called "default ANSI code plane", passing some characters, converting others to '?' and still others to 'A'. Either way, nothing resembling UTF8 comes out of this, so pick a better name. These now immediately look suspicious, so a follow-up CL will see which ones should really be WideString::UTF8Encode() instead. Making this a normal method on a widestring rather than a static method on a bytestring feels more natural; this is parallel to the UTF8Encode and UTF16LE_Encode functions. Add a test that shows these conversions. Change-Id: Ia7551b47199eba61b5c328a97bfe9176ac8e583c Reviewed-on: https://pdfium-review.googlesource.com/39690 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-07Remove unused codepage code from GetByteString().Tom Sepez
It is only called ever called from one place with 0 (FX_CODEPAGE_DefANSI), with more complicated usage being funneled directly into FXSYS_ code. Next, fold it into ByteString::FromUnicode(). Change-Id: I85aa0dd3a4ca8cddcff22533e0a284ff3f5535ee Reviewed-on: https://pdfium-review.googlesource.com/39670 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>