------------------------------------------------------------------------------
| 3819 | |
| 3820 | //------------------------------------------------------------------------------ |
| 3821 | int vtkDataReader::DecodeString(char* resname, const char* name) |
| 3822 | { |
| 3823 | if (!resname || !name) |
| 3824 | { |
| 3825 | return 0; |
| 3826 | } |
| 3827 | std::ostringstream str; |
| 3828 | size_t cc = 0; |
| 3829 | unsigned int ch; |
| 3830 | size_t len = strlen(name); |
| 3831 | size_t reslen = 0; |
| 3832 | char buffer[10] = "0x"; |
| 3833 | while (name[cc]) |
| 3834 | { |
| 3835 | if (name[cc] == '%') |
| 3836 | { |
| 3837 | if (cc <= (len - 3)) |
| 3838 | { |
| 3839 | buffer[2] = name[cc + 1]; |
| 3840 | buffer[3] = name[cc + 2]; |
| 3841 | buffer[4] = 0; |
| 3842 | auto result = vtk::scan<unsigned int>(std::string_view(buffer), "{:x}"); |
| 3843 | ch = result->value(); |
| 3844 | str << static_cast<char>(ch); |
| 3845 | cc += 2; |
| 3846 | reslen++; |
| 3847 | } |
| 3848 | } |
| 3849 | else |
| 3850 | { |
| 3851 | str << name[cc]; |
| 3852 | reslen++; |
| 3853 | } |
| 3854 | cc++; |
| 3855 | } |
| 3856 | strncpy(resname, str.str().c_str(), reslen + 1); |
| 3857 | resname[reslen] = 0; |
| 3858 | return static_cast<int>(reslen); |
| 3859 | } |
| 3860 | |
| 3861 | static int my_getline(istream& in, std::string& out, char delimiter) |
| 3862 | { |
no test coverage detected