小编Mla*_*dic的帖子

为什么在删除Accents/Diacritics时不会将D扁平化为D.

我正在使用此方法从我的字符串中删除重音:

static string RemoveAccents(string input)
{
    string normalized = input.Normalize(NormalizationForm.FormKD);
    StringBuilder builder = new StringBuilder();
    foreach (char c in normalized)
    {
        if (char.GetUnicodeCategory(c) !=
        UnicodeCategory.NonSpacingMark)
        {
            builder.Append(c);
        }
    }
    return builder.ToString();
}
Run Code Online (Sandbox Code Playgroud)

但是这个方法使đ为đ,并且不会将其更改为d,即使d是其基本字符.您可以使用此输入字符串"æøåáâăäĺćçčéęěěîďđńňóôőöřůúűüýţ"进行尝试

字母đ中有什么特别之处?

.net c# string diacritics

17
推荐指数
1
解决办法
2857
查看次数

使用iTextSharp在PdfPCell中自动调整图像大小

我对iTextSharp库中的图像有一个奇怪的问题.我正在将图像添加到PdfPCell中,并且由于某种原因它会被放大.我如何保持原始尺寸? 这是 100%的PDF 图像,并在paint.net中打开原始大小的图像. alt text http://a.yfrog.com/img697/7102/3kn.png 我虽然打印时图像相同,但图片上的差异在打印版本上是相同的.必须使用ScaleXXX手动缩放图像以使其向右移动似乎有点不合逻辑并且不会给出好的结果.

那么如何将图像放在原始大小的表格的PdfPCell中而不必缩放呢?

这是我的代码:

private PdfPTable CreateTestPDF()
{
    PdfPTable table = new PdfPTable(1);
    table.WidthPercentage = 100;

    Phrase phrase = new Phrase("MY TITLE", _font24Bold);
    table.AddCell(phrase);

    PdfPTable nestedTable = new PdfPTable(5);
    table.WidthPercentage = 100;

    Phrase cellText = new Phrase("cell 1", _font9BoldBlack);
    nestedTable.AddCell(cellText);

    cellText = new Phrase("cell 2", _font9BoldBlack);
    nestedTable.AddCell(cellText);

    cellText = new Phrase("cell 3", _font9BoldBlack);
    nestedTable.AddCell(cellText);

    iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(@"d:\MyPic.jpg");
    image.Alignment = iTextSharp.text.Image.ALIGN_CENTER;
    PdfPCell cell = new PdfPCell(image);
    cell.HorizontalAlignment = PdfPCell.ALIGN_MIDDLE;
    nestedTable.AddCell(cell);

    cellText = new …
Run Code Online (Sandbox Code Playgroud)

c# pdf-generation itext

10
推荐指数
2
解决办法
3万
查看次数

C#string.GetHashCode()返回非int结果

我的一个客户有一个应用程序崩溃,我跟踪它由于这个错误/功能我无法解释.
WindowsIdentity.GetCurrent().Name.GetHashCode()返回此字符串: - ?2097695743
是,那是一个减号,一个空格,一个问号,然后是实际的哈希数.

这是一个简单的控制台应用程序的代码,显示了奇怪的行为.

static void Main(string[] args)
{
    Console.WriteLine("From String: string name = WindowsIdentity.GetCurrent().Name");            
    string name = WindowsIdentity.GetCurrent().Name;
    Console.WriteLine("name:                            " + name);
    Console.WriteLine("name.GetHashCode().GetType():    " + name.GetHashCode().GetType());
    Console.WriteLine("name.GetHashCode():              " + name.GetHashCode());
    Console.WriteLine("name.GetHashCode().ToString():   " + name.GetHashCode().ToString());
    Console.WriteLine();
    Console.WriteLine();
    Console.WriteLine("Direct");
    Console.WriteLine("WindowsIdentity.GetCurrent().Name:                           " + WindowsIdentity.GetCurrent().Name);
    Console.WriteLine("WindowsIdentity.GetCurrent().Name.GetHashCode().GetType():   " + WindowsIdentity.GetCurrent().Name.GetHashCode().GetType());
    Console.WriteLine("WindowsIdentity.GetCurrent().Name.GetHashCode():             " + WindowsIdentity.GetCurrent().Name.GetHashCode());
    Console.WriteLine("WindowsIdentity.GetCurrent().Name.GetHashCode().ToString():  " + WindowsIdentity.GetCurrent().Name.GetHashCode().ToString());
    Console.WriteLine();
    Console.WriteLine();
    Console.WriteLine("Press Enter to continue");
    Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)

这是文本输出:

From String: string name = WindowsIdentity.GetCurrent().Name
name:                            COMMARC\tje
name.GetHashCode().GetType():    System.Int32
name.GetHashCode():              - ?2097695743
name.GetHashCode().ToString():   - …
Run Code Online (Sandbox Code Playgroud)

.net c#

7
推荐指数
2
解决办法
839
查看次数

一个我无法弄清楚的正则表达式问题(负面看后面)

我如何用正则表达式做到这一点?

我想匹配这个字符串: -myString

但我不想匹配-myString此字符串:--myString

myString当然是什么.

它甚至可能吗?

编辑:

这里有一些关于我到目前为止所得到的信息,因为我发布了一个问题:

string to match:
some random stuff here -string1, --string2, other stuff here
regex:
(-)([\w])*
Run Code Online (Sandbox Code Playgroud)

此正则表达式返回我3场比赛: -string1,--string2

理想情况下,我希望它只返回我的-string1比赛

c# regex negative-lookbehind lookbehind

2
推荐指数
1
解决办法
2524
查看次数