View Javadoc
1   package com.jsql.view.swing.util;
2   
3   import com.jsql.util.StringUtil;
4   import org.apache.commons.lang3.StringUtils;
5   
6   public class UiStringUtil {
7   
8       private UiStringUtil() {
9           // Utility class
10      }
11      
12      public static String detectUtf8Html(String text) {
13          return UiStringUtil.detectUtf8Html(text, false);
14      }
15      
16      public static String detectUtf8HtmlNoWrap(String text) {
17          return UiStringUtil.detectUtf8Html(text, true);
18      }
19      
20      public static String detectUtf8Html(String text, boolean nowrap) {
21          // Fix #35217: NullPointerException on getBytes()
22          if (text == null) {
23              return StringUtils.EMPTY;
24          }
25          
26          // Decode bytes for potentially UTF8 chars
27          // Required by asian and hindi chars, otherwise wrong display in database tree
28          String result = text;
29          if (StringUtil.containsNonStandardScripts(text)) {
30              result = I18nViewUtil.formatNonLatin(text, nowrap ? "white-space:nowrap;" : StringUtils.EMPTY);
31          }
32          return result;
33      }
34  }