@@ -89,30 +89,34 @@ struct WriteAttributePtr {
8989};
9090
9191static core::Dtype GetDtypeFromPCDHeaderField (char type, int size) {
92- if (type == ' I' ) {
92+ char type_uppercase = std::toupper (type, std::locale ());
93+ if (type_uppercase == ' I' ) {
9394 if (size == 1 ) return core::Dtype::Int8;
9495 if (size == 2 ) return core::Dtype::Int16;
9596 if (size == 4 ) return core::Dtype::Int32;
9697 if (size == 8 )
9798 return core::Dtype::Int64;
9899 else
99- utility::LogError (" Unsupported data type." );
100- } else if (type == ' U' ) {
100+ utility::LogError (" Unsupported size {} for data type {}." , size,
101+ type);
102+ } else if (type_uppercase == ' U' ) {
101103 if (size == 1 ) return core::Dtype::UInt8;
102104 if (size == 2 ) return core::Dtype::UInt16;
103105 if (size == 4 ) return core::Dtype::UInt32;
104106 if (size == 8 )
105107 return core::Dtype::UInt64;
106108 else
107- utility::LogError (" Unsupported data type." );
108- } else if (type == ' F' ) {
109+ utility::LogError (" Unsupported size {} for data type {}." , size,
110+ type);
111+ } else if (type_uppercase == ' F' ) {
109112 if (size == 4 ) return core::Dtype::Float32;
110113 if (size == 8 )
111114 return core::Dtype::Float64;
112115 else
113- utility::LogError (" Unsupported data type." );
116+ utility::LogError (" Unsupported size {} for data type {}." , size,
117+ type);
114118 } else {
115- utility::LogError (" Unsupported data type. " );
119+ utility::LogError (" Unsupported data type {}. " , type );
116120 }
117121}
118122
@@ -305,13 +309,14 @@ static void ReadASCIIPCDColorsFromField(ReadAttributePtr &attr,
305309 if (field.size == 4 ) {
306310 std::uint8_t data[4 ] = {0 };
307311 char *end;
308- if (field.type == ' I' ) {
312+ char type_uppercase = std::toupper (field.type , std::locale ());
313+ if (type_uppercase == ' I' ) {
309314 std::int32_t value = std::strtol (data_ptr, &end, 0 );
310315 std::memcpy (data, &value, sizeof (std::int32_t ));
311- } else if (field. type == ' U' ) {
316+ } else if (type_uppercase == ' U' ) {
312317 std::uint32_t value = std::strtoul (data_ptr, &end, 0 );
313318 std::memcpy (data, &value, sizeof (std::uint32_t ));
314- } else if (field. type == ' F' ) {
319+ } else if (type_uppercase == ' F' ) {
315320 float value = std::strtof (data_ptr, &end);
316321 std::memcpy (data, &value, sizeof (float ));
317322 }
0 commit comments