public ActionResult Index() { //菜单简繁体转换 var localID = Thread.CurrentThread.CurrentUICulture.Name == "zh-CN" ? 0 : 2; VbStrConv strTransfer = localID == 0? Microsoft.VisualBasic.VbStrConv.SimplifiedChinese : Microsoft.VisualBasic.VbStrConv.TraditionalChinese; return(View()); }
static void WriteChanged_SemiVoiced(VbStrConv mode) { var changed = EnumerableHelper.RangeChars(char.MinValue, char.MaxValue) .Select(c => new { before = c, after = Strings.StrConv($"{c}゚", mode) }) .Where(_ => _.after.Length == 1) .Select(_ => $"{ToMessage1(_.before)} > {ToMessage2(_.after[0])}") .ToArray(); File.WriteAllLines($"VBStrings-{mode.ToString().Replace(", ", "")}-SemiVoiced.txt", changed, Encoding.UTF8); }
// https://docs.microsoft.com/ja-jp/dotnet/api/microsoft.visualbasic.strings.strconv?view=net-5.0 public static string StrConv(string str, VbStrConv Conversion) { // TODO 要る分だけ実装ないし完全に置き換える // TODO Impl Wide switch (Conversion) { default: return(str); } }
private static VbStrConv ConvertToEnum(SearchText search) { VbStrConv vbStrConv = VbStrConv.None; foreach (var v in search.VbStrConv) { vbStrConv += (int)v; } return(vbStrConv); }
static void WriteChanged_Narrow(VbStrConv mode) { // 他言語の文字は "?" に変換されます。 var changed = EnumerableHelper.RangeChars(char.MinValue, char.MaxValue) .Select(c => new { before = c, after = Strings.StrConv(c.ToString(), mode) }) .Where(_ => _.before.ToString() != _.after) .Where(_ => TargetChars.Contains(_.before) || _.after != "?") .Select(_ => $"{ToMessage1(_.before)} > {(_.after.Length == 1 ? ToMessage2(_.after[0]) : _.after)}") .ToArray(); File.WriteAllLines($"VBStrings-{mode.ToString().Replace(", ", "")}.txt", changed, Encoding.UTF8); }
private static string convertlong(string xml, VbStrConv convert) { string output = ""; const int buffersize = 10000; int length = xml.Length; for (int i = 0; i < length - buffersize; i += buffersize) // put it through in Chunks { output += Strings.StrConv(xml.Substring(i, buffersize), convert); } output += Strings.StrConv(xml.Substring(length - (length % buffersize), length % buffersize), convert); // last bit is < buffersize return(output); }
/// <summary> /// /// </summary> /// <param name="str">文本</param> /// <param name="Conversion">被翻译成的语言</param> /// <param name="LocaleID"></param> /// <returns></returns> public static string StrConv(string str, VbStrConv Conversion, int LocaleID = 0) { try { ChineseTranslateDirection chineseTranslate = (Conversion == VbStrConv.SimplifiedChinese) ? ChineseTranslateDirection.TraditionalToSimplified : ChineseTranslateDirection.SimplifiedToTraditional; string value = ChineseTranslate.Convert(str, chineseTranslate); return(value); } catch (Exception ex) { return(str);//非Wwindows可能会报错~ } }
/* Converter Methods*/ private void tradSimpConvert(VbStrConv convert) { Word.Range currentRange = Globals.ThisAddIn.Application.Selection.Range; if (currentRange.Text == null) { System.Windows.Forms.MessageBox.Show("Please select some text."); } else { // don't use get_XML(), converts equations to pictures, use WordOpenXML currentRange.InsertXML(convertlong(currentRange.WordOpenXML, convert)); currentRange.Select(); } }
// Perform a string conversion (we don't support simplified/traditional // conversions or linguistic casing yet). public static String StrConv (String str, VbStrConv Conversion, [Optional][DefaultValue(0)] int LocaleID) { if (str == null) { return(null); } if ((Conversion & VbStrConv.Wide) != 0) { str = Utils.ToWide(str); } else if ((Conversion & VbStrConv.Narrow) != 0) { str = Utils.ToNarrow(str); } if ((Conversion & VbStrConv.Katakana) != 0) { str = Utils.ToKatakana(str); } else if ((Conversion & VbStrConv.Hiragana) != 0) { str = Utils.ToHiragana(str); } switch (Conversion & (VbStrConv)0x0003) { case VbStrConv.UpperCase: { str = GetTextInfo(LocaleID).ToUpper(str); } break; case VbStrConv.LowerCase: { str = GetTextInfo(LocaleID).ToLower(str); } break; case VbStrConv.ProperCase: { str = GetTextInfo(LocaleID).ToTitleCase(str); } break; } return(str); }
public static string StrConv(string str, VbStrConv Conversion, int LocaleID = 0) { switch (Conversion) { case VbStrConv.Wide: { var result = ""; for (int i = 0; i < str.Length; ++i) { char c = str[i]; char found = '\x0'; if (ToWide.TryGetValue(c, out found)) { result += found; } else { result += ' '; result += c; } } return(result); } case VbStrConv.Narrow: { var result = ""; for (int i = 0; i < str.Length; ++i) { char c = str[i]; char found = '\x0'; if (ToNarrow.TryGetValue(c, out found)) { result += found; } else { result += c; } } return(result); } } return(str); }
private bool TryStrConvUpdate(string original, ConversionItem item, out string updatedText) { var search = item.Search; var replacement = item.Replacement; updatedText = null; if (SearchTextValid(search)) { VbStrConv vbStrConv = ConvertToEnum(search); try { if (settings.SourceCulture != null) { updatedText = original.RegexReplace(search.Text, replacement, search.CaseSensitive, m => Strings.StrConv(m.Value, vbStrConv, settings.SourceCulture.LCID)); } else if (vbStrConv.HasFlag(VbStrConv.Hiragana) || vbStrConv.HasFlag(VbStrConv.Katakana)) { updatedText = original.RegexReplace(search.Text, replacement, search.CaseSensitive, m => Strings.StrConv(m.Value, vbStrConv, new CultureInfo("ja-JP").LCID)); } else { updatedText = original.RegexReplace(search.Text, replacement, search.CaseSensitive, m => Strings.StrConv(m.Value, vbStrConv)); } } catch (ArgumentException e) { Reporter.Report(this, ErrorLevel.Warning, $"Error {search.Text}: {e.Message}", "Exception happened"); } } // String compare has to be always case-sensitive here return((updatedText != null) && !original.NormalStringCompare(updatedText, true, settings.SourceCulture)); }
public string StrConv(string s) { VbStrConv conv = VbStrConv.None; switch (m_conv) { case CasingEnum.None: conv = VbStrConv.None; break; case CasingEnum.Upper: conv = VbStrConv.Uppercase; break; case CasingEnum.Lower: conv = VbStrConv.Lowercase; break; case CasingEnum.Proper: conv = VbStrConv.ProperCase; break; } return(Microsoft.VisualBasic.Strings.StrConv(s, conv, 0)); }
private bool ToKatakana(KakasiReader input, TextWriter output, VbStrConv conv) { if (!IsHiragana(input.Get())) { return(false); } while (true) { int ch = input.Get(); if (IsHiragana(ch)) { input.Consume(1); foreach (char c in Strings.StrConv(((char)ch).ToString(), conv).ToCharArray()) { output.Write(c); } } else { break; } } return(true); }
public static string StrConv(string str, VbStrConv strConv, int flag) { return(str); }
// Perform a string conversion (we don't support simplified/traditional // conversions or linguistic casing yet). public static String StrConv (String str, VbStrConv Conversion, [Optional][DefaultValue(0)] int LocaleID) { if(str == null) { return null; } if((Conversion & VbStrConv.Wide) != 0) { str = Utils.ToWide(str); } else if((Conversion & VbStrConv.Narrow) != 0) { str = Utils.ToNarrow(str); } if((Conversion & VbStrConv.Katakana) != 0) { str = Utils.ToKatakana(str); } else if((Conversion & VbStrConv.Hiragana) != 0) { str = Utils.ToHiragana(str); } switch(Conversion & (VbStrConv)0x0003) { case VbStrConv.UpperCase: { str = GetTextInfo(LocaleID).ToUpper(str); } break; case VbStrConv.LowerCase: { str = GetTextInfo(LocaleID).ToLower(str); } break; case VbStrConv.ProperCase: { str = GetTextInfo(LocaleID).ToTitleCase(str); } break; } return str; }
public static string StrConv(string str, VbStrConv Conversion, int LocaleID) { }
public static string StrConv(string str, VbStrConv Conversion, int LocaleID = 0) { throw new NotImplementedException(); //return Microsoft.VisualBasic.Strings.StrConv(str, (Microsoft.VisualBasic.VbStrConv)Conversion, LocaleID); }