[pdal] Non-English characters

Andrew Bell andrew.bell.ia at gmail.com
Wed Jan 17 07:27:40 PST 2018


The following complete program runs properly for me on OSX.  I'm referring
to the file that you provided earlier.

======

master $ DYLD_LIBRARY_PATH=./lib a.out
View size = 867!
X/Y/Z = 0.00472708/0.0012/-0.000833515!
X/Y/Z = 0.0048/0.0012/0!
X/Y/Z = 0/0/0!
X/Y/Z = 0.00451052/0.0012/-0.0016417!
X/Y/Z = 0.00415692/0.0012/-0.00240001!
X/Y/Z = 0.00367701/0.0012/-0.00308539!
X/Y/Z = 0.00308537/0.0012/-0.00367702!
X/Y/Z = 0.00239999/0.0012/-0.00415693!
X/Y/Z = 0.00164168/0.0012/-0.00451053!
X/Y/Z = 0.000833496/0.0012/-0.00472708!
X/Y/Z = -1.79482e-08/0.0012/-0.0048!
X/Y/Z = -0.00083353/0.0012/-0.00472707!
X/Y/Z = -0.00164172/0.0012/-0.00451052!
X/Y/Z = -0.00240002/0.0012/-0.00415691!
X/Y/Z = -0.0030854/0.0012/-0.003677!
X/Y/Z = -0.00367703/0.0012/-0.00308536!
X/Y/Z = -0.00415694/0.0012/-0.00239997!
X/Y/Z = -0.00451054/0.0012/-0.00164167!

==========

#include <pdal/StageFactory.hpp>
#include <pdal/Options.hpp>
#include <pdal/PointTable.hpp>
#include <pdal/PDALUtils.hpp>

int main()
{
  using namespace pdal;

  pdal::StageFactory factory;

  pdal::PointTable table;

    std::string filename(u8"/Users/acbell/Downloads/рфддвбс.ply");
  std::string sReaderDriver =
pdal::StageFactory::inferReaderDriver(filename);

  if (!sReaderDriver.empty())

  {

    pdal::Stage *pReader = factory.createStage(sReaderDriver);

    pdal::Options readerOptions;

    readerOptions.add("filename", filename);

    if (pReader)

    {

      pReader->setOptions(readerOptions);
      pReader->prepare(table);
      PointViewSet s = pReader->execute(table);
      PointViewPtr v = *s.begin();

      std::cerr << "View size = " << v->size() << "!\n";
      for (PointId id = 0; id < v->size(); ++id)
          std::cerr << "X/Y/Z = " <<
            v->getFieldAs<double>(Dimension::Id::X, id) << "/" <<
            v->getFieldAs<double>(Dimension::Id::Y, id) << "/" <<
            v->getFieldAs<double>(Dimension::Id::Z, id) << "!\n";
    }
  }

  return 0;

}

On Wed, Jan 17, 2018 at 9:33 AM, <pidgeon13 at googlemail.com> wrote:

