> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/string/strcoll.3.md).

# strcoll.3

`strcoll` — 按当前排序规则比较字符串

## 名称

`strcoll`

## 库

Lb libc

## 概要

`#include <string.h>`

`Ft int Fn strcoll const char *s1 const char *s2 Ft int Fn strcoll_l const char *s1 const char *s2 locale_t loc`

## 描述

`strcoll` 函数根据当前 locale 的排序规则，按字典序比较以 NUL 结尾的字符串 `s1` 和 `s2`，返回一个大于、等于或小于 0 的整数，分别对应 `s1` 大于、等于或小于 `s2`。若当前 locale 排序规则的信息不可用，则返回 `strcmp(s1, s2)` 的值。`strcoll_l` 函数使用显式指定的 locale 参数而非系统 locale。

## 参见

setlocale(3), [strcmp(3)](/man/string/strcmp.3.md), [strxfrm(3)](/man/string/strxfrm.3.md), wcscoll(3)

## 标准

`strcoll` 函数遵循 ISO/IEC 9899:1990 ("ISO C89")。`strcoll_l` 函数遵循 IEEE Std 1003.1-2008 ("POSIX.1")。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/string/strcoll.3.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
