diff --git a/hwpfilter/source/formula.cxx b/hwpfilter/source/formula.cxx
index f6fd509d9a67..cc47e8be1037 100644
--- a/hwpfilter/source/formula.cxx
+++ b/hwpfilter/source/formula.cxx
@@ -216,7 +216,7 @@ void Formula::makeIdentifier(Node *res)
indo;
#else
rstartEl(u"math:mi"_ustr, mxList);
- runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value.get())));
+ runistr(getMathMLEntity(tmp->value.get()));
rendEl(u"math:mi"_ustr);
#endif
break;
@@ -238,7 +238,7 @@ void Formula::makeIdentifier(Node *res)
inds; fprintf(stderr,"%s\n",tmp->value.get()); indo;
#else
rstartEl(u"math:mo"_ustr, mxList);
- runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value.get())));
+ runistr(getMathMLEntity(tmp->value.get()));
rendEl(u"math:mo"_ustr);
#endif
break;
@@ -399,7 +399,7 @@ void Formula::makeDecoration(Node *res)
indo;
#else
rstartEl(u"math:mo"_ustr, mxList);
- runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value.get())));
+ runistr(getMathMLEntity(tmp->value.get()));
rendEl(u"math:mo"_ustr);
#endif
@@ -521,9 +521,9 @@ void Formula::makeFence(Node *res)
getMathMLEntity(tmp->next->next->value.get()).c_str());
#else
padd(u"open"_ustr, u"CDATA"_ustr,
- OUString(reinterpret_cast(getMathMLEntity(tmp->value.get()).c_str())));
+ getMathMLEntity(tmp->value.get()));
padd(u"close"_ustr, u"CDATA"_ustr,
- OUString(reinterpret_cast(getMathMLEntity(tmp->next->next->value.get()).c_str())));
+ getMathMLEntity(tmp->next->next->value.get()));
rstartEl(u"math:mfenced"_ustr, mxList);
mxList->clear();
#endif
diff --git a/hwpfilter/source/mapping.h b/hwpfilter/source/mapping.h
index 34d8687d9529..389ed6272bbd 100644
--- a/hwpfilter/source/mapping.h
+++ b/hwpfilter/source/mapping.h
@@ -21,19 +21,20 @@
#include
#include
+#include
#include
#include "hwplib.h"
struct FormulaEntry{
- const char *tex;
+ std::string_view tex;
hchar ucs;
};
// empty square
#define DEFAULT_VALUE 0x25a1
-const struct FormulaEntry FormulaMapTab[] = {
+constexpr struct FormulaEntry FormulaMapTab[] = {
/* Capital Greek */
{"Alpha", 0x0391},
{"Beta", 0x0392},
@@ -360,28 +361,19 @@ const struct FormulaEntry FormulaMapTab[] = {
};
#if OSL_DEBUG_LEVEL < 2
-hchar_string getMathMLEntity(const char *tex)
+OUString getMathMLEntity(std::string_view tex)
{
- static const size_t tabSize = SAL_N_ELEMENTS(FormulaMapTab);
-
- hchar_string buf;
- for (size_t i = 0 ; i < tabSize ; i++) {
- if( !strcmp(tex, FormulaMapTab[i].tex ) ) {
- buf.push_back(FormulaMapTab[i].ucs);
- return buf;
- }
+ auto it = std::find_if(std::begin(FormulaMapTab), std::end(FormulaMapTab),
+ [&tex](const auto& entry) { return entry.tex == tex; });
+ if ( it != std::end(FormulaMapTab) ) {
+ return OUString(it->ucs);
}
- size_t const len = strlen(tex);
- for (size_t i = 0 ; i < len ; i++)
- {
- buf.push_back(tex[i]);
- }
- return buf;
+ return OUString::fromUtf8(tex);
}
#else
-::std::string getMathMLEntity(const char *tex)
+::std::string getMathMLEntity(std::string_view tex)
{
::std::string buf;
buf.append(tex);