> The following code is such an example.
>
>
>
> int main(
>
> {
>
>   pdal::StageFactory factory;
>
>   pdal::PointTable table;
>
>   std::string sReaderDriver = pdal::StageFactory::
> inferReaderDriver(u8"C:\\Users\\stephenp\\PDALe\\рфддвбс.ply");
>
>   if (!sReaderDriver.empty())
>
>   {
>
>     pdal::Stage *pReader = factory.createStage(sReaderDriver);
>
>     pdal::Options readerOptions;
>
>     readerOptions.add("filename", u8"C:\\Users\\stephenp\\PDALe\
> \рфддвбс.ply");
>
>     if (pReader)
>
>     {
>
>       pReader->setOptions(readerOptions);
>
>       pdal::PointViewSet set;
>
>       pdal::PointViewPtr pView;
>
>       pReader->prepare(table);
>
>       set = pReader->execute(table);
>
>       pView = *set.begin();
>
>       int nSize = pView->size();
>
>       std::cerr << Utils::toJSON(pReader->getMetadata());
>
>     }
>
>   }
>
>   return 0;
>
> }
>
>
>
> Regards,
>
>
>
> Stephen
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
> *From: *Andrew Bell <andrew.bell.ia at gmail.com>
> *Sent: *17 January 2018 13:50
> *To: *Stephen Pidgeon <pidgeon13 at googlemail.com>
> *Cc: *Mateusz Loskot <mateusz at loskot.net>; pdal at lists.osgeo.org
>
> *Subject: *Re: [pdal] Non-English characters
>
>
>
> I still haven't seen code that shows a UTF-8 string being passed to PDAL
> as a filename and PDAL failing to handle it.  Something like this would
> help:
>
>
>
> void main()
>
> {
>
>   LasReader r;
>
>   Options ro;
>
>   ro.add("filename", "some filename that causes a problem")
>
>
>
>   PointTable t;
>
>   r.prepare(t);
>
>   r.execute(t);
>
>   std::cerr << Utils::toJSON(r.getMetadata());
>
> }
>
>
>
> Does something like this fail?  If not, can you provide an example?  I
> can't help unless I understand the problem.
>
>
>
> Thanks,
>
>
>
>
>
> On Wed, Jan 17, 2018 at 5:31 AM, <pidgeon13 at googlemail.com> wrote:
>
> The two methods are producing the same std::string for me. I’m fairly sure
> that specifying the code page in CW2A overrides using the ANSI codepage.
>
>
>
> Regards,
>
>
>
> STephen
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
> *From: *Mateusz Loskot <mateusz at loskot.net>
> *Sent: *17 January 2018 10:21
>
>
> *To: *pidgeon13 at googlemail.com
> *Cc: *Andrew Bell <andrew.bell.ia at gmail.com>; pdal at lists.osgeo.org
> *Subject: *Re: [pdal] Non-English characters
>
>
>
> CUtils::toUtf8 looks fine to me
>
>
>
> On 17 January 2018 at 11:17,  <pidgeon13 at googlemail.com> wrote:
>
> > I have included another piece of code, which is what I tried first using
>
> > WideCharToMultiByte. Should this perform the conversion correctly?
>
> >
>
> >
>
> >
>
> > Regards,
>
> >
>
> >
>
> >
>
> > Stephen
>
> >
>
> >
>
> >
>
> > Sent from Mail for Windows 10
>
> >
>
> >
>
> >
>
> > From: Mateusz Loskot
>
> > Sent: 17 January 2018 10:09
>
> >
>
> >
>
> > To: pidgeon13 at googlemail.com
>
> > Cc: Andrew Bell; pdal at lists.osgeo.org
>
> > Subject: Re: [pdal] Non-English characters
>
> >
>
> >
>
> >
>
> > See what the docs [1] say about the A in CW2A.
>
> >
>
> >
>
> >
>
> > Meanwhile, you need to use WideCharToMultiByte [2] with CP_UTF8 code
> page.
>
> >
>
> >
>
> >
>
> > [1] https://msdn.microsoft.com/en-us/library/87zae4a3.aspx
>
> >
>
> > [2] https://msdn.microsoft.com/en-us/library/windows/desktop/
> dd374130.aspx
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > On 17 January 2018 at 11:02,  <pidgeon13 at googlemail.com> wrote:
>
> >
>
> >> std::string sFilePath = CW2A(filepath, CP_UTF8);
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >> Regards,
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >> Stephen
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >> Sent from Mail for Windows 10
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >> From: Mateusz Loskot
>
> >
>
> >> Sent: 17 January 2018 10:00
>
> >
>
> >> To: pidgeon13 at googlemail.com
>
> >
>
> >> Cc: Andrew Bell; pdal at lists.osgeo.org
>
> >
>
> >> Subject: Re: [pdal] Non-English characters
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >> On 17 January 2018 at 10:31,  <pidgeon13 at googlemail.com> wrote:
>
> >
>
> >>
>
> >
>
> >>>
>
> >
>
> >>
>
> >
>
> >>> The user browses for a file in a dialog file browser, and I convert
> this
>
> >
>
> >>
>
> >
>
> >>> string to UTF-8
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >> How do you convert to UTF-8?
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >> Please, you need to show some code (one image for 1000 words).
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >> Best regards,
>
> >
>
> >>
>
> >
>
> >> --
>
> >
>
> >>
>
> >
>
> >> Mateusz Loskot, http://mateusz.loskot.net
>
> >
>
> >>
>
> >
>
> >>
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > --
>
> >
>
> > Mateusz Loskot, http://mateusz.loskot.net
>
> >
>
> >
>
>
>
>
>
>
>
> --
>
> Mateusz Loskot, http://mateusz.loskot.net
>
>
>
>
>
>
>
> --
>
> Andrew Bell
> andrew.bell.ia at gmail.com
>
>
>



-- 
Andrew Bell
andrew.bell.ia at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pdal/attachments/20180117/4286ed7a/attachment.html>


More information about the pdal mailing list